2 lib/strutil - tests for lib/strutil/parse_integer function.
4 Copyright (C) 2013-2016
5 Free Software Foundation, Inc.
8 Andrew Borodin <aborodin@vmail.ru>, 2013
10 This file is part of the Midnight Commander.
12 The Midnight Commander is free software: you can redistribute it
13 and/or modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation, either version 3 of the License,
15 or (at your option) any later version.
17 The Midnight Commander is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #define TEST_SUITE_NAME "/lib/strutil"
28 #include "tests/mctest.h"
32 #include "lib/strutil.h"
34 /* --------------------------------------------------------------------------------------------- */
42 /* --------------------------------------------------------------------------------------------- */
50 /* --------------------------------------------------------------------------------------------- */
52 /* @DataSource("str_replace_all_test_ds") */
54 static const struct parse_integer_test_ds
57 uintmax_t expected_result
;
59 } parse_integer_test_ds
[] =
63 "99999999999999999999999999999999999999999999999999999999999999999999",
114 1 * 1024 * 1024 * 1024,
120 /* @Test(dataSource = "str_replace_all_test_ds") */
122 START_TEST (parse_integer_test
)
126 uintmax_t actual_result
;
127 gboolean invalid
= FALSE
;
128 const struct parse_integer_test_ds
*data
= &parse_integer_test_ds
[_i
];
131 actual_result
= parse_integer (data
->haystack
, &invalid
);
134 fail_unless (invalid
== data
->invalid
&& actual_result
== data
->expected_result
,
135 "actial ( %" PRIuMAX
") not equal to\nexpected (%" PRIuMAX
")",
136 actual_result
, data
->expected_result
);
142 /* --------------------------------------------------------------------------------------------- */
149 Suite
*s
= suite_create (TEST_SUITE_NAME
);
150 TCase
*tc_core
= tcase_create ("Core");
153 tcase_add_checked_fixture (tc_core
, setup
, teardown
);
155 /* Add new tests here: *************** */
156 tcase_add_loop_test (tc_core
, parse_integer_test
, 0, G_N_ELEMENTS (parse_integer_test_ds
));
157 /* *********************************** */
159 suite_add_tcase (s
, tc_core
);
160 sr
= srunner_create (s
);
161 srunner_set_log (sr
, "parse_integer.log");
162 srunner_run_all (sr
, CK_ENV
);
163 number_failed
= srunner_ntests_failed (sr
);
165 return (number_failed
== 0) ? EXIT_SUCCESS
: EXIT_FAILURE
;
168 /* --------------------------------------------------------------------------------------------- */