Bitcoin Core 31.99.0
P2P Digital Currency
rest_tests.cpp
Go to the documentation of this file.
1// Copyright (c) 2012-present The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <rest.h>
6#include <test/util/common.h>
8
9#include <boost/test/unit_test.hpp>
10
11#include <string>
12
14
15BOOST_AUTO_TEST_CASE(test_query_string)
16{
17 std::string param;
19 // No query string
20 rf = ParseDataFormat(param, "/rest/endpoint/someresource.json");
21 BOOST_CHECK_EQUAL(param, "/rest/endpoint/someresource");
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");
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");
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");
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");
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");
48}
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
#define BOOST_CHECK_EQUAL(v1, v2)
Definition: object.cpp:17
RESTResponseFormat rf
Definition: rest.cpp:48
RESTResponseFormat ParseDataFormat(std::string &param, const std::string &strReq)
Parse a URI to get the data format and URI without data format and query string.
Definition: rest.cpp:129
RESTResponseFormat
Definition: rest.h:10
BOOST_AUTO_TEST_CASE(test_query_string)
Definition: rest_tests.cpp:15
Basic testing setup.
Definition: setup_common.h:64