1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#define BOOST_TEST_MODULE config
#include <boost/test/included/unit_test.hpp>

#include <kooling/json/json.h>

#include <cstdlib>
#include <string>

BOOST_AUTO_TEST_SUITE(test_env)<--- There is an unknown macro here somewhere. Configuration is required. If BOOST_AUTO_TEST_SUITE is a macro then please configure it.

BOOST_AUTO_TEST_CASE(test_env_string)
{
    const json_t j = R"( { "k": "::env::KOOLING_TEST_STRING" } )"_json;

    const auto val{ j["k"].template get<std::string>() };
    BOOST_TEST(val == std::getenv("KOOLING_TEST_STRING"));
    BOOST_TEST(val == "foobar");
}

BOOST_AUTO_TEST_CASE(test_env_int)
{
    const json_t j = R"( { "k": "::env::KOOLING_TEST_INT" } )"_json;

    const auto val{ j["k"].template get<int>() };
    BOOST_TEST(val == std::stoi(std::getenv("KOOLING_TEST_INT")));
    BOOST_TEST(val == 42);
}

BOOST_AUTO_TEST_SUITE_END()