@@ -40,116 +40,117 @@ int main(void)
4040 .desc = "Convert integer with non-numeric suffix" ,
4141 .input = "123abc" ,
4242 .expected = 123 ,
43- }, {
44- .desc = "Convert positive zero" ,
45- .input = "0" ,
46- .expected = 0 ,
47- },
48- {
49- .desc = "Convert negative zero" ,
50- .input = "-0" ,
51- .expected = 0 ,
52- },
53- {
54- .desc = "Convert integer with leading zeros" ,
55- .input = "000123" ,
56- .expected = 123 ,
57- },
58- {
59- .desc = "Convert integer with leading zeros and plus sign" ,
60- .input = "+000123" ,
61- .expected = 123 ,
62- },
63- {
64- .desc = "Convert integer with maximum value for int" ,
65- .input = "2147483647" ,
66- .expected = 2147483647 ,
67- },
68- {
69- .desc = "Convert integer with minimum value for int" ,
70- .input = "-2147483648" ,
71- .expected = -2147483648 ,
72- },
73- {
74- .desc = "Convert integer with overflow value" ,
75- .input = "2147483648" ,
76- .expected = -2147483648 ,
77- },
78- {
79- .desc = "Convert integer with underflow value" ,
80- .input = "-2147483649" ,
81- .expected = 2147483647 ,
82- },
83- {
84- .desc = "Convert integer with only negative sign" ,
85- .input = "-" ,
86- .expected = 0 ,
87- },
88- {
89- .desc = "Convert integer with only plus sign" ,
90- .input = "+" ,
91- .expected = 0 ,
92- },
93- {
94- .desc = "Convert empty string" ,
95- .input = "" ,
96- .expected = 0 ,
97- },
98- {
99- .desc = "Convert string with only spaces" ,
100- .input = " " ,
101- .expected = 0 ,
102- },
103- {
104- .desc = "Convert string with spaces between digits" ,
105- .input = "12 34" ,
106- .expected = 12 ,
107- },
108- {
109- .desc = "Convert string with mixed spaces and signs" ,
110- .input = " +12 34" ,
111- .expected = 12 ,
112- },
113- {
114- .desc = "Convert string with non-numeric prefix" ,
115- .input = "abc123" ,
116- .expected = 0 ,
117- },
118- {
119- .desc = "Convert string with non-numeric prefix and sign" ,
120- .input = "+abc123" ,
121- .expected = 0 ,
122- },
123- {
124- .desc = "Convert string with non-numeric suffix and sign" ,
125- .input = "123abc+" ,
126- .expected = 123 ,
127- },
128- {
129- .desc = "Convert string with leading whitespaces, sign and zero" ,
130- .input = " - 0000" ,
131- .expected = 0 ,
132- },
133- {
134- .desc = "Convert string with multiple signs" ,
135- .input = "--123" ,
136- .expected = 123 ,
137- },
138- {
139- .desc = "Convert string with multiple signs" ,
140- .input = "++123" ,
141- .expected = 123 ,
142- },
143- {
144- .desc = "Convert string with invalid signs" ,
145- .input = "+-123" ,
146- .expected = -123 ,
147- },
148- {
149- .desc = "Convert string with out of range chars" ,
150- .input = "1 2 3 4 5 6 7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z" ,
151- .expected = 1 ,
152- },
43+ },
44+ {
45+ .desc = "Convert positive zero" ,
46+ .input = "0" ,
47+ .expected = 0 ,
48+ },
49+ {
50+ .desc = "Convert negative zero" ,
51+ .input = "-0" ,
52+ .expected = 0 ,
53+ },
54+ {
55+ .desc = "Convert integer with leading zeros" ,
56+ .input = "000123" ,
57+ .expected = 123 ,
58+ },
59+ {
60+ .desc = "Convert integer with leading zeros and plus sign" ,
61+ .input = "+000123" ,
62+ .expected = 123 ,
63+ },
64+ {
65+ .desc = "Convert integer with maximum value for int" ,
66+ .input = "2147483647" ,
67+ .expected = 2147483647 ,
68+ },
69+ {
70+ .desc = "Convert integer with minimum value for int" ,
71+ .input = "-2147483648" ,
72+ .expected = -2147483648 ,
73+ },
74+ {
75+ .desc = "Convert integer with overflow value" ,
76+ .input = "2147483648" ,
77+ .expected = -2147483648 ,
78+ },
79+ {
80+ .desc = "Convert integer with underflow value" ,
81+ .input = "-2147483649" ,
82+ .expected = 2147483647 ,
83+ },
84+ {
85+ .desc = "Convert integer with only negative sign" ,
86+ .input = "-" ,
87+ .expected = 0 ,
88+ },
89+ {
90+ .desc = "Convert integer with only plus sign" ,
91+ .input = "+" ,
92+ .expected = 0 ,
93+ },
94+ {
95+ .desc = "Convert empty string" ,
96+ .input = "" ,
97+ .expected = 0 ,
98+ },
99+ {
100+ .desc = "Convert string with only spaces" ,
101+ .input = " " ,
102+ .expected = 0 ,
103+ },
104+ {
105+ .desc = "Convert string with spaces between digits" ,
106+ .input = "12 34" ,
107+ .expected = 12 ,
108+ },
109+ {
110+ .desc = "Convert string with mixed spaces and signs" ,
111+ .input = " +12 34" ,
112+ .expected = 12 ,
113+ },
114+ {
115+ .desc = "Convert string with non-numeric prefix" ,
116+ .input = "abc123" ,
117+ .expected = 0 ,
118+ },
119+ {
120+ .desc = "Convert string with non-numeric prefix and sign" ,
121+ .input = "+abc123" ,
122+ .expected = 0 ,
123+ },
124+ {
125+ .desc = "Convert string with non-numeric suffix and sign" ,
126+ .input = "123abc+" ,
127+ .expected = 123 ,
128+ },
129+ {
130+ .desc = "Convert string with leading whitespaces, sign and zero" ,
131+ .input = " - 0000" ,
132+ .expected = 0 ,
133+ },
134+ {
135+ .desc = "Convert string with multiple signs" ,
136+ .input = "--123" ,
137+ .expected = 123 ,
138+ },
139+ {
140+ .desc = "Convert string with multiple signs" ,
141+ .input = "++123" ,
142+ .expected = 123 ,
143+ },
144+ {
145+ .desc = "Convert string with invalid signs" ,
146+ .input = "+-123" ,
147+ .expected = -123 ,
148+ },
149+ {
150+ .desc = "Convert string with out of range chars" ,
151+ .input = "1 2 3 4 5 6 7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z" ,
152+ .expected = 1 ,
153+ },
153154 };
154155 int count = sizeof (tests ) / sizeof (tests [0 ]);
155156
0 commit comments