diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-01-10 10:08:05 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-01-10 10:08:05 -0500 |
| commit | 79e040d203e63ec79bb124215dcd1e940f7b676c (patch) | |
| tree | 23c11c6911b99161d0063e63122d9dd15485e1ed /test | |
| parent | 74fb835d28f2a4e604a32fd292bb3060a832a1db (diff) | |
pk.h: handle gcc compiler warnings; breaking changes
Diffstat (limited to 'test')
| -rw-r--r-- | test/pkarr.cpp | 2 | ||||
| -rw-r--r-- | test/pkev.cpp | 18 | ||||
| -rw-r--r-- | test/pkmacros.cpp | 32 | ||||
| -rw-r--r-- | test/pkmem-types.cpp | 16 |
4 files changed, 35 insertions, 33 deletions
diff --git a/test/pkarr.cpp b/test/pkarr.cpp index d60d90c..306dd51 100644 --- a/test/pkarr.cpp +++ b/test/pkarr.cpp @@ -1,4 +1,6 @@ +#include <cstring> + #include "../pkarr.h" void diff --git a/test/pkev.cpp b/test/pkev.cpp index 652f020..dd227ce 100644 --- a/test/pkev.cpp +++ b/test/pkev.cpp @@ -50,13 +50,13 @@ test_setup() return evmgr; } -struct cb_data { +typedef struct cb_data { int i; struct ev *ev; -}; +} cb_data; void stress_cb(void *, void *, void *user_data) { - struct cb_data *data = reinterpret_cast<struct cb_data*>(user_data); + cb_data *data = reinterpret_cast<cb_data*>(user_data); data->ev[data->i].handled = true; data->ev[data->i].count += 1; } @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) (void)argc; (void)argv; (void)stdout; - int i, ii; + size_t i, ii; // register, emit, catch @@ -84,7 +84,7 @@ int main(int argc, char *argv[]) pk_ev_register_cb(evmgr, ev_two.evid, &invoke_packged_task, NULL); pk_ev_emit(evmgr, ev_one.evid, &handle_ev_one); pk_ev_emit(evmgr, ev_two.evid, &handle_ev_two); - PK_LOGV_INF("%s: ev_one: %b, ev_two: %b\n", __FILE__, ev_one.handled, ev_two.handled); + PK_LOGV_INF("%s: ev_one: %s, ev_two: %s\n", __FILE__, ev_one.handled ? "true" : "false", ev_two.handled ? "true" : "false"); pk_ev_teardown(); fflush(stdout); fflush(stderr); @@ -104,7 +104,7 @@ int main(int argc, char *argv[]) auto t2 = std::thread([&handle_ev_two]() { pk_ev_emit(ev_two.evmgr, ev_two.evid, &handle_ev_two); }); t1.join(); t2.join(); - PK_LOGV_INF("%s: ev_one: %b, ev_two: %b\n", __FILE__, ev_one.handled, ev_two.handled); + PK_LOGV_INF("%s: ev_one: %s, ev_two: %s\n", __FILE__, ev_one.handled ? "true" : "false", ev_two.handled ? "true" : "false"); pk_ev_teardown(); fflush(stdout); fflush(stderr); @@ -126,7 +126,7 @@ int main(int argc, char *argv[]) } for (i = 0; i < ev_count; ++i) { - struct cb_data *d = new struct cb_data{}; + cb_data *d = new cb_data{}; d->ev = evs; d->i = i; pk_ev_emit(evs[i].evmgr, evs[i].evid, d); @@ -134,7 +134,7 @@ int main(int argc, char *argv[]) bool any_false = false; for (i = 0; i < ev_count; ++i) { - PK_LOGV_INF("%s: ev# %.2i: %b, called count: %i\n", __FILE__, i, evs[i].handled, evs[i].count); + PK_LOGV_INF("%s: ev# %.2zu: %s, called count: %i\n", __FILE__, i, evs[i].handled ? "true" : "false", evs[i].count); any_false = any_false || !evs[i].handled; } pk_ev_teardown(); @@ -158,7 +158,7 @@ int main(int argc, char *argv[]) } for (i = 0; i < ev_count; ++i) { - struct cb_data *d = new struct cb_data{}; + cb_data *d = new cb_data{}; d->ev = evs; d->i = i; pk_ev_emit(evs[i].evmgr, evs[i].evid, d); diff --git a/test/pkmacros.cpp b/test/pkmacros.cpp index 5e5377f..8edcbfd 100644 --- a/test/pkmacros.cpp +++ b/test/pkmacros.cpp @@ -136,8 +136,8 @@ int main(int argc, char *argv[]) // MISC { - PK_LOGV_INF("PK_HAS_FLAG 000: %b\n", PK_HAS_FLAG(0xFF, 5)); - PK_LOGV_INF("PK_HAS_FLAG 001: %b\n", PK_HAS_FLAG(0x0F, 5)); + PK_LOGV_INF("PK_HAS_FLAG 000: %s\n", PK_HAS_FLAG(0xFF, 5) ? "true" : "false"); + PK_LOGV_INF("PK_HAS_FLAG 001: %s\n", PK_HAS_FLAG(0x0F, 5) ? "true" : "false"); PK_LOGV_INF("PK_CLAMP 000: %i\n", PK_CLAMP(0, -10, 10)); PK_LOGV_INF("PK_CLAMP 001: %i\n", PK_CLAMP(-20, -10, 10)); PK_LOGV_INF("PK_CLAMP 002: %i\n", PK_CLAMP(20, -10, 10)); @@ -154,9 +154,9 @@ int main(int argc, char *argv[]) { bool b = false; if IS_CONSTRUCTIBLE(sdc) b = true; - fprintf(stdout, "class sdc IS_CONSTRUCTIBLE: %b\n", b); + fprintf(stdout, "class sdc IS_CONSTRUCTIBLE: %s\n", b ? "true" : "false"); if IS_DESTRUCTIBLE(sdc) b = false; - fprintf(stdout, "class sdc IS_DESTRUCTIBLE: %b\n", b); + fprintf(stdout, "class sdc IS_DESTRUCTIBLE: %s\n", b ? "true" : "false"); } // TypeSafeInt @@ -169,22 +169,22 @@ int main(int argc, char *argv[]) PK_LOGV_INF(PK_TO_BIN_PAT_16"\n", PK_TO_BIN_16(static_cast<MyConstexprTSI_16_T>(MyConstexprTSI_16_MAX))); PK_LOGV_INF(PK_TO_BIN_PAT_32"\n", PK_TO_BIN_32(static_cast<MyConstexprTSI_32_T>(MyConstexprTSI_32_MAX))); PK_LOGV_INF(PK_TO_BIN_PAT_64"\n", PK_TO_BIN_64(static_cast<MyConstexprTSI_64_T>(MyConstexprTSI_64_MAX))); - PK_LOGV_INF("tsi_test_operators 08: %b\n", tsi_test_operators<MyTSI_8, MyTSI_8_T>()); - PK_LOGV_INF("tsi_test_operators 16: %b\n", tsi_test_operators<MyTSI_16, MyTSI_16_T>()); - PK_LOGV_INF("tsi_test_operators 32: %b\n", tsi_test_operators<MyTSI_32, MyTSI_32_T>()); - PK_LOGV_INF("tsi_test_operators 64: %b\n", tsi_test_operators<MyTSI_64, MyTSI_64_T>()); - PK_LOGV_INF("tsi_test_operators c08: %b\n", tsi_test_operators<MyConstexprTSI_8, MyConstexprTSI_8_T>()); - PK_LOGV_INF("tsi_test_operators c16: %b\n", tsi_test_operators<MyConstexprTSI_16, MyConstexprTSI_16_T>()); - PK_LOGV_INF("tsi_test_operators c32: %b\n", tsi_test_operators<MyConstexprTSI_32, MyConstexprTSI_32_T>()); - PK_LOGV_INF("tsi_test_operators c64: %b\n", tsi_test_operators<MyConstexprTSI_64, MyConstexprTSI_64_T>()); + PK_LOGV_INF("tsi_test_operators 08: %s\n", tsi_test_operators<MyTSI_8, MyTSI_8_T>() ? "true" : "false"); + PK_LOGV_INF("tsi_test_operators 16: %s\n", tsi_test_operators<MyTSI_16, MyTSI_16_T>() ? "true" : "false"); + PK_LOGV_INF("tsi_test_operators 32: %s\n", tsi_test_operators<MyTSI_32, MyTSI_32_T>() ? "true" : "false"); + PK_LOGV_INF("tsi_test_operators 64: %s\n", tsi_test_operators<MyTSI_64, MyTSI_64_T>() ? "true" : "false"); + PK_LOGV_INF("tsi_test_operators c08: %s\n", tsi_test_operators<MyConstexprTSI_8, MyConstexprTSI_8_T>() ? "true" : "false"); + PK_LOGV_INF("tsi_test_operators c16: %s\n", tsi_test_operators<MyConstexprTSI_16, MyConstexprTSI_16_T>() ? "true" : "false"); + PK_LOGV_INF("tsi_test_operators c32: %s\n", tsi_test_operators<MyConstexprTSI_32, MyConstexprTSI_32_T>() ? "true" : "false"); + PK_LOGV_INF("tsi_test_operators c64: %s\n", tsi_test_operators<MyConstexprTSI_64, MyConstexprTSI_64_T>() ? "true" : "false"); constexpr bool b1 = tsi_test_operators_constexpr<MyConstexprTSI_8, MyConstexprTSI_8_T>(); constexpr bool b2 = tsi_test_operators_constexpr<MyConstexprTSI_16, MyConstexprTSI_16_T>(); constexpr bool b3 = tsi_test_operators_constexpr<MyConstexprTSI_32, MyConstexprTSI_32_T>(); constexpr bool b4 = tsi_test_operators_constexpr<MyConstexprTSI_64, MyConstexprTSI_64_T>(); - PK_LOGV_INF("TypeSafeInt_constexpr_08: %b\n", b1); - PK_LOGV_INF("TypeSafeInt_constexpr_16: %b\n", b2); - PK_LOGV_INF("TypeSafeInt_constexpr_32: %b\n", b3); - PK_LOGV_INF("TypeSafeInt_constexpr_64: %b\n", b4); + PK_LOGV_INF("TypeSafeInt_constexpr_08: %s\n", b1 ? "true" : "false"); + PK_LOGV_INF("TypeSafeInt_constexpr_16: %s\n", b2 ? "true" : "false"); + PK_LOGV_INF("TypeSafeInt_constexpr_32: %s\n", b3 ? "true" : "false"); + PK_LOGV_INF("TypeSafeInt_constexpr_64: %s\n", b4 ? "true" : "false"); } return 0; diff --git a/test/pkmem-types.cpp b/test/pkmem-types.cpp index 0dc0f90..34ef102 100644 --- a/test/pkmem-types.cpp +++ b/test/pkmem-types.cpp @@ -18,26 +18,26 @@ int main(int argc, char *argv[]) constexpr struct pk_handle ch1 { .bucketIndex = 0xAAAAAAAA, .itemIndex = 0x55555555 }; constexpr struct pk_handle cbh1 { .bucketIndex = 0xAAAAAAAA, .itemIndex = 0x55555555 }; constexpr bool ret1 = (ch1 == cbh1); - PK_LOGV_INF("pk_handle constexpr operator== 000: %b\n", ret1); + PK_LOGV_INF("pk_handle constexpr operator== 000: %s\n", ret1 ? "true" : "false"); constexpr struct pk_handle ch2 { .bucketIndex = 0x00000000, .itemIndex = 0x00000000 }; constexpr struct pk_handle cbh2 { .bucketIndex = 0xFFFFFFFF, .itemIndex = 0xFFFFFFFF }; constexpr bool ret2 = (ch2 == cbh2); - PK_LOGV_INF("pk_handle constexpr operator== 001: %b\n", ret2); + PK_LOGV_INF("pk_handle constexpr operator== 001: %s\n", ret2 ? "true" : "false"); h.bucketIndex = 0xCAFE; h.itemIndex = 0xBABE; bh.bucketIndex = 0xCAFE; bh.itemIndex = 0xBABE; res = h == bh; - PK_LOGV_INF("pk_handle operator== 000: %b\n", res); + PK_LOGV_INF("pk_handle operator== 000: %s\n", res ? "true" : "false"); h.bucketIndex = 0x00000000; h.itemIndex = 0x00000000; bh.bucketIndex = 0xFFFFFFFF; bh.itemIndex = 0xFFFFFFFF; res = h == bh; - PK_LOGV_INF("pk_handle operator== 001: %b\n", res); + PK_LOGV_INF("pk_handle operator== 001: %s\n", res ? "true" : "false"); } // pk_handle_validate_constexpr @@ -70,26 +70,26 @@ int main(int argc, char *argv[]) struct custom_handle ch1; ch1.bucketIndex = 0xAAAAAAAA; ch1.itemIndex = 0x55555555; struct custom_handle cbh1; cbh1.bucketIndex = 0xAAAAAAAA; cbh1.itemIndex = 0x55555555; bool ret1 = (ch1 == cbh1); - PK_LOGV_INF("custom_handle constexpr operator== 000: %b\n", ret1); + PK_LOGV_INF("custom_handle constexpr operator== 000: %s\n", ret1 ? "true" : "false"); struct custom_handle ch2; ch2.bucketIndex = 0x00000000; ch2.itemIndex = 0x00000000; struct custom_handle cbh2; cbh2.bucketIndex = 0xFFFFFFFF; cbh2.itemIndex = 0xFFFFFFFF; bool ret2 = (ch2 == cbh2); - PK_LOGV_INF("custom_handle constexpr operator== 001: %b\n", ret2); + PK_LOGV_INF("custom_handle constexpr operator== 001: %s\n", ret2 ? "true" : "false"); h.bucketIndex = 0xCAFE; h.itemIndex = 0xBABE; bh.bucketIndex = 0xCAFE; bh.itemIndex = 0xBABE; res = h == bh; - PK_LOGV_INF("custom_handle operator== 000: %b\n", res); + PK_LOGV_INF("custom_handle operator== 000: %s\n", res ? "true" : "false"); h.bucketIndex = 0x00000000; h.itemIndex = 0x00000000; bh.bucketIndex = 0xFFFFFFFF; bh.itemIndex = 0xFFFFFFFF; res = h == bh; - PK_LOGV_INF("custom_handle operator== 001: %b\n", res); + PK_LOGV_INF("custom_handle operator== 001: %s\n", res ? "true" : "false"); } return 0; |
