lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [6076] Refactor


From: Greg Chicares
Subject: [lmi-commits] [6076] Refactor
Date: Mon, 15 Dec 2014 14:00:25 +0000

Revision: 6076
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=6076
Author:   chicares
Date:     2014-12-15 14:00:24 +0000 (Mon, 15 Dec 2014)
Log Message:
-----------
Refactor

Modified Paths:
--------------
    lmi/trunk/ChangeLog
    lmi/trunk/wx_test_expiry_dates.cpp

Added Paths:
-----------
    lmi/trunk/wx_test_date.hpp

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2014-12-15 13:53:46 UTC (rev 6075)
+++ lmi/trunk/ChangeLog 2014-12-15 14:00:24 UTC (rev 6076)
@@ -34906,3 +34906,10 @@
 Run only with '--distribution' flag. See:
   http://lists.nongnu.org/archive/html/lmi/2014-12/msg00074.html
 
+20141215T1400Z <address@hidden> [516]
+
+  wx_test_date.hpp [new file]
+  wx_test_expiry_dates.cpp
+Refactor. See:
+  http://lists.nongnu.org/archive/html/lmi/2014-12/msg00075.html
+

Added: lmi/trunk/wx_test_date.hpp
===================================================================
--- lmi/trunk/wx_test_date.hpp                          (rev 0)
+++ lmi/trunk/wx_test_date.hpp  2014-12-15 14:00:24 UTC (rev 6076)
@@ -0,0 +1,74 @@
+// Helpers for working with dates in wx test suite code.
+//
+// Copyright (C) 2014 Gregory W. Chicares.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+//
+// http://savannah.nongnu.org/projects/lmi
+// email: <address@hidden>
+// snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
+
+// $Id$
+
+#ifndef wx_test_date_hpp
+#define wx_test_date_hpp
+
+#include "config.hpp"
+
+#include "calendar_date.hpp"
+
+#include <sstream>
+
+// Return a string containing both the JDN and a string representation of the
+// given date.
+//
+// This provides as much information as possible for the diagnostics.
+inline
+std::string dump_date(calendar_date const& date)
+{
+    std::ostringstream oss;
+    oss << date << " (" << date.str() << ")";
+    return oss.str();
+}
+
+// Return the date corresponding to the first day of the month following the
+// month of the given date.
+inline
+calendar_date get_first_next_month(calendar_date const& date)
+{
+    int year = date.year();
+    int month = date.month();
+    if(month == 12)
+        {
+        month = 1;
+        year++;
+        }
+    else
+        {
+        month++;
+        }
+
+    return calendar_date(year, month, 1);
+}
+
+// A variant of LMI_ASSERT_EQUAL which provides more information about dates in
+// case of assertion failure.
+#define LMI_ASSERT_DATES_EQUAL(observed,expected)                   \
+    LMI_ASSERT_WITH_MSG                                             \
+        ((observed) == (expected)                                   \
+        ,"expected " << (dump_date(expected))                       \
+            << " vs observed " << (dump_date(observed))             \
+        )
+
+#endif // wx_test_date_hpp


Property changes on: lmi/trunk/wx_test_date.hpp
___________________________________________________________________
Added: svn:keywords
   + Id

Modified: lmi/trunk/wx_test_expiry_dates.cpp
===================================================================
--- lmi/trunk/wx_test_expiry_dates.cpp  2014-12-15 13:53:46 UTC (rev 6075)
+++ lmi/trunk/wx_test_expiry_dates.cpp  2014-12-15 14:00:24 UTC (rev 6076)
@@ -30,6 +30,7 @@
 #include "calendar_date.hpp"
 #include "global_settings.hpp"
 #include "wx_test_case.hpp"
+#include "wx_test_date.hpp"
 #include "version.hpp"
 
 #include <wx/log.h>
@@ -37,52 +38,6 @@
 #include <boost/filesystem/fstream.hpp>
 #include <boost/filesystem/operations.hpp>
 
-#include <sstream>
-
-namespace
-{
-
-// Return a string containing both the JDN and a string representation of the
-// given date.
-//
-// This provides as much information as possible for the diagnostics.
-std::string dump_date(calendar_date const& date)
-{
-    std::ostringstream oss;
-    oss << date << " (" << date.str() << ")";
-    return oss.str();
-}
-
-// Return the date corresponding to the first day of the month following the
-// month of the given date.
-calendar_date get_first_next_month(calendar_date const& date)
-{
-    int year = date.year();
-    int month = date.month();
-    if(month == 12)
-        {
-        month = 1;
-        year++;
-        }
-    else
-        {
-        month++;
-        }
-
-    return calendar_date(year, month, 1);
-}
-
-} // Unnamed namespace.
-
-// A variant of LMI_ASSERT_EQUAL which provides more information about dates in
-// case of assertion failure.
-#define LMI_ASSERT_DATES_EQUAL(observed,expected)                   \
-    LMI_ASSERT_WITH_MSG                                             \
-        ((observed) == (expected)                                   \
-        ,"expected " << (dump_date(expected))                       \
-            << " vs observed " << (dump_date(observed))             \
-        )
-
 /// Validate dates in the 'expiry' file.
 ///
 /// Write the begin and end dates to stdout, as JDN and as YYYYMMDD,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]