Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Introduce support for DJGPP cross compiler

DJGPP cross compiler is targeting DOS which does not support POSIX
signals. Probably for the same reason (targeting DOS) this compiler
does not support wide characters.
Commit
95c849f613a79cb3c7f59aa0589304513688aba1
Author
Tomas Zeman ·
Committer
Martin Hořeňovský
Parents
352853ed7e25

Files · Download .tar.gz

Changes

 include/internal/catch_compiler_capabilities.h     |  9 ++++++-
 include/internal/catch_console_colour.cpp          |  7 ++++-
 .../SelfTest/Baselines/compact.sw.approved.txt     | 12 ++++-----
 .../SelfTest/Baselines/console.sw.approved.txt     | 12 ++++-----
 projects/SelfTest/Baselines/xml.sw.approved.txt    | 12 ++++-----
 projects/SelfTest/UsageTests/Matchers.tests.cpp    | 30 +++++++++++++++++-----
 6 files changed, 56 insertions(+), 26 deletions(-)

diff --git a/include/internal/catch_compiler_capabilities.h b/include/internal/catch_compiler_capabilities.h
index b1acf99d..2bbba4f0 100644
--- a/include/internal/catch_compiler_capabilities.h
+++ b/include/internal/catch_compiler_capabilities.h
@@ -67,7 +67,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 // We know some environments not to support full POSIX signals
-#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__)
+#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__)
 
 #   if !defined(CATCH_CONFIG_POSIX_SIGNALS)
 #       define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
@@ -111,6 +111,13 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 
+// DJGPP
+#ifdef __DJGPP__
+#  define CATCH_INTERNAL_CONFIG_NO_WCHAR
+#endif // __DJGPP__
+
+////////////////////////////////////////////////////////////////////////////////
+
 // Use of __COUNTER__ is suppressed during code analysis in
 // CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly
 // handled by it.
