[niepce] Fix a regression in the propertybag code caused by ed5d51



commit 37f01257c25540187ca127caa50614a1497b4537
Author: Hubert Figuière <hub figuiere net>
Date:   Tue Jun 25 18:29:33 2013 -0400

    Fix a regression in the propertybag code caused by ed5d51

 .gitignore                         |    1 +
 src/fwk/base/Makefile.am           |   10 ++++++-
 src/fwk/base/propertybag.cpp       |    2 +-
 src/fwk/base/t/testpropertybag.cpp |   43 ++++++++++++++++++++++++++++++++++++
 4 files changed, 53 insertions(+), 3 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 13cb90e..e384701 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,6 +38,7 @@ src/fwk/base/testgeometry
 src/fwk/base/testfractions
 src/fwk/base/testdate
 src/fwk/base/testmap
+src/fwk/base/testpropertybag
 src/fwk/utils/test_db
 src/fwk/utils/test_db2
 src/fwk/utils/test_db3
diff --git a/src/fwk/base/Makefile.am b/src/fwk/base/Makefile.am
index 3d40322..0d9ba62 100644
--- a/src/fwk/base/Makefile.am
+++ b/src/fwk/base/Makefile.am
@@ -7,9 +7,11 @@ INCLUDES = -I$(top_srcdir)/src \
 noinst_LIBRARIES = libfwkbase.a
 
 
-TESTS = testmoniker testgeometry testfractions testdate testmap
+TESTS = testmoniker testgeometry testfractions testdate testmap\
+       testpropertybag
 
-check_PROGRAMS = testmoniker testgeometry testfractions testdate testmap
+check_PROGRAMS = testmoniker testgeometry testfractions testdate testmap\
+       testpropertybag
 
 testdate_SOURCES = t/testdate.cpp
 testdate_LDADD = libfwkbase.a \
@@ -31,6 +33,10 @@ testmap_SOURCES = t/testmap.cpp
 testmap_LDADD = libfwkbase.a \
        @LIBGLIBMM_LIBS@
 
+testpropertybag_SOURCES = t/testpropertybag.cpp
+testpropertybag_LDADD = libfwkbase.a \
+       @LIBGLIBMM_LIBS@
+
 libfwkbase_a_SOURCES = colour.hpp colour.cpp \
        autoflag.hpp \
        date.hpp date.cpp \
diff --git a/src/fwk/base/propertybag.cpp b/src/fwk/base/propertybag.cpp
index f9b95ad..29bb8c5 100644
--- a/src/fwk/base/propertybag.cpp
+++ b/src/fwk/base/propertybag.cpp
@@ -30,7 +30,7 @@ bool is_empty(const PropertyValue & v)
 
 bool is_integer(const PropertyValue & v)
 {
-    return v.type() == typeid(EmptyValue);
+    return v.type() == typeid(int);
 }
 
 int get_integer(const PropertyValue & v)
diff --git a/src/fwk/base/t/testpropertybag.cpp b/src/fwk/base/t/testpropertybag.cpp
new file mode 100644
index 0000000..c653c11
--- /dev/null
+++ b/src/fwk/base/t/testpropertybag.cpp
@@ -0,0 +1,43 @@
+/*
+ * niepce - base/t/testpropertybag.cpp
+ *
+ * Copyright (C) 2013 Hubert Figuiere
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+/** @brief unit test for propertybag */
+
+#include <boost/test/minimal.hpp>
+
+#include <stdlib.h>
+#include "fwk/base/propertybag.hpp"
+
+int test_main( int, char *[] )             // note the name!
+{
+       fwk::PropertyValue v;
+
+       BOOST_CHECK(v.type() == typeid(fwk::EmptyValue));
+
+       BOOST_CHECK(is_empty(v));
+       BOOST_CHECK(get_integer(v) == 0);
+
+       v = 42;
+
+       BOOST_CHECK(!is_empty(v));
+       BOOST_CHECK(is_integer(v));
+       BOOST_CHECK(get_integer(v) == 42);
+
+        return 0;
+}
+


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