mirror of
https://github.com/ToruNiina/toml11.git
synced 2024-11-25 22:00:05 +00:00
10fd14f8b9
This patch consistently changes the inclusion order for unit test files to the following: 1. The header of the unit under test (using <> includes). 2. The unit_test.hpp header (using "" includes). 3. Any additional auxiliary test headers (using "" includes and sorted alphabetically). 4. Additional system headers needed for the test (using <> includes and sorted alphabetically). 5. Conditionally included system headers (using <> includes). Putting the unit under test's header at the very beginning has the advantage of also testing that the header is self-contained. It also makes it very quick to tell what unit is tested in this file.
27 lines
787 B
C++
27 lines
787 B
C++
#include <toml.hpp>
|
|
|
|
#include "unit_test.hpp"
|
|
|
|
#include <array>
|
|
#include <deque>
|
|
#include <list>
|
|
#include <map>
|
|
#include <unordered_map>
|
|
|
|
BOOST_AUTO_TEST_CASE(test_expect)
|
|
{
|
|
{
|
|
toml::value v1(42);
|
|
toml::value v2(3.14);
|
|
const auto v1_or_0 = toml::expect<int>(v1).unwrap_or(0);
|
|
const auto v2_or_0 = toml::expect<int>(v2).unwrap_or(0);
|
|
BOOST_TEST(42 == v1_or_0);
|
|
BOOST_TEST( 0 == v2_or_0);
|
|
|
|
const auto v1_or_none = toml::expect<int>(v1).map([](int i){return std::to_string(i);}).unwrap_or(std::string("none"));
|
|
const auto v2_or_none = toml::expect<int>(v2).map([](int i){return std::to_string(i);}).unwrap_or(std::string("none"));
|
|
BOOST_TEST("42" == v1_or_none);
|
|
BOOST_TEST("none" == v2_or_none);
|
|
}
|
|
}
|