From 1e8ef99fa7af2e89e4cef5798b2e3282a9e9708d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 11 Jun 2020 19:17:17 -0400 Subject: [PATCH] use compile time tests instead of runtime checks for skipping 64bit tests on 32bit integers --- unittest/utils/test_fmtlib.cpp | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/unittest/utils/test_fmtlib.cpp b/unittest/utils/test_fmtlib.cpp index 6d354cf69f..0b1ec16368 100644 --- a/unittest/utils/test_fmtlib.cpp +++ b/unittest/utils/test_fmtlib.cpp @@ -42,45 +42,63 @@ TEST(FmtLib, insert_neg_int) { } TEST(FmtLib, insert_bigint) { - if (sizeof(bigint) == 4) GTEST_SKIP(); +#if defined(LAMMPS_BIGBIG) || defined(LAMMPS_SMALLBIG) const bigint val = 9945234592L; auto text = fmt::format("word {}",val); ASSERT_THAT(text, Eq("word 9945234592")); +#else + GTEST_SKIP(); +#endif } TEST(FmtLib, insert_neg_bigint) { - if (sizeof(bigint) == 4) GTEST_SKIP(); +#if defined(LAMMPS_BIGBIG) || defined(LAMMPS_SMALLBIG) const bigint val = -9945234592L; auto text = fmt::format("word {}",val); ASSERT_THAT(text, Eq("word -9945234592")); +#else + GTEST_SKIP(); +#endif } TEST(FmtLib, insert_tagint) { - if (sizeof(tagint) == 4) GTEST_SKIP(); +#if defined(LAMMPS_BIGBIG) const tagint val = 9945234592L; auto text = fmt::format("word {}",val); ASSERT_THAT(text, Eq("word 9945234592")); +#else + GTEST_SKIP(); +#endif } TEST(FmtLib, insert_neg_tagint) { - if (sizeof(tagint) == 4) GTEST_SKIP(); +#if defined(LAMMPS_BIGBIG) const tagint val = -9945234592L; auto text = fmt::format("word {}",val); ASSERT_THAT(text, Eq("word -9945234592")); +#else + GTEST_SKIP(); +#endif } TEST(FmtLib, insert_imageint) { - if (sizeof(imageint) == 4) GTEST_SKIP(); +#if defined(LAMMPS_BIGBIG) const imageint val = 9945234592L; auto text = fmt::format("word {}",val); ASSERT_THAT(text, Eq("word 9945234592")); +#else + GTEST_SKIP(); +#endif } TEST(FmtLib, insert_neg_imageint) { - if (sizeof(imageint) == 4) GTEST_SKIP(); +#if defined(LAMMPS_BIGBIG) const imageint val = -9945234592L; auto text = fmt::format("word {}",val); ASSERT_THAT(text, Eq("word -9945234592")); +#else + GTEST_SKIP(); +#endif } TEST(FmtLib, insert_double) {