File 0001-Test-construction-of-DateTime-from-time_t.patch of Package wxWidgets-3_2

From ba62d3eeb4bd5c7f6ad5912f30e741b96a13ab80 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Tue, 28 Jun 2022 19:29:37 +0200
Subject: [PATCH] Test construction of DateTime from time_t

---
 tests/datetime/datetimetest.cpp | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tests/datetime/datetimetest.cpp b/tests/datetime/datetimetest.cpp
index 064575bfb7..27d90707d9 100644
--- a/tests/datetime/datetimetest.cpp
+++ b/tests/datetime/datetimetest.cpp
@@ -214,6 +214,7 @@ private:
     CPPUNIT_TEST_SUITE( DateTimeTestCase );
         CPPUNIT_TEST( TestLeapYears );
         CPPUNIT_TEST( TestTimeSet );
+        CPPUNIT_TEST( TestTimeTimeT );
         CPPUNIT_TEST( TestTimeJDN );
         CPPUNIT_TEST( TestTimeWNumber );
         CPPUNIT_TEST( TestTimeWDays );
@@ -237,6 +238,7 @@ private:
 
     void TestLeapYears();
     void TestTimeSet();
+    void TestTimeTimeT();
     void TestTimeJDN();
     void TestTimeWNumber();
     void TestTimeWDays();
@@ -309,6 +311,25 @@ void DateTimeTestCase::TestTimeSet()
     }
 }
 
+// test constructing wxDateTime from time_t
+void DateTimeTestCase::TestTimeTimeT()
+{
+    for ( size_t n = 0; n < WXSIZEOF(testDates); n++ )
+    {
+        const Date& d1 = testDates[n];
+        if ( d1.gmticks == -1 )
+            continue;
+
+        const wxDateTime tt{time_t{d1.gmticks}};
+
+        Date d2;
+        d2.Init(tt.GetTm());
+
+        INFO("n=" << n);
+        CHECK( d1.Format() == d2.Format() );
+    }
+}
+
 // test conversions to JDN &c
 void DateTimeTestCase::TestTimeJDN()
 {
-- 
2.36.1

openSUSE Build Service is sponsored by