diff --git a/include/internal/catch_console_colour.cpp b/include/internal/catch_console_colour.cpp
index f692b5c5..5fb1d07f 100644
--- a/include/internal/catch_console_colour.cpp
+++ b/include/internal/catch_console_colour.cpp
@@ -169,7 +169,12 @@ namespace {
 #ifdef CATCH_PLATFORM_MAC
             !isDebuggerActive() &&
 #endif
-            isatty(STDOUT_FILENO);
+#if !(defined(__DJGPP__) && defined(__STRICT_ANSI__))
+            isatty(STDOUT_FILENO)
+#else
+            false
+#endif
+            ;
     }
     IColourImpl* platformColourInstance() {
         ErrnoGuard guard;
diff --git a/projects/SelfTest/Baselines/compact.sw.approved.txt b/projects/SelfTest/Baselines/compact.sw.approved.txt
index a4f85a68..4a1aeb78 100644
--- a/projects/SelfTest/Baselines/compact.sw.approved.txt
+++ b/projects/SelfTest/Baselines/compact.sw.approved.txt
@@ -236,9 +236,9 @@ Matchers.tests.cpp:<line number>: passed: 0., !WithinAbs(1., 0.99) for: 0.0 not
 Matchers.tests.cpp:<line number>: passed: 0., !WithinAbs(1., 0.99) for: 0.0 not is within 0.99 of 1.0
 Matchers.tests.cpp:<line number>: passed: NAN, !WithinAbs(NAN, 0) for: nanf not is within 0.0 of nan
 Matchers.tests.cpp:<line number>: passed: 1., WithinULP(1., 0) for: 1.0 is within 0 ULPs of 1.0
-Matchers.tests.cpp:<line number>: passed: std::nextafter(1., 2.), WithinULP(1., 1) for: 1.0 is within 1 ULPs of 1.0
-Matchers.tests.cpp:<line number>: passed: std::nextafter(1., 0.), WithinULP(1., 1) for: 1.0 is within 1 ULPs of 1.0
-Matchers.tests.cpp:<line number>: passed: std::nextafter(1., 2.), !WithinULP(1., 0) for: 1.0 not is within 0 ULPs of 1.0
+Matchers.tests.cpp:<line number>: passed: nextafter(1., 2.), WithinULP(1., 1) for: 1.0 is within 1 ULPs of 1.0
+Matchers.tests.cpp:<line number>: passed: nextafter(1., 0.), WithinULP(1., 1) for: 1.0 is within 1 ULPs of 1.0
+Matchers.tests.cpp:<line number>: passed: nextafter(1., 2.), !WithinULP(1., 0) for: 1.0 not is within 0 ULPs of 1.0
 Matchers.tests.cpp:<line number>: passed: 1., WithinULP(1., 0) for: 1.0 is within 0 ULPs of 1.0
 Matchers.tests.cpp:<line number>: passed: -0., WithinULP(0., 0) for: -0.0 is within 0 ULPs of 0.0
 Matchers.tests.cpp:<line number>: passed: NAN, !WithinULP(NAN, 123) for: nanf not is within 123 ULPs of nanf
@@ -256,9 +256,9 @@ Matchers.tests.cpp:<line number>: passed: 0.f, !WithinAbs(1.f, 0.99f) for: 0.0f
 Matchers.tests.cpp:<line number>: passed: 0.f, WithinAbs(-0.f, 0) for: 0.0f is within 0.0 of -0.0
 Matchers.tests.cpp:<line number>: passed: NAN, !WithinAbs(NAN, 0) for: nanf not is within 0.0 of nan
 Matchers.tests.cpp:<line number>: passed: 1.f, WithinULP(1.f, 0) for: 1.0f is within 0 ULPs of 1.0f
-Matchers.tests.cpp:<line number>: passed: std::nextafter(1.f, 2.f), WithinULP(1.f, 1) for: 1.0f is within 1 ULPs of 1.0f
-Matchers.tests.cpp:<line number>: passed: std::nextafter(1.f, 0.f), WithinULP(1.f, 1) for: 1.0f is within 1 ULPs of 1.0f
-Matchers.tests.cpp:<line number>: passed: std::nextafter(1.f, 2.f), !WithinULP(1.f, 0) for: 1.0f not is within 0 ULPs of 1.0f
+Matchers.tests.cpp:<line number>: passed: nextafter(1.f, 2.f), WithinULP(1.f, 1) for: 1.0f is within 1 ULPs of 1.0f
+Matchers.tests.cpp:<line number>: passed: nextafter(1.f, 0.f), WithinULP(1.f, 1) for: 1.0f is within 1 ULPs of 1.0f
+Matchers.tests.cpp:<line number>: passed: nextafter(1.f, 2.f), !WithinULP(1.f, 0) for: 1.0f not is within 0 ULPs of 1.0f
 Matchers.tests.cpp:<line number>: passed: 1.f, WithinULP(1.f, 0) for: 1.0f is within 0 ULPs of 1.0f
 Matchers.tests.cpp:<line number>: passed: -0.f, WithinULP(0.f, 0) for: -0.0f is within 0 ULPs of 0.0f
 Matchers.tests.cpp:<line number>: passed: NAN, !WithinULP(NAN, 123) for: nanf not is within 123 ULPs of nanf
diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt
index 9c738463..70bff4a8 100644
--- a/projects/SelfTest/Baselines/console.sw.approved.txt
+++ b/projects/SelfTest/Baselines/console.sw.approved.txt
@@ -1873,19 +1873,19 @@ with expansion:
 
 Matchers.tests.cpp:<line number>:
 PASSED:
-  REQUIRE_THAT( std::nextafter(1., 2.), WithinULP(1., 1) )
+  REQUIRE_THAT( nextafter(1., 2.), WithinULP(1., 1) )
 with expansion:
   1.0 is within 1 ULPs of 1.0
 
 Matchers.tests.cpp:<line number>:
 PASSED:
-  REQUIRE_THAT( std::nextafter(1., 0.), WithinULP(1., 1) )
+  REQUIRE_THAT( nextafter(1., 0.), WithinULP(1., 1) )
 with expansion:
   1.0 is within 1 ULPs of 1.0
 
 Matchers.tests.cpp:<line number>:
 PASSED:
-  REQUIRE_THAT( std::nextafter(1., 2.), !WithinULP(1., 0) )
+  REQUIRE_THAT( nextafter(1., 2.), !WithinULP(1., 0) )
 with expansion:
   1.0 not is within 0 ULPs of 1.0
 
@@ -2013,19 +2013,19 @@ with expansion:
 
 Matchers.tests.cpp:<line number>:
 PASSED:
-  REQUIRE_THAT( std::nextafter(1.f, 2.f), WithinULP(1.f, 1) )
+  REQUIRE_THAT( nextafter(1.f, 2.f), WithinULP(1.f, 1) )
 with expansion:
   1.0f is within 1 ULPs of 1.0f
 
 Matchers.tests.cpp:<line number>:
 PASSED:
-  REQUIRE_THAT( std::nextafter(1.f, 0.f), WithinULP(1.f, 1) )
+  REQUIRE_THAT( nextafter(1.f, 0.f), WithinULP(1.f, 1) )
 with expansion:
   1.0f is within 1 ULPs of 1.0f
 
 Matchers.tests.cpp:<line number>:
 PASSED:
-  REQUIRE_THAT( std::nextafter(1.f, 2.f), !WithinULP(1.f, 0) )
+  REQUIRE_THAT( nextafter(1.f, 2.f), !WithinULP(1.f, 0) )
 with expansion:
   1.0f not is within 0 ULPs of 1.0f
 
diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt
index 70868b59..227dee93 100644
--- a/projects/SelfTest/Baselines/xml.sw.approved.txt
+++ b/projects/SelfTest/Baselines/xml.sw.approved.txt
@@ -2121,7 +2121,7 @@
         </Expression>
         <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
           <Original>
-            std::nextafter(1., 2.), WithinULP(1., 1)
+            nextafter(1., 2.), WithinULP(1., 1)
           </Original>
           <Expanded>
             1.0 is within 1 ULPs of 1.0
@@ -2129,7 +2129,7 @@
         </Expression>
         <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
           <Original>
-            std::nextafter(1., 0.), WithinULP(1., 1)
+            nextafter(1., 0.), WithinULP(1., 1)
           </Original>
           <Expanded>
             1.0 is within 1 ULPs of 1.0
@@ -2137,7 +2137,7 @@
         </Expression>
         <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
           <Original>
-            std::nextafter(1., 2.), !WithinULP(1., 0)
+            nextafter(1., 2.), !WithinULP(1., 0)
           </Original>
           <Expanded>
             1.0 not is within 0 ULPs of 1.0
@@ -2296,7 +2296,7 @@
         </Expression>
         <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
           <Original>
-            std::nextafter(1.f, 2.f), WithinULP(1.f, 1)
+            nextafter(1.f, 2.f), WithinULP(1.f, 1)
           </Original>
           <Expanded>
             1.0f is within 1 ULPs of 1.0f
@@ -2304,7 +2304,7 @@
         </Expression>
         <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
           <Original>
-            std::nextafter(1.f, 0.f), WithinULP(1.f, 1)
+            nextafter(1.f, 0.f), WithinULP(1.f, 1)
           </Original>
           <Expanded>
             1.0f is within 1 ULPs of 1.0f
@@ -2312,7 +2312,7 @@
         </Expression>
         <Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
           <Original>
-            std::nextafter(1.f, 2.f), !WithinULP(1.f, 0)
+            nextafter(1.f, 2.f), !WithinULP(1.f, 0)
           </Original>
           <Expanded>
             1.0f not is within 0 ULPs of 1.0f
diff --git a/projects/SelfTest/UsageTests/Matchers.tests.cpp b/projects/SelfTest/UsageTests/Matchers.tests.cpp
index 3c20caa1..05056b43 100644
--- a/projects/SelfTest/UsageTests/Matchers.tests.cpp
+++ b/projects/SelfTest/UsageTests/Matchers.tests.cpp
@@ -77,6 +77,20 @@ namespace { namespace MatchersTests {
 
     using namespace Catch::Matchers;
 
+#ifdef __DJGPP__
+    float nextafter(float from, float to)
+    {
+        return ::nextafterf(from, to);
+    }
+
+    double nextafter(double from, double to)
+    {
+        return ::nextafter(from, to);
+    }
+#else
+    using std::nextafter;
+#endif
+
     TEST_CASE("String matchers", "[matchers]") {
         REQUIRE_THAT(testStringForMatching(), Contains("string"));
         REQUIRE_THAT(testStringForMatching(), Contains("string", Catch::CaseSensitive::No));
@@ -130,12 +144,16 @@ namespace { namespace MatchersTests {
              (defined(_GLIBCXX_RELEASE) && \
              _GLIBCXX_RELEASE > 4))))
 
+// DJGPP meets the above condition but <regex> does not work properly anyway
+#ifndef __DJGPP__
             REQUIRE_THAT(testStringForMatching(), Matches("this string contains 'abc' as a substring"));
             REQUIRE_THAT(testStringForMatching(),
                          Matches("this string CONTAINS 'abc' as a substring", Catch::CaseSensitive::No));
             REQUIRE_THAT(testStringForMatching(), Matches("^this string contains 'abc' as a substring$"));
             REQUIRE_THAT(testStringForMatching(), Matches("^.* 'abc' .*$"));
             REQUIRE_THAT(testStringForMatching(), Matches("^.* 'ABC' .*$", Catch::CaseSensitive::No));
+#endif
+
 #endif
 
             REQUIRE_THAT(testStringForMatching2(), !Matches("this string contains 'abc' as a substring"));
@@ -307,9 +325,9 @@ namespace { namespace MatchersTests {
             SECTION("ULPs") {
                 REQUIRE_THAT(1.f, WithinULP(1.f, 0));
 
-                REQUIRE_THAT(std::nextafter(1.f, 2.f), WithinULP(1.f, 1));
-                REQUIRE_THAT(std::nextafter(1.f, 0.f), WithinULP(1.f, 1));
-                REQUIRE_THAT(std::nextafter(1.f, 2.f), !WithinULP(1.f, 0));
+                REQUIRE_THAT(nextafter(1.f, 2.f), WithinULP(1.f, 1));
+                REQUIRE_THAT(nextafter(1.f, 0.f), WithinULP(1.f, 1));
+                REQUIRE_THAT(nextafter(1.f, 2.f), !WithinULP(1.f, 0));
 
                 REQUIRE_THAT(1.f, WithinULP(1.f, 0));
                 REQUIRE_THAT(-0.f, WithinULP(0.f, 0));
@@ -344,9 +362,9 @@ namespace { namespace MatchersTests {
             SECTION("ULPs") {
                 REQUIRE_THAT(1., WithinULP(1., 0));
 
-                REQUIRE_THAT(std::nextafter(1., 2.), WithinULP(1., 1));
-                REQUIRE_THAT(std::nextafter(1., 0.), WithinULP(1., 1));
-                REQUIRE_THAT(std::nextafter(1., 2.), !WithinULP(1., 0));
+                REQUIRE_THAT(nextafter(1., 2.), WithinULP(1., 1));
+                REQUIRE_THAT(nextafter(1., 0.), WithinULP(1., 1));
+                REQUIRE_THAT(nextafter(1., 2.), !WithinULP(1., 0));
 
                 REQUIRE_THAT(1., WithinULP(1., 0));
                 REQUIRE_THAT(-0., WithinULP(0., 0));