// // json_binder_test_bool.t.h // json // // Created by Sam Jaffe on 2/27/17. // #pragma once #include #include "json_binder.hpp" using namespace json::binder; using namespace json::parser; class json_binder_value_bool_TestSuite : public CxxTest::TestSuite { public: void test_parse_bool_true() { char data[] = "true"; bool out = false; value_binder binder{}; parse(bind(out, binder), data, allow_all); TS_ASSERT_EQUALS( out, true ); } void test_parse_bool_false() { char data[] = "false"; bool out = true; value_binder binder{}; parse(bind(out, binder), data, allow_all); TS_ASSERT_EQUALS( out, false ); } void test_parse_nonbool_throws() { char data[] = "YES"; // Obj-C bool out = false; value_binder binder{}; TS_ASSERT_THROWS(parse(bind(out, binder), data, allow_all), json::malformed_json_exception); } void test_write_bool_true() { std::string const expected = "true"; std::stringstream ss; bool const in = true; value_binder binder{}; write(bind(in, binder), ss); TS_ASSERT_EQUALS(ss.str(), expected); } void test_write_bool_false() { std::string const expected = "false"; std::stringstream ss; bool const in = false; value_binder binder{}; write(bind(in, binder), ss); TS_ASSERT_EQUALS(ss.str(), expected); } };