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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
#define PK_IMPL_STN
#include "../pkstn.h"
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
(void)argc;
(void)argv;
char *s;
enum PK_STN_RES res = {0};
// stn_int64_t
{
int64_t i = {0};
res = pk_stn_int64_t(&i, "-1", &s, 0);
fprintf(stdout, "pkstn: stn_int64_t res: %ld\n", i);
if (res != PK_STN_RES_SUCCESS) exit(1);
if (-1 != i) exit(1);
}
// stn_uint64_t
{
uint64_t i = {0};
res = pk_stn_uint64_t(&i, "1", &s, 0);
fprintf(stdout, "pkstn: stn_uint64_t res: %lu\n", i);
if (res != PK_STN_RES_SUCCESS) exit(1);
if (1 != i) exit(1);
}
// stn_int32_t
{
int32_t i = {0};
res = pk_stn_int32_t(&i, "-1", &s, 0);
fprintf(stdout, "pkstn: stn_int32_t res: %d\n", i);
if (res != PK_STN_RES_SUCCESS) exit(1);
if (-1 != i) exit(1);
}
// stn_uint32_t
{
uint32_t i = {0};
res = pk_stn_uint32_t(&i, "1", &s, 0);
fprintf(stdout, "pkstn: stn_uint32_t res: %u\n", i);
if (res != PK_STN_RES_SUCCESS) exit(1);
if (1 != i) exit(1);
}
// stn_int16_t
{
int16_t i = {0};
res = pk_stn_int16_t(&i, "-1", &s, 0);
fprintf(stdout, "pkstn: stn_int16_t res: %d\n", i);
if (res != PK_STN_RES_SUCCESS) exit(1);
if (-1 != i) exit(1);
}
// stn_uint16_t
{
uint16_t i = {0};
res = pk_stn_uint16_t(&i, "1", &s, 0);
fprintf(stdout, "pkstn: stn_uint16_t res: %u\n", i);
if (res != PK_STN_RES_SUCCESS) exit(1);
if (1 != i) exit(1);
}
// stn_int8_t
{
int8_t i = {0};
res = pk_stn_int8_t(&i, "-1", &s, 0);
fprintf(stdout, "pkstn: stn_int8_t res: %d\n", i);
if (res != PK_STN_RES_SUCCESS) exit(1);
if (-1 != i) exit(1);
}
// stn_uint8_t
{
uint8_t i = {0};
res = pk_stn_uint8_t(&i, "1", &s, 0);
fprintf(stdout, "pkstn: stn_uint8_t res: %u\n", i);
if (res != PK_STN_RES_SUCCESS) exit(1);
if (1 != i) exit(1);
}
// stn_float
{
float f = {0};
res = pk_stn_float(&f, "-1", &s);
fprintf(stdout, "pkstn: stn_float res: %f\n", f);
if (res != PK_STN_RES_SUCCESS) exit(1);
if (-1 != f) exit(1);
}
// stn_double
{
double f = {0};
res = pk_stn_double(&f, "-1", &s);
fprintf(stdout, "pkstn: stn_double res: %f\n", f);
if (res != PK_STN_RES_SUCCESS) exit(1);
if (-1 != f) exit(1);
}
return 0;
}
|