yaml-cpp/test
Kefu Chai 3ff13a243d node/convert: support conversion for std::string_view
as the key is not always nul terminated, it'd be handy to use
a `std::string_view` when a key is expected.

before this change, we would have FTBFS if the key is a `string_view`
when looking up a node in a map:
```
/usr/include/yaml-cpp/node/detail/impl.h: In instantiation of ‘bool YAML::detail::node::equals(const T&, YAML::detail::shared_memory_holder) [with T = std::basic_string_view<char>; YAML::detail::shared_memory_holder = std::shared_ptr<YAML::detail::memory_holder>]’:
/usr/include/yaml-cpp/node/detail/impl.h:122:26:   required from ‘YAML::detail::node* YAML::detail::node_data::get(const Key&, YAML::detail::shared_memory_holder) const [with Key = std::basic_string_view<char>; YAML::detail::shared_memory_holder = std::shared_ptr<YAML::detail::memory_holder>]’
/usr/include/yaml-cpp/node/detail/node_ref.h:64:55:   required from ‘YAML::detail::node* YAML::detail::node_ref::get(const Key&, YAML::detail::shared_memory_holder) const [with Key = std::basic_string_view<char>; YAML::detail::shared_memory_holder = std::shared_ptr<YAML::detail::memory_holder>]’
/usr/include/yaml-cpp/node/detail/node.h:125:53:   required from ‘YAML::detail::node* YAML::detail::node::get(const Key&, YAML::detail::shared_memory_holder) const [with Key = std::basic_string_view<char>; YAML::detail::shared_memory_holder = std::shared_ptr<YAML::detail::memory_holder>]’
/usr/include/yaml-cpp/node/impl.h:392:71:   required from ‘const YAML::Node YAML::Node::operator[](const Key&) const [with Key = std::basic_string_view<char>]’
../../src/config/base_config.cc:20:23:   required from here
/usr/include/yaml-cpp/node/detail/impl.h:93:25: error: incomplete type ‘YAML::convert<std::basic_string_view<char> >’ used in nested name specifier
   93 |   if (convert<T>::decode(Node(*this, pMemory), lhs)) {
      |       ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
```
after this change, a full specialization for `convert<std::string_view`
is added so that we can lookup a node using key of `std::string_view`, like
```c++
string_view key = "yet_another_key";
auto value = node[key];
```

tested with
```console
$ cmake -B build -D CMAKE_CXX_STANDARD=20 -D YAML_CPP_BUILD_TESTS=ON -G Ninja
$ cmake --build build yaml-cpp-tests
$ ctest --test-dir build --output-on-failure
```

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
2023-07-18 12:55:45 +08:00
..
gtest-1.11.0 Update gtest to 1.11.0 (#1086) 2022-02-17 12:08:56 -06:00
integration Include property nodes in the long key check (#1140) 2022-10-04 18:51:53 -05:00
node node/convert: support conversion for std::string_view 2023-07-18 12:55:45 +08:00
binary_test.cpp Use static_cast<unsigned char> on DecodeBase64 to prevent SEGV on negative values (#1051) 2021-10-20 10:18:08 -05:00
BUILD.bazel Add bazel Support (#724) 2019-09-27 10:11:38 -05:00
CMakeLists.txt Make sure tests are run in CI (#1170) 2023-03-04 14:06:01 -06:00
create-emitter-tests.py Add optional OnAnchor method to EventHandler (#530) 2019-03-12 15:24:32 -07:00
handler_test.h Factored out HandlerTest as a base class 2014-03-23 16:26:44 -05:00
main.cpp Convert node tests to gtest 2014-03-23 19:21:13 -05:00
mock_event_handler.h Small readability improvements in Parser 2019-11-23 13:17:02 -06:00
ostream_wrapper_test.cpp Refactor CMake to use more modern paradigms (#741) 2019-09-27 09:59:53 -05:00
parser_test.cpp Fix stack overflow (#807) 2020-04-09 13:02:10 -05:00
regex_test.cpp Apply formatting/style tweaks to comply with compile time diagnostics for g++ and clang++ (#686) 2019-03-13 15:18:34 -07:00
specexamples.h Supplement test cases for 2.19 ~ 2.22 schema tags. (#857) 2020-05-12 13:20:45 -05:00