From 3822aca4e6a8534b673407a6e3b5d9d86bece4c3 Mon Sep 17 00:00:00 2001 From: Olivier Charloton Date: Thu, 6 Aug 2015 00:20:51 +0200 Subject: [PATCH] Resolving #122 "C string DIFFERS not consistent with EQUALS" New specialized templates for the differs test to manage C strings, as done for equals (cf. #82, #83 & #84). --- cxxtest/TestSuite.h | 64 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/cxxtest/TestSuite.h b/cxxtest/TestSuite.h index b34c45d..7a184ec 100644 --- a/cxxtest/TestSuite.h +++ b/cxxtest/TestSuite.h @@ -168,6 +168,70 @@ struct differs } }; +template<> +struct differs +{ + static bool test(const char *x, const char *y) + { + if ((x != 0) && (y != 0)) + { + return (CXXTEST_STD(strcmp(x, y)) != 0); + } + else + { + return (x != y); + } + } +}; + +template<> +struct differs +{ + static bool test(char *x, char *y) + { + if ((x != 0) && (y != 0)) + { + return (CXXTEST_STD(strcmp(x, y)) != 0); + } + else + { + return (x != y); + } + } +}; + +template<> +struct differs +{ + static bool test(const char *x, char *y) + { + if ((x != 0) && (y != 0)) + { + return (CXXTEST_STD(strcmp(x, y)) != 0); + } + else + { + return (x != y); + } + } +}; + +template<> +struct differs +{ + static bool test(char *x, const char *y) + { + if ((x != 0) && (y != 0)) + { + return (CXXTEST_STD(strcmp(x, y)) != 0); + } + else + { + return (x != y); + } + } +}; + template void doAssertDiffers(const char *file, int line, const char *xExpr, X x,