| 98 | } |
| 99 | |
| 100 | void test_addr() { |
| 101 | connection_options opts; |
| 102 | ASSERT_EQUAL("foo:bar", configure(opts, R"({ "host":"foo", "port":"bar" })")); |
| 103 | ASSERT_EQUAL("foo:1234", configure(opts, R"({ "host":"foo", "port":"1234" })")); |
| 104 | ASSERT_EQUAL("localhost:amqps", configure(opts, "{}")); |
| 105 | ASSERT_EQUAL("localhost:amqp", configure(opts, R"({"scheme":"amqp"})")); |
| 106 | ASSERT_EQUAL("foo:bar", configure(opts, R"( |
| 107 | { "host":"foo", /* inline comment */"port":"bar" // end of line comment |
| 108 | } |
| 109 | )")); |
| 110 | |
| 111 | ASSERT_THROWS_MSG(error, "'scheme' must be", configure(opts, R"({"scheme":"bad"})")); |
| 112 | ASSERT_THROWS_MSG(error, "'scheme' expected string, found boolean", configure(opts, R"({"scheme":true})")); |
| 113 | ASSERT_THROWS_MSG(error, "'port' expected string or uint, found boolean", configure(opts, R"({"port":true})")); |
| 114 | ASSERT_THROWS_MSG(error, "'host' expected string, found boolean", configure(opts, R"({"host":true})")); |
| 115 | } |
| 116 | |
| 117 | void test_invalid_config() { |
| 118 | connection_options opts; |