Compare commits

...

11 Commits

Author SHA1 Message Date
Toru Niina
b389bbc4eb Merge pull request #242 from 0X1A/master
Fix issues with CMake package configuration when used with vcpkg #110
2024-06-12 00:46:15 +09:00
ToruNiina
5e4eb52f84 fix: add cxx_std to check_cxx_source_compiles
in macos, default version is 98 and it fails to compile boost test.
ci fails in the test branch because of apt timeout, but osx jobs works.
2024-06-11 23:47:49 +09:00
Alberto Corona
cbd596144d Fix issue with CMake package configuration #110 2024-05-01 18:57:49 -05:00
ToruNiina
85faca9cbe ci: update action checkout 2024-03-20 23:43:01 +09:00
ToruNiina
3509be6629 ci: add env var to avoid installation failure 2024-03-20 23:33:47 +09:00
ToruNiina
fb7b02f254 ci: remove old version of osx that takes time 2024-03-20 23:33:27 +09:00
ToruNiina
2466959cf9 chore: avoid false-positive ref life warning 2024-03-20 22:42:00 +09:00
ToruNiina
a76c5b385f refactor: replace mut-ref by take-and-move pattern 2024-03-20 22:40:46 +09:00
ToruNiina
52621a4fd8 feat: remove cxx_standard related stuff
fix #241
2024-03-20 22:38:56 +09:00
ToruNiina
64cd90637b refactor: move cmake component to where it's used 2024-03-20 22:35:03 +09:00
ToruNiina
d4a6fc7953 refactor: remove scripts for old version of cmake
now minimum_require ensures that version is not used
2024-03-20 22:34:02 +09:00
7 changed files with 62 additions and 112 deletions

View File

@@ -12,7 +12,7 @@ jobs:
unreleased: ['ON', 'OFF'] unreleased: ['ON', 'OFF']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
submodules: true submodules: true
- name: Install - name: Install
@@ -46,7 +46,7 @@ jobs:
- {compiler: '11', standard: '20'} - {compiler: '11', standard: '20'}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
submodules: true submodules: true
- name: Install - name: Install
@@ -78,7 +78,7 @@ jobs:
- {compiler: 'g++-7', standard: '20'} - {compiler: 'g++-7', standard: '20'}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
submodules: true submodules: true
- name: Install - name: Install
@@ -117,7 +117,7 @@ jobs:
- {compiler: '9', standard: '20'} - {compiler: '9', standard: '20'}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
submodules: true submodules: true
- name: Install - name: Install
@@ -146,7 +146,7 @@ jobs:
# unreleased: ['ON', 'OFF'] # unreleased: ['ON', 'OFF']
# steps: # steps:
# - name: Checkout # - name: Checkout
# uses: actions/checkout@v3 # uses: actions/checkout@v4
# with: # with:
# submodules: true # submodules: true
# - name: Install # - name: Install
@@ -171,12 +171,14 @@ jobs:
unreleased: ['ON', 'OFF'] unreleased: ['ON', 'OFF']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
submodules: true submodules: true
- name: Install - name: Install
run: | run: |
brew install boost brew install boost
env:
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
- name: Configure - name: Configure
run: | run: |
mkdir build && cd build mkdir build && cd build
@@ -196,33 +198,7 @@ jobs:
unreleased: ['ON', 'OFF'] unreleased: ['ON', 'OFF']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
with:
submodules: true
- name: Install
run: |
brew install boost
- name: Configure
run: |
mkdir build && cd build
cmake .. -Dtoml11_BUILD_TEST=ON -DCMAKE_CXX_STANDARD=${{ matrix.standard }} -DTOML11_USE_UNRELEASED_TOML_FEATURES=${{ matrix.unreleased }}
- name: Build
run: |
cd build && cmake --build .
- name: Test
run: |
cd build && ctest --output-on-failure
build-osx-11:
runs-on: macos-11
strategy:
matrix:
standard: ['11', '14', '17', '20']
unreleased: ['ON', 'OFF']
steps:
- name: Checkout
uses: actions/checkout@v3
with: with:
submodules: true submodules: true
- name: Install - name: Install
@@ -248,7 +224,7 @@ jobs:
unreleased: ['ON', 'OFF'] unreleased: ['ON', 'OFF']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
submodules: true submodules: true
- name: Install - name: Install

View File

