This source file includes following definitions.
- START_PARAMETRIZED_TEST
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #define TEST_SUITE_NAME "/lib/strutil"
27
28 #include "tests/mctest.h"
29
30 #include <inttypes.h>
31
32 #include "lib/strutil.h"
33
34
35
36
37 static const struct parse_integer_test_ds
38 {
39 const char *haystack;
40 uintmax_t expected_result;
41 gboolean invalid;
42 } parse_integer_test_ds[] = {
43 {
44 "99999999999999999999999999999999999999999999999999999999999999999999", 0, TRUE },
45 { "x", 0, TRUE },
46 { "9x", 0, TRUE },
47 { "1", 1, FALSE },
48 { "-1", 0, TRUE },
49 { "1k", 1024, FALSE },
50 { "1K", 1024, FALSE },
51 { "1M", 1024 * 1024, FALSE },
52 { "1m", 0, TRUE },
53 { "64M", 64 * 1024 * 1024, FALSE },
54 { "1G", 1 * 1024 * 1024 * 1024, FALSE },
55 };
56
57
58 START_PARAMETRIZED_TEST (parse_integer_test, parse_integer_test_ds)
59 {
60
61 uintmax_t actual_result;
62 gboolean invalid = FALSE;
63
64
65 actual_result = parse_integer (data->haystack, &invalid);
66
67
68 ck_assert_msg (invalid == data->invalid && actual_result == data->expected_result,
69 "actual ( %" PRIuMAX ") not equal to\nexpected (%" PRIuMAX ")", actual_result,
70 data->expected_result);
71 }
72 END_PARAMETRIZED_TEST
73
74
75
76 int
77 main (void)
78 {
79 TCase *tc_core;
80
81 tc_core = tcase_create ("Core");
82
83
84 mctest_add_parameterized_test (tc_core, parse_integer_test, parse_integer_test_ds);
85
86
87 return mctest_run_all (tc_core);
88 }
89
90