lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] (no subject)


From: Greg Chicares
Subject: [lmi-commits] (no subject)
Date: Fri, 3 Jun 2016 16:06:33 +0000 (UTC)

branch: master
commit 219000db269c288414499e5272ee981c7ecac40b
Author: Gregory W. Chicares <address@hidden>
Date:   Fri Jun 3 15:09:15 2016 +0000

    Add a unit test for class ce_product_name [446]
    
    It was not obvious that ce_product_name::read() can throw.
    
    Class ce_skin_name is pretty much a clone of ce_product_name, so it
    doesn't seem to need unit tests.
---
 ce_product_name.cpp |    5 +++++
 ce_product_name.hpp |    2 --
 ce_skin_name.cpp    |    5 +++++
 mc_enum_test.cpp    |   15 +++++++++++++++
 objects.make        |    1 +
 5 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/ce_product_name.cpp b/ce_product_name.cpp
index 1f7b973..f621920 100644
--- a/ce_product_name.cpp
+++ b/ce_product_name.cpp
@@ -177,6 +177,11 @@ std::string ce_product_name::value() const
     return value_;
 }
 
+/// DWISOTT.
+///
+/// Calls operator=(std::string const&), which throws if the value
+/// read from the stream is invalid.
+
 std::istream& ce_product_name::read(std::istream& is)
 {
     std::locale old_locale = is.imbue(blank_is_not_whitespace_locale());
diff --git a/ce_product_name.hpp b/ce_product_name.hpp
index 80fc0ed..686e597 100644
--- a/ce_product_name.hpp
+++ b/ce_product_name.hpp
@@ -59,8 +59,6 @@
 /// program might write the 'sample' product's files if it finds no
 /// other product.
 ///
-/// TODO ?? Add unit tests.
-///
 /// TODO ?? Can't read() and write() be moved to the base class?
 
 class ce_product_name
diff --git a/ce_skin_name.cpp b/ce_skin_name.cpp
index d0e0d53..b7f6417 100644
--- a/ce_skin_name.cpp
+++ b/ce_skin_name.cpp
@@ -166,6 +166,11 @@ std::string ce_skin_name::value() const
     return value_;
 }
 
+/// DWISOTT.
+///
+/// Calls operator=(std::string const&), which throws if the value
+/// read from the stream is invalid.
+
 std::istream& ce_skin_name::read(std::istream& is)
 {
     std::locale old_locale = is.imbue(blank_is_not_whitespace_locale());
diff --git a/mc_enum_test.cpp b/mc_enum_test.cpp
index a46832e..73ca30d 100644
--- a/mc_enum_test.cpp
+++ b/mc_enum_test.cpp
@@ -24,6 +24,7 @@
 #   pragma hdrstop
 #endif // __BORLANDC__
 
+#include "ce_product_name.hpp"
 #include "mc_enum.hpp"
 #include "mc_enum_test_aux.hpp"
 
@@ -38,11 +39,13 @@
 struct mc_enum_test
 {
     static void test();
+    static void test_product_name();
 };
 
 int test_main(int, char*[])
 {
     mc_enum_test::test();
+    mc_enum_test::test_product_name();
     return 0;
 }
 
@@ -225,3 +228,15 @@ void mc_enum_test::test()
         );
 }
 
+void mc_enum_test::test_product_name()
+{
+    std::stringstream ss;
+    ss.str("invalid product");
+    ce_product_name x;
+    BOOST_TEST_THROW
+        (ss >> x
+        ,std::runtime_error
+        ,"Value 'invalid product' invalid for type 'ce_product_name'."
+        );
+}
+
diff --git a/objects.make b/objects.make
index bfb98a7..7b26bf1 100644
--- a/objects.make
+++ b/objects.make
@@ -707,6 +707,7 @@ mc_enum_test$(EXEEXT): \
   $(boost_filesystem_objects) \
   $(common_test_objects) \
   calendar_date.o \
+  ce_product_name.o \
   datum_base.o \
   facets.o \
   global_settings.o \



reply via email to

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