diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2024-12-10 15:45:38 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2024-12-10 16:22:30 -0500 |
| commit | 97a9b70bc2f779b9267d02c255628fd7895a53b3 (patch) | |
| tree | 2185cb60964d38345b1de220027476ff6af70d20 /test | |
| parent | a3cc7699c56ae324733bd7c4c4808090b28a2377 (diff) | |
pkstn: first-pass
Diffstat (limited to 'test')
| -rw-r--r-- | test/pkstn.c | 104 | ||||
| -rw-r--r-- | test/pkstn.cpp | 104 |
2 files changed, 208 insertions, 0 deletions
diff --git a/test/pkstn.c b/test/pkstn.c new file mode 100644 index 0000000..97ec8a9 --- /dev/null +++ b/test/pkstn.c @@ -0,0 +1,104 @@ + +#include "../pkstn.h" + +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char *argv[]) +{ + (void)argc; + (void)argv; + enum PK_STN_ERR res = {0}; + + // stn_int64_t + { + int64_t i = {0}; + res = pk_stn_int64_t(&i, "-1", 0); + fprintf(stdout, "pkstn: stn_int64_t res: %ld\n", i); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (-1 != i) exit(1); + } + + // stn_uint64_t + { + uint64_t i = {0}; + res = pk_stn_uint64_t(&i, "1", 0); + fprintf(stdout, "pkstn: stn_uint64_t res: %lu\n", i); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (1 != i) exit(1); + } + + // stn_int32_t + { + int32_t i = {0}; + res = pk_stn_int32_t(&i, "-1", 0); + fprintf(stdout, "pkstn: stn_int32_t res: %d\n", i); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (-1 != i) exit(1); + } + + // stn_uint32_t + { + uint32_t i = {0}; + res = pk_stn_uint32_t(&i, "1", 0); + fprintf(stdout, "pkstn: stn_uint32_t res: %u\n", i); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (1 != i) exit(1); + } + + // stn_int16_t + { + int16_t i = {0}; + res = pk_stn_int16_t(&i, "-1", 0); + fprintf(stdout, "pkstn: stn_int16_t res: %d\n", i); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (-1 != i) exit(1); + } + + // stn_uint16_t + { + uint16_t i = {0}; + res = pk_stn_uint16_t(&i, "1", 0); + fprintf(stdout, "pkstn: stn_uint16_t res: %u\n", i); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (1 != i) exit(1); + } + + // stn_int8_t + { + int8_t i = {0}; + res = pk_stn_int8_t(&i, "-1", 0); + fprintf(stdout, "pkstn: stn_int8_t res: %d\n", i); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (-1 != i) exit(1); + } + + // stn_uint8_t + { + uint8_t i = {0}; + res = pk_stn_uint8_t(&i, "1", 0); + fprintf(stdout, "pkstn: stn_uint8_t res: %u\n", i); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (1 != i) exit(1); + } + + // stn_float + { + float f = {0}; + res = pk_stn_float(&f, "-1"); + fprintf(stdout, "pkstn: stn_float res: %f\n", f); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (-1 != f) exit(1); + } + + // stn_double + { + double f = {0}; + res = pk_stn_double(&f, "-1"); + fprintf(stdout, "pkstn: stn_double res: %f\n", f); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (-1 != f) exit(1); + } + + return 0; +} diff --git a/test/pkstn.cpp b/test/pkstn.cpp new file mode 100644 index 0000000..261fb56 --- /dev/null +++ b/test/pkstn.cpp @@ -0,0 +1,104 @@ + +#include "../pkstn.h" + +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char *argv[]) +{ + (void)argc; + (void)argv; + enum PK_STN_ERR res = {}; + + // stn_int64_t + { + int64_t i = {0}; + res = pk_stn_int64_t(&i, "-1", 0); + fprintf(stdout, "pkstn: stn_int64_t res: %ld\n", i); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (-1 != i) exit(1); + } + + // stn_uint64_t + { + uint64_t i = {0}; + res = pk_stn_uint64_t(&i, "1", 0); + fprintf(stdout, "pkstn: stn_uint64_t res: %lu\n", i); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (1 != i) exit(1); + } + + // stn_int32_t + { + int32_t i = {0}; + res = pk_stn_int32_t(&i, "-1", 0); + fprintf(stdout, "pkstn: stn_int32_t res: %d\n", i); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (-1 != i) exit(1); + } + + // stn_uint32_t + { + uint32_t i = {0}; + res = pk_stn_uint32_t(&i, "1", 0); + fprintf(stdout, "pkstn: stn_uint32_t res: %u\n", i); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (1 != i) exit(1); + } + + // stn_int16_t + { + int16_t i = {0}; + res = pk_stn_int16_t(&i, "-1", 0); + fprintf(stdout, "pkstn: stn_int16_t res: %d\n", i); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (-1 != i) exit(1); + } + + // stn_uint16_t + { + uint16_t i = {0}; + res = pk_stn_uint16_t(&i, "1", 0); + fprintf(stdout, "pkstn: stn_uint16_t res: %u\n", i); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (1 != i) exit(1); + } + + // stn_int8_t + { + int8_t i = {0}; + res = pk_stn_int8_t(&i, "-1", 0); + fprintf(stdout, "pkstn: stn_int8_t res: %d\n", i); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (-1 != i) exit(1); + } + + // stn_uint8_t + { + uint8_t i = {0}; + res = pk_stn_uint8_t(&i, "1", 0); + fprintf(stdout, "pkstn: stn_uint8_t res: %u\n", i); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (1 != i) exit(1); + } + + // stn_float + { + float f = {0}; + res = pk_stn_float(&f, "-1"); + fprintf(stdout, "pkstn: stn_float res: %f\n", f); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (-1 != f) exit(1); + } + + // stn_double + { + double f = {0}; + res = pk_stn_double(&f, "-1"); + fprintf(stdout, "pkstn: stn_double res: %f\n", f); + if (res != PK_STN_ERR_SUCCESS) exit(1); + if (-1 != f) exit(1); + } + + return 0; +} |