@@ -11,40 +11,6 @@ option(toml11_TEST_WITH_UBSAN "use LLVM undefined behavior sanitizer" OFF)
option(TOML11_USE_UNRELEASED_TOML_FEATURES option(TOML11_USE_UNRELEASED_TOML_FEATURES
"use features in toml-lang/toml master while testing" OFF) "use features in toml-lang/toml master while testing" OFF)
include(CheckCXXCompilerFlag)
if("${CMAKE_VERSION}" VERSION_GREATER 3.1)
set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "Boolean specifying whether compiler specific extensions are requested.")
if(NOT DEFINED CMAKE_CXX_STANDARD)
message(FATAL_ERROR "CMAKE_CXX_STANDARD is not defined. \
The C++ standard whose features are requested to *build* all targets. \
Remember that toml11 is a header only library that does NOT require compilation to use.")
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON CACHE BOOL "Boolean describing whether the value of CXX_STANDARD is a requirement.")
else()
# Manually check for C++11 compiler flag.
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_GNU11)
CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" COMPILER_SUPPORTS_GNU0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXXOX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
elseif(COMPILER_SUPPORTS_GNU11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
elseif(COMPILER_SUPPORTS_GNU0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
else()
if(MSVC)
if(MSVC_VERSION LESS 1900)
message(SEND_ERROR "MSVC < 14.0 is not supported. Please update your compiler or use mingw")
endif()
else()
message(SEND_ERROR "The ${CMAKE_CXX_COMPILER} compiler lacks C++11 support. Use another compiler.")
endif()
endif()
endif()
if(MSVC) if(MSVC)
# add_definitions("/Zc:__cplusplus") # define __cplusplus value correctly # add_definitions("/Zc:__cplusplus") # define __cplusplus value correctly
add_definitions("/utf-8") # enable to use u8"" literal add_definitions("/utf-8") # enable to use u8"" literal

View File

@@ -1,2 +1,2 @@
@PACKAGE_INIT@ @PACKAGE_INIT@
include("@PACKAGE_toml11_install_cmake_dir@/toml11Targets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/toml11Targets.cmake")

View File

@@ -55,6 +55,8 @@ set(TEST_NAMES
test_extended_conversions test_extended_conversions
) )
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-Wall" COMPILER_SUPPORTS_WALL) CHECK_CXX_COMPILER_FLAG("-Wall" COMPILER_SUPPORTS_WALL)
CHECK_CXX_COMPILER_FLAG("-Wextra" COMPILER_SUPPORTS_WEXTRA) CHECK_CXX_COMPILER_FLAG("-Wextra" COMPILER_SUPPORTS_WEXTRA)
CHECK_CXX_COMPILER_FLAG("-Wpedantic" COMPILER_SUPPORTS_WPEDANTIC) CHECK_CXX_COMPILER_FLAG("-Wpedantic" COMPILER_SUPPORTS_WPEDANTIC)
@@ -103,9 +105,13 @@ find_package(Boost COMPONENTS unit_test_framework REQUIRED)
set(PREVIOUSLY_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}") set(PREVIOUSLY_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}")
set(PREVIOUSLY_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") set(PREVIOUSLY_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
set(PREVIOUSLY_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
list(APPEND CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIRS}) list(APPEND CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) list(APPEND CMAKE_REQUIRED_LIBRARIES ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
if(APPLE)
list(APPEND CMAKE_REQUIRED_FLAGS "-std=c++11")
endif()
check_cxx_source_compiles(" check_cxx_source_compiles("
#define BOOST_TEST_MODULE \"dummy\" #define BOOST_TEST_MODULE \"dummy\"
@@ -133,9 +139,11 @@ BOOST_AUTO_TEST_CASE(proforma) { BOOST_TEST(true); }
set(CMAKE_REQUIRED_INCLUDES "${PREVIOUSLY_REQUIRED_INCLUDES}") set(CMAKE_REQUIRED_INCLUDES "${PREVIOUSLY_REQUIRED_INCLUDES}")
set(CMAKE_REQUIRED_LIBRARIES "${PREVIOUSLY_REQUIRED_LIBRARIES}") set(CMAKE_REQUIRED_LIBRARIES "${PREVIOUSLY_REQUIRED_LIBRARIES}")
set(CMAKE_REQUIRED_FLAGS "${PREVIOUSLY_REQUIRED_FLAGS}")
unset(PREVIOUSLY_REQUIRED_INCLUDES) unset(PREVIOUSLY_REQUIRED_INCLUDES)
unset(PREVIOUSLY_REQUIRED_LIBRARIES) unset(PREVIOUSLY_REQUIRED_LIBRARIES)
unset(PREVIOUSLY_REQUIRED_FLAGS)
if(TOML11_WITH_BOOST_TEST_DYNAMIC) if(TOML11_WITH_BOOST_TEST_DYNAMIC)
add_definitions(-DUNITTEST_FRAMEWORK_LIBRARY_EXIST -DBOOST_TEST_DYN_LINK) add_definitions(-DUNITTEST_FRAMEWORK_LIBRARY_EXIST -DBOOST_TEST_DYN_LINK)

View File

@@ -14,8 +14,8 @@ BOOST_AUTO_TEST_CASE(test_comment_before)
std::istringstream iss(file); std::istringstream iss(file);
const auto v = toml::parse<toml::preserve_comments>(iss); const auto v = toml::parse<toml::preserve_comments>(iss);
const auto& a = toml::find(v, "a"); const auto a = toml::find(v, "a");
const auto& b = toml::find(v, "b"); const auto b = toml::find(v, "b");
BOOST_TEST(a.comments().size() == 1u); BOOST_TEST(a.comments().size() == 1u);
BOOST_TEST(a.comments().front() == " comment for a."); BOOST_TEST(a.comments().front() == " comment for a.");
@@ -35,8 +35,8 @@ BOOST_AUTO_TEST_CASE(test_comment_before)
std::istringstream iss(file); std::istringstream iss(file);
const auto v = toml::parse<toml::preserve_comments>(iss); const auto v = toml::parse<toml::preserve_comments>(iss);
const auto& a = toml::find(v, "a"); const auto a = toml::find(v, "a");
const auto& b = toml::find(v, "b"); const auto b = toml::find(v, "b");
BOOST_TEST(a.comments().size() == 2u); BOOST_TEST(a.comments().size() == 2u);
BOOST_TEST(a.comments().front() == " comment for a."); BOOST_TEST(a.comments().front() == " comment for a.");
@@ -58,8 +58,8 @@ BOOST_AUTO_TEST_CASE(test_comment_inline)
std::istringstream iss(file); std::istringstream iss(file);
const auto v = toml::parse<toml::preserve_comments>(iss); const auto v = toml::parse<toml::preserve_comments>(iss);
const auto& a = toml::find(v, "a"); const auto a = toml::find(v, "a");
const auto& b = toml::find(v, "b"); const auto b = toml::find(v, "b");
BOOST_TEST(a.comments().size() == 1u); BOOST_TEST(a.comments().size() == 1u);
BOOST_TEST(a.comments().front() == " comment for a."); BOOST_TEST(a.comments().front() == " comment for a.");
@@ -79,9 +79,9 @@ BOOST_AUTO_TEST_CASE(test_comment_inline)
std::istringstream iss(file); std::istringstream iss(file);
const auto v = toml::parse<toml::preserve_comments>(iss); const auto v = toml::parse<toml::preserve_comments>(iss);
const auto& a = toml::find(v, "a"); const auto a = toml::find(v, "a");
const auto& b = toml::find(v, "b"); const auto b = toml::find(v, "b");
const auto& b0 = b.as_array().at(0); const auto b0 = b.as_array().at(0);
BOOST_TEST(a.comments().size() == 1u); BOOST_TEST(a.comments().size() == 1u);
BOOST_TEST(a.comments().front() == " comment for a."); BOOST_TEST(a.comments().front() == " comment for a.");
@@ -110,10 +110,10 @@ BOOST_AUTO_TEST_CASE(test_comment_both)
std::istringstream iss(file); std::istringstream iss(file);
const auto v = toml::parse<toml::preserve_comments>(iss); const auto v = toml::parse<toml::preserve_comments>(iss);
const auto& a = toml::find(v, "a"); const auto a = toml::find(v, "a");
const auto& b = toml::find(v, "b"); const auto b = toml::find(v, "b");
const auto& c = toml::find(v, "c"); const auto c = toml::find(v, "c");
const auto& c0 = c.as_array().at(0); const auto c0 = c.as_array().at(0);
BOOST_TEST(a.comments().size() == 2u); BOOST_TEST(a.comments().size() == 2u);
BOOST_TEST(a.comments().front() == " comment for a."); BOOST_TEST(a.comments().front() == " comment for a.");
@@ -186,10 +186,10 @@ BOOST_AUTO_TEST_CASE(test_discard_comment)
std::istringstream iss(file); std::istringstream iss(file);
const auto v = toml::parse<toml::discard_comments>(iss); const auto v = toml::parse<toml::discard_comments>(iss);
const auto& a = toml::find(v, "a"); const auto a = toml::find(v, "a");
const auto& b = toml::find(v, "b"); const auto b = toml::find(v, "b");
const auto& c = toml::find(v, "c"); const auto c = toml::find(v, "c");
const auto& c0 = c.as_array().at(0); const auto c0 = c.as_array().at(0);
BOOST_TEST(a.comments().empty()); BOOST_TEST(a.comments().empty());
BOOST_TEST(b.comments().empty()); BOOST_TEST(b.comments().empty());

View File

@@ -12,7 +12,7 @@ BOOST_AUTO_TEST_CASE(test_example)
const auto data = toml::parse(testinput("example.toml")); const auto data = toml::parse(testinput("example.toml"));
BOOST_TEST(toml::find<std::string>(data, "title") == "TOML Example"); BOOST_TEST(toml::find<std::string>(data, "title") == "TOML Example");
const auto& owner = toml::find(data, "owner"); const auto owner = toml::find(data, "owner");
{ {
BOOST_TEST(toml::find<std::string>(owner, "name") == "Tom Preston-Werner"); BOOST_TEST(toml::find<std::string>(owner, "name") == "Tom Preston-Werner");
BOOST_TEST(toml::find<std::string>(owner, "organization") == "GitHub"); BOOST_TEST(toml::find<std::string>(owner, "organization") == "GitHub");
@@ -23,7 +23,7 @@ BOOST_AUTO_TEST_CASE(test_example)
toml::local_time(7, 32, 0), toml::time_offset(0, 0))); toml::local_time(7, 32, 0), toml::time_offset(0, 0)));
} }
const auto& database = toml::find(data, "database"); const auto database = toml::find(data, "database");
{ {
BOOST_TEST(toml::find<std::string>(database, "server") == "192.168.1.1"); BOOST_TEST(toml::find<std::string>(database, "server") == "192.168.1.1");
const std::vector<int> expected_ports{8001, 8001, 8002}; const std::vector<int> expected_ports{8001, 8001, 8002};
@@ -32,7 +32,7 @@ BOOST_AUTO_TEST_CASE(test_example)
BOOST_TEST(toml::find<bool>(database, "enabled") == true); BOOST_TEST(toml::find<bool>(database, "enabled") == true);
} }
const auto& servers = toml::find(data, "servers"); const auto servers = toml::find(data, "servers");
{ {
toml::table alpha = toml::find<toml::table>(servers, "alpha"); toml::table alpha = toml::find<toml::table>(servers, "alpha");
BOOST_TEST(toml::get<std::string>(alpha.at("ip")) == "10.0.0.1"); BOOST_TEST(toml::get<std::string>(alpha.at("ip")) == "10.0.0.1");
@@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE(test_example)
BOOST_TEST(toml::get<std::string>(beta.at("country")) == "\xE4\xB8\xAD\xE5\x9B\xBD"); BOOST_TEST(toml::get<std::string>(beta.at("country")) == "\xE4\xB8\xAD\xE5\x9B\xBD");
} }
const auto& clients = toml::find(data, "clients"); const auto clients = toml::find(data, "clients");
{ {
toml::array clients_data = toml::find<toml::array>(clients, "data"); toml::array clients_data = toml::find<toml::array>(clients, "data");
@@ -76,7 +76,7 @@ BOOST_AUTO_TEST_CASE(test_example_stream)
const auto data = toml::parse(ifs); const auto data = toml::parse(ifs);
BOOST_TEST(toml::find<std::string>(data, "title") == "TOML Example"); BOOST_TEST(toml::find<std::string>(data, "title") == "TOML Example");
const auto& owner = toml::find(data, "owner"); const auto owner = toml::find(data, "owner");
{ {
BOOST_TEST(toml::find<std::string>(owner, "name") == "Tom Preston-Werner"); BOOST_TEST(toml::find<std::string>(owner, "name") == "Tom Preston-Werner");
BOOST_TEST(toml::find<std::string>(owner, "organization") == "GitHub"); BOOST_TEST(toml::find<std::string>(owner, "organization") == "GitHub");
@@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(test_example_stream)
toml::local_time(7, 32, 0), toml::time_offset(0, 0))); toml::local_time(7, 32, 0), toml::time_offset(0, 0)));
} }
const auto& database = toml::find(data, "database"); const auto database = toml::find(data, "database");
{ {
BOOST_TEST(toml::find<std::string>(database, "server") == "192.168.1.1"); BOOST_TEST(toml::find<std::string>(database, "server") == "192.168.1.1");
const std::vector<int> expected_ports{8001, 8001, 8002}; const std::vector<int> expected_ports{8001, 8001, 8002};
@@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE(test_example_stream)
BOOST_TEST(toml::find<bool>(database, "enabled") == true); BOOST_TEST(toml::find<bool>(database, "enabled") == true);
} }
const auto& servers = toml::find(data, "servers"); const auto servers = toml::find(data, "servers");
{ {
toml::table alpha = toml::find<toml::table>(servers, "alpha"); toml::table alpha = toml::find<toml::table>(servers, "alpha");
BOOST_TEST(toml::get<std::string>(alpha.at("ip")) == "10.0.0.1"); BOOST_TEST(toml::get<std::string>(alpha.at("ip")) == "10.0.0.1");
@@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE(test_example_stream)
BOOST_TEST(toml::get<std::string>(beta.at("country")) == "\xE4\xB8\xAD\xE5\x9B\xBD"); BOOST_TEST(toml::get<std::string>(beta.at("country")) == "\xE4\xB8\xAD\xE5\x9B\xBD");
} }
const auto& clients = toml::find(data, "clients"); const auto clients = toml::find(data, "clients");
{ {
toml::array clients_data = toml::find<toml::array>(clients, "data"); toml::array clients_data = toml::find<toml::array>(clients, "data");
std::vector<std::string> expected_name{"gamma", "delta"}; std::vector<std::string> expected_name{"gamma", "delta"};
@@ -145,7 +145,7 @@ BOOST_AUTO_TEST_CASE(test_example_file_pointer)
fclose(file); fclose(file);
BOOST_TEST(toml::find<std::string>(data, "title") == "TOML Example"); BOOST_TEST(toml::find<std::string>(data, "title") == "TOML Example");
const auto& owner = toml::find(data, "owner"); const auto owner = toml::find(data, "owner");
{ {
BOOST_TEST(toml::find<std::string>(owner, "name") == "Tom Preston-Werner"); BOOST_TEST(toml::find<std::string>(owner, "name") == "Tom Preston-Werner");
BOOST_TEST(toml::find<std::string>(owner, "organization") == "GitHub"); BOOST_TEST(toml::find<std::string>(owner, "organization") == "GitHub");
@@ -156,7 +156,7 @@ BOOST_AUTO_TEST_CASE(test_example_file_pointer)
toml::local_time(7, 32, 0), toml::time_offset(0, 0))); toml::local_time(7, 32, 0), toml::time_offset(0, 0)));
} }
const auto& database = toml::find(data, "database"); const auto database = toml::find(data, "database");
{ {
BOOST_TEST(toml::find<std::string>(database, "server") == "192.168.1.1"); BOOST_TEST(toml::find<std::string>(database, "server") == "192.168.1.1");
const std::vector<int> expected_ports{8001, 8001, 8002}; const std::vector<int> expected_ports{8001, 8001, 8002};
@@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE(test_example_file_pointer)
BOOST_TEST(toml::find<bool>(database, "enabled") == true); BOOST_TEST(toml::find<bool>(database, "enabled") == true);
} }
const auto& servers = toml::find(data, "servers"); const auto servers = toml::find(data, "servers");
{ {
toml::table alpha = toml::find<toml::table>(servers, "alpha"); toml::table alpha = toml::find<toml::table>(servers, "alpha");
BOOST_TEST(toml::get<std::string>(alpha.at("ip")) == "10.0.0.1"); BOOST_TEST(toml::get<std::string>(alpha.at("ip")) == "10.0.0.1");
@@ -177,7 +177,7 @@ BOOST_AUTO_TEST_CASE(test_example_file_pointer)
BOOST_TEST(toml::get<std::string>(beta.at("country")) == "\xE4\xB8\xAD\xE5\x9B\xBD"); BOOST_TEST(toml::get<std::string>(beta.at("country")) == "\xE4\xB8\xAD\xE5\x9B\xBD");
} }
const auto& clients = toml::find(data, "clients"); const auto clients = toml::find(data, "clients");
{ {
toml::array clients_data = toml::find<toml::array>(clients, "data"); toml::array clients_data = toml::find<toml::array>(clients, "data");
std::vector<std::string> expected_name{"gamma", "delta"}; std::vector<std::string> expected_name{"gamma", "delta"};
@@ -286,7 +286,7 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_comment)
const auto data = toml::parse<toml::preserve_comments>(testinput("example.toml")); const auto data = toml::parse<toml::preserve_comments>(testinput("example.toml"));
BOOST_TEST(toml::find<std::string>(data, "title") == "TOML Example"); BOOST_TEST(toml::find<std::string>(data, "title") == "TOML Example");
const auto& owner = toml::find(data, "owner"); const auto owner = toml::find(data, "owner");
{ {
BOOST_TEST(toml::find<std::string>(owner, "name") == "Tom Preston-Werner"); BOOST_TEST(toml::find<std::string>(owner, "name") == "Tom Preston-Werner");
BOOST_TEST(toml::find<std::string>(owner, "organization") == "GitHub"); BOOST_TEST(toml::find<std::string>(owner, "organization") == "GitHub");
@@ -299,7 +299,7 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_comment)
" First class dates? Why not?"); " First class dates? Why not?");
} }
const auto& database = toml::find(data, "database"); const auto database = toml::find(data, "database");
{ {
BOOST_TEST(toml::find<std::string>(database, "server") == "192.168.1.1"); BOOST_TEST(toml::find<std::string>(database, "server") == "192.168.1.1");
const std::vector<int> expected_ports{8001, 8001, 8002}; const std::vector<int> expected_ports{8001, 8001, 8002};
@@ -308,15 +308,15 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_comment)
BOOST_TEST(toml::find<bool>(database, "enabled") == true); BOOST_TEST(toml::find<bool>(database, "enabled") == true);
} }
const auto& servers = toml::find(data, "servers"); const auto servers = toml::find(data, "servers");
{ {
const auto& alpha = toml::find(servers, "alpha"); const auto alpha = toml::find(servers, "alpha");
BOOST_TEST(alpha.comments().at(0) == BOOST_TEST(alpha.comments().at(0) ==
" You can indent as you please. Tabs or spaces. TOML don't care."); " You can indent as you please. Tabs or spaces. TOML don't care.");
BOOST_TEST(toml::find<std::string>(alpha, "ip") == "10.0.0.1"); BOOST_TEST(toml::find<std::string>(alpha, "ip") == "10.0.0.1");
BOOST_TEST(toml::find<std::string>(alpha, "dc") == "eqdc10"); BOOST_TEST(toml::find<std::string>(alpha, "dc") == "eqdc10");
const auto& beta = toml::find(servers, "beta"); const auto beta = toml::find(servers, "beta");
BOOST_TEST(toml::find<std::string>(beta, "ip") == "10.0.0.2"); BOOST_TEST(toml::find<std::string>(beta, "ip") == "10.0.0.2");
BOOST_TEST(toml::find<std::string>(beta, "dc") == "eqdc10"); BOOST_TEST(toml::find<std::string>(beta, "dc") == "eqdc10");
BOOST_TEST(toml::find<std::string>(beta, "country") == BOOST_TEST(toml::find<std::string>(beta, "country") ==
@@ -325,7 +325,7 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_comment)
" This should be parsed as UTF-8"); " This should be parsed as UTF-8");
} }
const auto& clients = toml::find(data, "clients"); const auto clients = toml::find(data, "clients");
{ {
BOOST_TEST(toml::find(clients, "data").comments().at(0) == BOOST_TEST(toml::find(clients, "data").comments().at(0) ==
" just an update to make sure parsers support it"); " just an update to make sure parsers support it");
@@ -376,7 +376,7 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_stdmap_stddeque)
>::value, ""); >::value, "");
BOOST_TEST(toml::find<std::string>(data, "title") == "TOML Example"); BOOST_TEST(toml::find<std::string>(data, "title") == "TOML Example");
const auto& owner = toml::find(data, "owner"); const auto owner = toml::find(data, "owner");
{ {
BOOST_TEST(toml::find<std::string>(owner, "name") == "Tom Preston-Werner"); BOOST_TEST(toml::find<std::string>(owner, "name") == "Tom Preston-Werner");
BOOST_TEST(toml::find<std::string>(owner, "organization") == "GitHub"); BOOST_TEST(toml::find<std::string>(owner, "organization") == "GitHub");
@@ -389,7 +389,7 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_stdmap_stddeque)
" First class dates? Why not?"); " First class dates? Why not?");
} }
const auto& database = toml::find(data, "database"); const auto database = toml::find(data, "database");
{ {
BOOST_TEST(toml::find<std::string>(database, "server") == "192.168.1.1"); BOOST_TEST(toml::find<std::string>(database, "server") == "192.168.1.1");
const std::vector<int> expected_ports{8001, 8001, 8002}; const std::vector<int> expected_ports{8001, 8001, 8002};
@@ -398,15 +398,15 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_stdmap_stddeque)
BOOST_TEST(toml::find<bool>(database, "enabled") == true); BOOST_TEST(toml::find<bool>(database, "enabled") == true);
} }
const auto& servers = toml::find(data, "servers"); const auto servers = toml::find(data, "servers");
{ {
const auto& alpha = toml::find(servers, "alpha"); const auto alpha = toml::find(servers, "alpha");
BOOST_TEST(alpha.comments().at(0) == BOOST_TEST(alpha.comments().at(0) ==
" You can indent as you please. Tabs or spaces. TOML don't care."); " You can indent as you please. Tabs or spaces. TOML don't care.");
BOOST_TEST(toml::find<std::string>(alpha, "ip") == "10.0.0.1"); BOOST_TEST(toml::find<std::string>(alpha, "ip") == "10.0.0.1");
BOOST_TEST(toml::find<std::string>(alpha, "dc") == "eqdc10"); BOOST_TEST(toml::find<std::string>(alpha, "dc") == "eqdc10");
const auto& beta = toml::find(servers, "beta"); const auto beta = toml::find(servers, "beta");
BOOST_TEST(toml::find<std::string>(beta, "ip") == "10.0.0.2"); BOOST_TEST(toml::find<std::string>(beta, "ip") == "10.0.0.2");
BOOST_TEST(toml::find<std::string>(beta, "dc") == "eqdc10"); BOOST_TEST(toml::find<std::string>(beta, "dc") == "eqdc10");
BOOST_TEST(toml::find<std::string>(beta, "country") == BOOST_TEST(toml::find<std::string>(beta, "country") ==
@@ -415,7 +415,7 @@ BOOST_AUTO_TEST_CASE(test_example_preserve_stdmap_stddeque)
" This should be parsed as UTF-8"); " This should be parsed as UTF-8");
} }
const auto& clients = toml::find(data, "clients"); const auto clients = toml::find(data, "clients");
{ {
BOOST_TEST(toml::find(clients, "data").comments().at(0) == BOOST_TEST(toml::find(clients, "data").comments().at(0) ==
" just an update to make sure parsers support it"); " just an update to make sure parsers support it");

View File

@@ -2453,7 +2453,7 @@ template<typename Comment = TOML11_DEFAULT_COMMENT_STRATEGY,
template<typename ...> class Table = std::unordered_map, template<typename ...> class Table = std::unordered_map,
template<typename ...> class Array = std::vector> template<typename ...> class Array = std::vector>
basic_value<Comment, Table, Array> basic_value<Comment, Table, Array>
parse(std::vector<char>& letters, const std::string& fname) parse(std::vector<char> letters, const std::string& fname)
{ {
using value_type = basic_value<Comment, Table, Array>; using value_type = basic_value<Comment, Table, Array>;
@@ -2468,7 +2468,7 @@ parse(std::vector<char>& letters, const std::string& fname)
letters.push_back('\n'); letters.push_back('\n');
} }
detail::location loc(std::move(fname), std::move(letters)); detail::location loc(fname, std::move(letters));
// skip BOM if exists. // skip BOM if exists.
// XXX component of BOM (like 0xEF) exceeds the representable range of // XXX component of BOM (like 0xEF) exceeds the representable range of