curl-curl/tests/data/test1664
Daniel Stenberg 255aac56f9
curlx: move into to curlx/
Move curlx_ functions into its own subdir.

The idea is to use the curlx_ prefix proper on these functions, and use
these same function names both in tool, lib and test suite source code.
Stop the previous special #define setup for curlx_ names.

The printf defines are now done for the library alone. Tests no longer
use the printf defines. The tool code sets its own defines. The printf
functions are not curlx, they are publicly available.

The strcase defines are not curlx_ functions and should not be used by
tool or server code.

dynbuf, warnless, base64, strparse, timeval, timediff are now proper
curlx functions.

When libcurl is built statically, the functions from the library can be
used as-is. The key is then that the functions must work as-is, without
having to be recompiled for use in tool/tests. This avoids symbol
collisions - when libcurl is built statically, we use those functions
directly when building the tool/tests. When libcurl is shared, we
build/link them separately for the tool/tests.

Assisted-by: Jay Satiro

Closes #17253
2025-05-07 11:01:15 +02:00

241 lines
7.1 KiB
Plaintext

<testcase>
<info>
<keywords>
unittest
strparse
</keywords>
</info>
#
# Client-side
<client>
<server>
none
</server>
<features>
unittest
large-size
</features>
<name>
unit tests for strparse.c string parsing functions
</name>
</client>
<verify>
<stdout>
curlx_str_word
0: ("word") 0, "word" [4], line 4
1: ("word ") 0, "word" [4], line 4
2: (" word ") 2, "" [0], line 0
3: ("wo rd") 0, "wo" [2], line 2
4: ("word(") 0, "word(" [5], line 5
5: ("wor(d") 0, "wor(d" [5], line 5
6: ("perfect") 0, "perfect" [7], line 7
7: ("") 2, "" [0], line 0
8: ("longerth") 1, "" [0], line 0
curlx_str_until
0: ("word") 0, "wor" [3], line 3
1: ("word ") 0, "wor" [3], line 3
2: (" word ") 0, " wor" [4], line 4
3: ("wo rd") 0, "wo r" [4], line 4
4: ("word(") 0, "wor" [3], line 3
5: ("wor(d") 0, "wor(" [4], line 4
6: ("perfect") 0, "perfect" [7], line 7
7: ("") 2, "" [0], line 0
8: ("longerth") 1, "" [0], line 0
curlx_str_quotedword
0: (""word"") 0, "word" [4], line 6
1: (""word") 4, "" [0], line 0
2: ("word"") 3, "" [0], line 0
3: (""word""") 0, "word" [4], line 6
4: (""word" ") 0, "word" [4], line 6
5: (" "word"") 3, "" [0], line 0
6: (""perfect"") 0, "perfect" [7], line 9
7: (""p r e t"") 0, "p r e t" [7], line 9
8: (""perfec\"") 0, "perfec\" [7], line 9
9: ("""") 0, "" [0], line 2
10: ("") 3, "" [0], line 0
11: (""longerth"") 1, "" [0], line 0
curlx_str_single
0: ("a") 0, line 1
1: ("aa") 0, line 1
2: ("A") 5, line 0
3: ("b") 5, line 0
4: ("\") 5, line 0
5: (" ") 5, line 0
6: ("") 5, line 0
curlx_str_singlespace
0: ("a") 5, line 0
1: ("aa") 5, line 0
2: ("A") 5, line 0
3: ("b") 5, line 0
4: ("\") 5, line 0
5: (" ") 0, line 1
6: (" ") 5, line 0
7: ("
") 5, line 0
8: ("") 5, line 0
curlx_str_single
0: ("a") 0, line 1
1: ("aa") 0, line 1
2: ("A") 5, line 0
3: ("b") 5, line 0
4: ("\") 5, line 0
5: (" ") 5, line 0
6: ("") 5, line 0
curlx_str_number
0: ("1") 0, [1] line 1
1: ("10000") 7, [0] line 0
2: ("1234") 0, [1234] line 4
3: ("1235") 0, [1235] line 4
4: ("1236") 7, [0] line 0
5: ("01234") 0, [1234] line 5
6: ("00000000000000000000000000001234") 0, [1234] line 32
7: ("0123 345") 0, [123] line 4
8: ("0123O345") 0, [123] line 4
9: ("-12") 8, [0] line 0
10: (" 123") 8, [0] line 0
11: ("") 8, [0] line 0
curlx_str_number varying max
0: ("00") max 8 == 0, [0]
1: ("1") max 8 == 0, [1]
2: ("1") max 1 == 0, [1]
3: ("2") max 1 == 7, [0]
4: ("2") max 2 == 0, [2]
5: ("5") max 6 == 0, [5]
6: ("000000000000000000000006") max 6 == 0, [6]
7: ("7") max 6 == 7, [0]
8: ("8") max 6 == 7, [0]
9: ("9") max 8 == 7, [0]
10: ("10") max 10 == 0, [10]
11: ("11") max 10 == 7, [0]
12: ("12") max 10 == 7, [0]
curlx_str_hex varying max
0: ("00") max 8 == 0, [0]
1: ("1") max 8 == 0, [1]
2: ("1") max 1 == 0, [1]
3: ("2") max 1 == 7, [0]
4: ("2") max 2 == 0, [2]
5: ("5") max 6 == 0, [5]
6: ("000000000000000000000006") max 6 == 0, [6]
7: ("7") max 6 == 7, [0]
8: ("8") max 6 == 7, [0]
9: ("9") max 8 == 7, [0]
10: ("a") max 14 == 0, [10]
11: ("b") max 14 == 0, [11]
12: ("c") max 14 == 0, [12]
13: ("d") max 14 == 0, [13]
14: ("e") max 14 == 0, [14]
15: ("f") max 14 == 7, [0]
16: ("f") max 15 == 0, [15]
17: ("10") max 16 == 0, [16]
18: ("11") max 16 == 7, [0]
19: ("12") max 16 == 7, [0]
curlx_str_octal varying max
0: ("00") max 4 == 0, [0]
1: ("1") max 4 == 0, [1]
2: ("1") max 4 == 0, [1]
3: ("2") max 4 == 0, [2]
4: ("3") max 4 == 0, [3]
5: ("4") max 4 == 0, [4]
6: ("5") max 4 == 7, [0]
7: ("000000000000000000000006") max 6 == 0, [6]
8: ("7") max 7 == 0, [7]
9: ("10") max 8 == 0, [8]
10: ("11") max 8 == 7, [0]
11: ("11") max 9 == 0, [9]
12: ("12") max 9 == 7, [0]
13: ("13") max 9 == 7, [0]
14: ("8") max 10 == 8, [0]
curlx_str_number / max
0: ("9223372036854775807") 0, [9223372036854775807] line 19
1: ("9223372036854775808") 7, [0] line 0
2: ("18446744073709551615") 7, [0] line 0
3: ("18446744073709551616") 7, [0] line 0
4: ("18446744073709551617") 7, [0] line 0
5: ("0123456799a") 0, [123456799] line 10
6: ("0123456789") 0, [123456789] line 10
7: ("123498760b") 0, [123498760] line 9
8: ("1234987607611298232") 0, [1234987607611298232] line 19
9: ("1111111111111111111") 0, [1111111111111111111] line 19
10: ("2222222222222222222") 0, [2222222222222222222] line 19
11: ("00000000000000000000000000000009223372036854775807") 0, [9223372036854775807] line 50
12: ("3333333333333333333") 0, [3333333333333333333] line 19
13: ("4444444444444444444") 0, [4444444444444444444] line 19
14: ("5555555555555555555") 0, [5555555555555555555] line 19
15: ("6666666666666666666") 0, [6666666666666666666] line 19
16: ("7777777777777777777") 0, [7777777777777777777] line 19
17: ("8888888888888888888") 0, [8888888888888888888] line 19
18: ("999999999999999999") 0, [999999999999999999] line 18
curlx_str_newline
0: (%61) 6, line 0
1: (%61) 6, line 0
2: (%41) 6, line 0
3: (%62) 6, line 0
4: (%5c) 6, line 0
5: (%20) 6, line 0
6: (%0a) 0, line 1
7: (%0d) 0, line 1
8: (%0d) 0, line 1
9: (%0c) 6, line 0
10: (%00) 6, line 0
curlx_str_hex
0: ("1") 0, [1] line 1
1: ("1000") 0, [4096] line 4
2: ("1234") 0, [4660] line 4
3: ("1235") 0, [4661] line 4
4: ("1236") 7, [0] line 0
5: ("01234") 0, [4660] line 5
6: ("00000000000000000000000000001234") 0, [4660] line 32
7: ("0123 345") 0, [291] line 4
8: ("0123O345") 0, [291] line 4
9: ("-12") 8, [0] line 0
10: (" 123") 8, [0] line 0
11: ("") 8, [0] line 0
curlx_str_octal
0: ("1") 0, [1] line 1
1: ("1000") 0, [512] line 4
2: ("1234") 0, [668] line 4
3: ("1235") 0, [669] line 4
4: ("1236") 7, [0] line 0
5: ("01234") 0, [668] line 5
6: ("00000000000000000000000000001234") 0, [668] line 32
7: ("0123 345") 0, [83] line 4
8: ("0123O345") 0, [83] line 4
9: ("-12") 8, [0] line 0
10: (" 123") 8, [0] line 0
11: ("") 8, [0] line 0
curlx_str_octal / max
0: ("777777777777777777777") 0, [9223372036854775807] line 21
1: ("1000000000000000000000") 7, [0] line 0
2: ("111111111111111111111") 0, [1317624576693539401] line 21
3: ("222222222222222222222") 0, [2635249153387078802] line 21
4: ("333333333333333333333") 0, [3952873730080618203] line 21
5: ("444444444444444444444") 0, [5270498306774157604] line 21
6: ("555555555555555555555") 0, [6588122883467697005] line 21
7: ("666666666666666666666") 0, [7905747460161236406] line 21
curlx_str_hex / max
0: ("7FFFFFFFFFFFFFFF") 0, [9223372036854775807] line 16
1: ("8000000000000000") 7, [0] line 0
2: ("1111111111111111") 0, [1229782938247303441] line 16
3: ("2222222222222222") 0, [2459565876494606882] line 16
4: ("3333333333333333") 0, [3689348814741910323] line 16
5: ("4444444444444444") 0, [4919131752989213764] line 16
6: ("5555555555555555") 0, [6148914691236517205] line 16
7: ("6666666666666666") 0, [7378697629483820646] line 16
8: ("7777777777777777") 0, [8608480567731124087] line 16
9: ("888888888888888") 0, [614891469123651720] line 15
10: ("999999999999999") 0, [691752902764108185] line 15
11: ("aaaaaaaaAAAAAAA") 0, [768614336404564650] line 15
12: ("bbbbbbbbBBBBBBB") 0, [845475770045021115] line 15
13: ("BBBBBBBBbbbbbbb") 0, [845475770045021115] line 15
14: ("ccccccccCCCCCCC") 0, [922337203685477580] line 15
15: ("ddddddddDDDDDDD") 0, [999198637325934045] line 15
16: ("eeeeeeeeEEEEEEE") 0, [1076060070966390510] line 15
17: ("ffffffffFFFFFFF") 0, [1152921504606846975] line 15
18: ("abcdef") 0, [11259375] line 6
19: ("ABCDEF") 0, [11259375] line 6
</stdout>
</verify>
</testcase>