client/server: convert nr_zone_resets on the wire
[fio.git] / unittests / lib / strntol.c
CommitLineData
ce875031
TK
1#include "../unittest.h"
2
3#include "../../lib/strntol.h"
4
5static void test_strntol_1(void)
6{
7 char s[] = "12345";
8 char *endp = NULL;
9 long ret = strntol(s, strlen(s), &endp, 10);
10
11 CU_ASSERT_EQUAL(ret, 12345);
12 CU_ASSERT_NOT_EQUAL(endp, NULL);
13 CU_ASSERT_EQUAL(*endp, '\0');
14}
15
16static void test_strntol_2(void)
17{
18 char s[] = " 12345";
19 char *endp = NULL;
20 long ret = strntol(s, strlen(s), &endp, 10);
21
22 CU_ASSERT_EQUAL(ret, 12345);
23 CU_ASSERT_NOT_EQUAL(endp, NULL);
24 CU_ASSERT_EQUAL(*endp, '\0');
25}
26
27static void test_strntol_3(void)
28{
29 char s[] = "0x12345";
30 char *endp = NULL;
31 long ret = strntol(s, strlen(s), &endp, 16);
32
33 CU_ASSERT_EQUAL(ret, 0x12345);
34 CU_ASSERT_NOT_EQUAL(endp, NULL);
35 CU_ASSERT_EQUAL(*endp, '\0');
36}
37
38static struct fio_unittest_entry tests[] = {
39 {
40 .name = "strntol/1",
41 .fn = test_strntol_1,
42 },
43 {
44 .name = "strntol/2",
45 .fn = test_strntol_2,
46 },
47 {
48 .name = "strntol/3",
49 .fn = test_strntol_3,
50 },
51 {
52 .name = NULL,
53 },
54};
55
56CU_ErrorCode fio_unittest_lib_strntol(void)
57{
58 return fio_unittest_add_suite("lib/strntol.c", NULL, NULL, tests);
59}