Permalink
Browse files

add test for maybe<> and json serialization

  • Loading branch information...
1 parent 7e5bc28 commit 6886f043256e55e5bd7299a2ac7d1dbc49a75992 Chip Salzenberg committed Apr 24, 2012
Showing with 15 additions and 0 deletions.
  1. +15 −0 tests/test_json.cc
View
@@ -2,6 +2,7 @@
#include <boost/test/unit_test.hpp>
#include <ten/json.hh>
#include <ten/jserial.hh>
+#include <ten/jserial_maybe.hh>
#include <ten/jserial_seq.hh>
#include <ten/jserial_assoc.hh>
@@ -234,4 +235,18 @@ BOOST_AUTO_TEST_CASE(json_serial) {
BOOST_CHECK_EQUAL(f["foo"], 42);
BOOST_CHECK_EQUAL(f["bar"], 17);
#endif
+
+ maybe<int> a;
+ j = jsave_all(a);
+ BOOST_CHECK(!j);
+ a = 42;
+ j = jsave_all(a);
+ BOOST_CHECK_EQUAL(j, 42);
+
+ a.reset();
+ BOOST_CHECK(!a.ok());
+ j = 17;
+ JLoad(j) >> a;
+ BOOST_CHECK(a.ok());
+ BOOST_CHECK_EQUAL(a.get(), 17);
}

0 comments on commit 6886f04

Please sign in to comment.