diff options
author | Mattes D <github@xoft.cz> | 2023-05-11 22:05:17 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2023-05-16 23:50:37 +0200 |
commit | c9522fb740200ccef6230cec452c48efb31e5394 (patch) | |
tree | 7e74d70699e13dd0a92444a1a0add7a3059ac7ca /tests/TestHelpers.h | |
parent | Try a timeout for jobs. (diff) | |
download | cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.gz cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.bz2 cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.lz cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.xz cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.zst cuberite-c9522fb740200ccef6230cec452c48efb31e5394.zip |
Diffstat (limited to 'tests/TestHelpers.h')
-rw-r--r-- | tests/TestHelpers.h | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/tests/TestHelpers.h b/tests/TestHelpers.h index cd1a52998..665d4bf52 100644 --- a/tests/TestHelpers.h +++ b/tests/TestHelpers.h @@ -18,6 +18,7 @@ IMPLEMENT_TEST_MAIN("TestName", + /** The exception that is thrown if a test fails. It doesn't inherit from any type so that it is not possible to catch it by a mistake, it needs to be caught explicitly (used in the TEST_THROWS). @@ -50,9 +51,10 @@ public: { \ throw TestException( \ __FILE__, __LINE__, __FUNCTION__, \ - Printf("Equality test failed: %s != %s", #VAL1, #VAL2)); \ + fmt::format(FMT_STRING("Equality test failed: {} != {}"), #VAL1, #VAL2) \ + ); \ } \ - } while (false) + } while (false) @@ -65,7 +67,8 @@ public: { \ throw TestException( \ __FILE__, __LINE__, __FUNCTION__, \ - Printf("Equality test failed: %s != %s (%s)", #VAL1, #VAL2, MSG)); \ + fmt::format(FMT_STRING("Equality test failed: {} != {} ({})"), #VAL1, #VAL2, MSG) \ + ); \ } \ } while (false) @@ -80,10 +83,10 @@ public: { \ throw TestException( \ __FILE__, __LINE__, __FUNCTION__, \ - Printf("Inequality test failed: %s == %s", #VAL1, #VAL2) \ - ); \ + fmt::format(FMT_STRING("Inequality test failed: {} == {}"), #VAL1, #VAL2) \ + ); \ } \ - } while(false) + } while (false) @@ -108,7 +111,7 @@ public: do { \ if (Stmt < Val) \ { \ - throw TestException(__FILE__, __LINE__, __FUNCTION__, Printf("Comparison failed: %s < %s", #Stmt, #Val)); \ + throw TestException(__FILE__, __LINE__, __FUNCTION__, fmt::format(FMT_STRING("Comparison failed: {} < {}"), #Stmt, #Val)); \ } \ } while (false) @@ -121,7 +124,7 @@ public: do { \ if (Stmt > Val) \ { \ - throw TestException(__FILE__, __LINE__, __FUNCTION__, Printf("Comparison failed: %s > %s", #Stmt, #Val)); \ + throw TestException(__FILE__, __LINE__, __FUNCTION__, fmt::format(FMT_STRING("Comparison failed: {} > {}"), #Stmt, #Val)); \ } \ } while (false) @@ -137,8 +140,8 @@ public: Stmt; \ throw TestException( \ __FILE__, __LINE__, __FUNCTION__, \ - Printf("Failed to throw an exception of type %s", #ExcClass) \ - ); \ + fmt::format(FMT_STRING("Failed to throw an exception of type {}"), #ExcClass) \ + ); \ } \ catch (const ExcClass &) \ { \ @@ -148,17 +151,18 @@ public: { \ throw TestException( \ __FILE__, __LINE__, __FUNCTION__, \ - Printf("An unexpected std::exception descendant was thrown, was expecting type %s. Message is: %s", \ + fmt::format( \ + FMT_STRING("An unexpected std::exception descendant was thrown, was expecting type {}. Message is: {}"), \ #ExcClass, exc.what() \ - )); \ + ) \ + ); \ } \ catch (...)\ { \ throw TestException( \ __FILE__, __LINE__, __FUNCTION__, \ - Printf("An unexpected unknown exception object was thrown, was expecting type %s", \ - #ExcClass \ - )); \ + fmt::format(FMT_STRING("An unexpected unknown exception object was thrown, was expecting type {}"), #ExcClass) \ + ); \ } \ } while (false) @@ -174,7 +178,8 @@ public: Stmt; \ throw TestException( \ __FILE__, __LINE__, __FUNCTION__, \ - "Failed to throw an exception of any type"); \ + "Failed to throw an exception of any type" \ + ); \ } \ catch (const TestException & exc) \ { \ |