Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions src/jc_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,18 +202,26 @@ struct jc_test_params_class : public jc_test_base_class {
#endif

#if !defined(JC_FMT_U64)
#if defined(__ANDROID__)
#define JC_FMT_U64 "%llu"
#define JC_FMT_I64 "%lld"
#else
#if __cplusplus == 199711L && (defined(__GNUC__) && !defined(__clang__))
// For some reason GCC would always warn about the format not working in c++98 (it does though)
#pragma GCC diagnostic ignored "-Wformat"
#if defined(__has_include)
#if __has_include(<inttypes.h>)
#include <inttypes.h>
#endif
#include <inttypes.h>
#define JC_FMT_U64 "%" PRIu64
#define JC_FMT_I64 "%" PRId64
#endif

#if !defined(PRId64)
#if defined(_MSC_VER)
#define PRId64 "I64d"
#define PRIi64 "I64i"
#define PRIu64 "I64u"
#define PRIx64 "I64x"
#else
#define PRIu64 "llu"
#define PRIx64 "lld"
#endif
#endif

#define JC_FMT_U64 "%" PRIu64
#define JC_FMT_I64 "%" PRId64
#endif

#if defined(__x86_64__) || defined(__arm64) || defined(__aarch64__) || defined(__ppc64__) || defined(_WIN64)
Expand Down Expand Up @@ -1042,7 +1050,7 @@ template <> char* jc_test_print_value(char* buffer, size_t buffer_len, std::null

static int jc_get_formatted_test_name(char* buffer, size_t buffer_len, const jc_test_fixture* fixture, const jc_test_entry* test, int usecolor) {
if (fixture->index != 0xFFFFFFFF)
return JC_TEST_SNPRINTF(buffer, buffer_len, "%s%s%s.%s%s%s/%d", JC_TEST_COL2(CYAN,usecolor), fixture->name, JC_TEST_COL2(DEFAULT,usecolor), JC_TEST_COL2(YELLOW,usecolor), test->name, JC_TEST_COL2(DEFAULT,usecolor), fixture->index);
return JC_TEST_SNPRINTF(buffer, buffer_len, "%s%s%s.%s%s%s/%u", JC_TEST_COL2(CYAN,usecolor), fixture->name, JC_TEST_COL2(DEFAULT,usecolor), JC_TEST_COL2(YELLOW,usecolor), test->name, JC_TEST_COL2(DEFAULT,usecolor), fixture->index);
else
return JC_TEST_SNPRINTF(buffer, buffer_len, "%s%s%s.%s%s%s", JC_TEST_COL2(CYAN,usecolor), fixture->name, JC_TEST_COL2(DEFAULT,usecolor), JC_TEST_COL2(YELLOW,usecolor), test->name, JC_TEST_COL2(DEFAULT,usecolor));
}
Expand Down Expand Up @@ -1206,7 +1214,7 @@ void jc_test_print_logger::OnTestSetup(const jc_test_fixture* fixture, const jc_
str->Appendf("%s%s%s", JC_TEST_COL(YELLOW), test->name, JC_TEST_COL(DEFAULT));

if (fixture->index != 0xFFFFFFFF) {
str->Appendf("/%d ", fixture->index);
str->Appendf("/%u ", fixture->index);
}
str->Append("\n");

Expand All @@ -1219,7 +1227,7 @@ void jc_test_print_logger::OnTestTeardown(const jc_test_fixture* fixture, const

str->Appendf("%s%s%s", JC_TEST_COL(YELLOW), test->name, JC_TEST_COL(DEFAULT));
if (fixture->index != 0xFFFFFFFF) {
str->Appendf("/%d ", fixture->index);
str->Appendf("/%u ", fixture->index);
}
if (test->fail)
str->Appendf(" %s%s%s (", JC_TEST_COL(FAIL), "FAIL", JC_TEST_COL(DEFAULT));
Expand Down Expand Up @@ -2054,6 +2062,7 @@ INSTANTIATE_TEST_CASE_P(EvenValues, MyParamTest, jc_test_values(2,4,6,8,10));
* Made sure to compile with highest warning/error levels possible
*
* HISTORY:
* 0.12 2025-09-24 * Added more robust way to check for PRIu64 etc
* 0.11 2023-10-13 * Added JC_TEST_OUTPUT_FN for customizing log output
* * Added JC_TEST_USE_PRINTF to choose printf() over write()
* 0.10 2023-05-19 * Introduced JC_TEXT_LOGGER_CLASS for easier log printing
Expand Down
Loading