From 97a9b70bc2f779b9267d02c255628fd7895a53b3 Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Tue, 10 Dec 2024 15:45:38 -0500 Subject: pkstn: first-pass --- test/pkstn.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/pkstn.cpp | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 208 insertions(+) create mode 100644 test/pkstn.c create mode 100644 test/pkstn.cpp (limited to 'test') 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 +#include + +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 +#include + +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; +} -- cgit v1.2.3