|
|
@@ -19,9 +19,7 @@ public:
|
|
|
char data[] = "[ 1, 2 ]";
|
|
|
using tuple = std::tuple<int, int>;
|
|
|
tuple out = std::make_tuple(0, 0);
|
|
|
- auto binder = tuple_binder<std::tuple<int, int>>()
|
|
|
- (get_binder<tuple, 0>())
|
|
|
- (get_binder<tuple, 1>());
|
|
|
+ auto binder = make_default_tuple_binder<int, int>();
|
|
|
parse(json::binder::bind(out, binder), data, allow_all);
|
|
|
TS_ASSERT_EQUALS(out, std::make_tuple(1, 2));
|
|
|
}
|
|
|
@@ -30,9 +28,7 @@ public:
|
|
|
char data[] = "[ 1 ]";
|
|
|
using tuple = std::tuple<int, int>;
|
|
|
tuple out = std::make_tuple(0, 0);
|
|
|
- auto binder = tuple_binder<std::tuple<int, int>>()
|
|
|
- (get_binder<tuple, 0>())
|
|
|
- (get_binder<tuple, 1>());
|
|
|
+ auto binder = make_default_tuple_binder<int, int>();
|
|
|
TS_ASSERT_THROWS(parse(json::binder::bind(out, binder), data, allow_all),
|
|
|
json::malformed_json_exception);
|
|
|
TS_ASSERT_EQUALS(out, std::make_tuple(1, 0));
|
|
|
@@ -42,11 +38,18 @@ public:
|
|
|
char data[] = "[ 1, 2, 3 ]";
|
|
|
using tuple = std::tuple<int, int>;
|
|
|
tuple out = std::make_tuple(0, 0);
|
|
|
- auto binder = tuple_binder<std::tuple<int, int>>()
|
|
|
- (get_binder<tuple, 0>())
|
|
|
- (get_binder<tuple, 1>());
|
|
|
+ auto binder = make_default_tuple_binder<int, int>();
|
|
|
TS_ASSERT_THROWS(parse(json::binder::bind(out, binder), data, allow_all),
|
|
|
json::malformed_json_exception);
|
|
|
TS_ASSERT_EQUALS(out, std::make_tuple(1, 2));
|
|
|
}
|
|
|
-};
|
|
|
+
|
|
|
+ void test_bind_to_tuple_with_multiple_types() {
|
|
|
+ char data[] = "[ 1, 0.5, \"hello\" ]";
|
|
|
+ using tuple = std::tuple<int, double, std::string>;
|
|
|
+ tuple out = std::make_tuple(0, 0.0, "");
|
|
|
+ auto binder = make_default_tuple_binder<int, double, std::string>();
|
|
|
+ TS_ASSERT_THROWS_NOTHING(parse(json::binder::bind(out, binder), data, allow_all));
|
|
|
+ TS_ASSERT_EQUALS(out, std::make_tuple(1, 0.5, "hello"));
|
|
|
+ }
|
|
|
+};
|