| 13 | BOOST_FIXTURE_TEST_SUITE(rest_tests, BasicTestingSetup) |
| 14 | |
| 15 | BOOST_AUTO_TEST_CASE(test_query_string) |
| 16 | { |
| 17 | std::string param; |
| 18 | RESTResponseFormat rf; |
| 19 | // No query string |
| 20 | rf = ParseDataFormat(param, "/rest/endpoint/someresource.json"); |
| 21 | BOOST_CHECK_EQUAL(param, "/rest/endpoint/someresource"); |
| 22 | BOOST_CHECK_EQUAL(rf, RESTResponseFormat::JSON); |
| 23 | |
| 24 | // Query string with single parameter |
| 25 | rf = ParseDataFormat(param, "/rest/endpoint/someresource.bin?p1=v1"); |
| 26 | BOOST_CHECK_EQUAL(param, "/rest/endpoint/someresource"); |
| 27 | BOOST_CHECK_EQUAL(rf, RESTResponseFormat::BINARY); |
| 28 | |
| 29 | // Query string with multiple parameters |
| 30 | rf = ParseDataFormat(param, "/rest/endpoint/someresource.hex?p1=v1&p2=v2"); |
| 31 | BOOST_CHECK_EQUAL(param, "/rest/endpoint/someresource"); |
| 32 | BOOST_CHECK_EQUAL(rf, RESTResponseFormat::HEX); |
| 33 | |
| 34 | // Incorrectly formed query string will not be handled |
| 35 | rf = ParseDataFormat(param, "/rest/endpoint/someresource.json&p1=v1"); |
| 36 | BOOST_CHECK_EQUAL(param, "/rest/endpoint/someresource.json&p1=v1"); |
| 37 | BOOST_CHECK_EQUAL(rf, RESTResponseFormat::UNDEF); |
| 38 | |
| 39 | // Omitted data format with query string should return UNDEF and hide query string |
| 40 | rf = ParseDataFormat(param, "/rest/endpoint/someresource?p1=v1"); |
| 41 | BOOST_CHECK_EQUAL(param, "/rest/endpoint/someresource"); |
| 42 | BOOST_CHECK_EQUAL(rf, RESTResponseFormat::UNDEF); |
| 43 | |
| 44 | // Data format specified after query string |
| 45 | rf = ParseDataFormat(param, "/rest/endpoint/someresource?p1=v1.json"); |
| 46 | BOOST_CHECK_EQUAL(param, "/rest/endpoint/someresource"); |
| 47 | BOOST_CHECK_EQUAL(rf, RESTResponseFormat::UNDEF); |
| 48 | } |
| 49 | BOOST_AUTO_TEST_SUITE_END() |
nothing calls this directly
no test coverage detected