[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [4818] Move 'e_island' out of the unit-test TU
From: |
Greg Chicares |
Subject: |
[lmi-commits] [4818] Move 'e_island' out of the unit-test TU |
Date: |
Fri, 26 Mar 2010 22:47:26 +0000 |
Revision: 4818
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=4818
Author: chicares
Date: 2010-03-26 22:47:25 +0000 (Fri, 26 Mar 2010)
Log Message:
-----------
Move 'e_island' out of the unit-test TU
Modified Paths:
--------------
lmi/trunk/ChangeLog
lmi/trunk/mc_enum_test.cpp
lmi/trunk/mc_enum_test_aux.cpp
lmi/trunk/mc_enum_test_aux.hpp
lmi/trunk/mc_enum_test_aux_enums.hpp
Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2010-03-26 12:58:51 UTC (rev 4817)
+++ lmi/trunk/ChangeLog 2010-03-26 22:47:25 UTC (rev 4818)
@@ -24645,13 +24645,28 @@
http://lists.nongnu.org/archive/html/lmi/2010-03/msg00060.html
http://lists.nongnu.org/archive/html/lmi/2010-03/msg00067.html
+20100325T2028Z <zeitlin> [761]
+
+ Makefile.am
+Fix autotools linking problems for various unit tests.
+
20100326T1257Z <address@hidden> [762]
ihs_avmly.cpp
Subtract gross withdrawal from 7702 'premiums paid'.
-20100326T1258Z <address@hidden> [761]
+20100326T1258Z <address@hidden> [762]
version.hpp
Mark release candidate.
+20100326T2247Z <address@hidden> [762]
+
+ mc_enum_test.cpp
+ mc_enum_test_aux.cpp
+ mc_enum_test_aux.hpp
+ mc_enum_test_aux_enums.hpp
+Move 'e_island' out of the unit-test TU. Instantiating such types in
+the TU that uses them is valid, but is deliberately avoided everywhere
+else and need not be demonstrated by unit tests.
+
Modified: lmi/trunk/mc_enum_test.cpp
===================================================================
--- lmi/trunk/mc_enum_test.cpp 2010-03-26 12:58:51 UTC (rev 4817)
+++ lmi/trunk/mc_enum_test.cpp 2010-03-26 22:47:25 UTC (rev 4818)
@@ -27,7 +27,6 @@
#endif // __BORLANDC__
#include "mc_enum.hpp"
-#include "mc_enum.tpp"
#include "mc_enum_test_aux.hpp"
#include "test_tools.hpp"
@@ -35,20 +34,9 @@
#include <sstream>
#include <stdexcept>
-// Ni'ihau is deliberately (mis)spelled with an underbar instead of an
-// apostrophe, in order to test provide_for_backward_compatibility().
+// Enumerative types 'e_holiday' and 'e_island' are explicitly
+// instantiated in a different translation unit.
-enum enum_island {i_Easter = 37, i_Pago_Pago = -17, i_Ni_ihau = 13};
-extern enum_island const island_enums[] = {i_Easter, i_Pago_Pago, i_Ni_ihau};
-extern char const*const island_strings[] = {"Easter", "Pago Pago", "Ni_ihau"};
-template<> struct mc_enum_key<enum_island>
- :public mc_enum_data<enum_island, 3, island_enums, island_strings> {};
-template class mc_enum<enum_island>;
-typedef mc_enum<enum_island> e_island;
-
-// Enumerative type 'e_holiday' is explicitly instantiated in a
-// different translation unit.
-
struct mc_enum_test
{
static void test();
@@ -196,8 +184,8 @@
ss >> holiday5;
BOOST_TEST_EQUAL(Pentecost, holiday5);
- // Test an enum class defined in this translation unit that has a
- // std::string name that matches one in a different class.
+ // Test an enumerative class that has a std::string name that
+ // matches one in a different enumerative class.
e_island island0;
BOOST_TEST_EQUAL("Easter", island0);
BOOST_TEST_EQUAL(i_Easter, island0);
Modified: lmi/trunk/mc_enum_test_aux.cpp
===================================================================
--- lmi/trunk/mc_enum_test_aux.cpp 2010-03-26 12:58:51 UTC (rev 4817)
+++ lmi/trunk/mc_enum_test_aux.cpp 2010-03-26 22:47:25 UTC (rev 4818)
@@ -30,23 +30,22 @@
#include "mc_enum.tpp"
#include "mc_enum_test_aux_enums.hpp" // Plain enums.
-// Normally, one would prefer to instantiate all mc_enum templates
-// in a single file. Here, however, the point is to instantiate one
-// such template in a different translation unit than the unit-test
-// driver, in order to prove that explicit instantiation works.
+// The mc_enum types used for unit testing are explicitly instantiated
+// here, and not in the unit-test driver. This deliberately follows
+// the recommended practice used throughout lmi, and is necessary for
+// proving that explicit instantiation works as intended.
-extern enum_holiday const holiday_enums[] =
- {h_Theophany
- ,h_Easter
- ,h_Pentecost
- };
-extern char const*const holiday_strings[] =
- {"Theophany"
- ,"Easter"
- ,"Pentecost"
- };
+extern enum_holiday const holiday_enums[] = {h_Theophany, h_Easter,
h_Pentecost};
+extern char const*const holiday_strings[] = {"Theophany", "Easter",
"Pentecost"};
template class mc_enum<enum_holiday>;
+// Ni'ihau is deliberately (mis)spelled with an underbar instead of an
+// apostrophe, in order to test provide_for_backward_compatibility().
+
+extern enum_island const island_enums[] = {i_Easter, i_Pago_Pago, i_Ni_ihau};
+extern char const*const island_strings[] = {"Easter", "Pago Pago", "Ni_ihau"};
+template class mc_enum<enum_island>;
+
// Explicit instantiation of class mc_enum above does not require a
// definition of mc_enum_key<T>, which does not appear in the class
// definition. However, because mc_enum_key<T> is used in the bodies
Modified: lmi/trunk/mc_enum_test_aux.hpp
===================================================================
--- lmi/trunk/mc_enum_test_aux.hpp 2010-03-26 12:58:51 UTC (rev 4817)
+++ lmi/trunk/mc_enum_test_aux.hpp 2010-03-26 22:47:25 UTC (rev 4818)
@@ -36,5 +36,11 @@
:public mc_enum_data<enum_holiday, 3, holiday_enums, holiday_strings> {};
typedef mc_enum<enum_holiday> e_holiday;
+extern enum_island const island_enums[3];
+extern char const*const island_strings[3];
+template<> struct mc_enum_key<enum_island>
+ :public mc_enum_data<enum_island, 3, island_enums, island_strings> {};
+typedef mc_enum<enum_island> e_island;
+
#endif // mc_enum_test_aux_hpp
Modified: lmi/trunk/mc_enum_test_aux_enums.hpp
===================================================================
--- lmi/trunk/mc_enum_test_aux_enums.hpp 2010-03-26 12:58:51 UTC (rev
4817)
+++ lmi/trunk/mc_enum_test_aux_enums.hpp 2010-03-26 22:47:25 UTC (rev
4818)
@@ -31,6 +31,11 @@
,h_Easter = 20040411
,h_Pentecost = 20040530
};
+enum enum_island
+ {i_Easter = 37
+ ,i_Pago_Pago = -17
+ ,i_Ni_ihau = 13
+ };
#endif // mc_enum_test_aux_enums_hpp
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [4818] Move 'e_island' out of the unit-test TU,
Greg Chicares <=