-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d386cce
commit e023542
Showing
7 changed files
with
47 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,16 @@ | ||
include(CTest) | ||
|
||
add_executable(element_test element_test.cpp) | ||
add_executable(parser_test parser_test.cpp) | ||
add_executable(printable_test printable_test.cpp) | ||
add_executable(document_test document_test.cpp) | ||
add_executable(buffer_test buffer_test.cpp) | ||
function(add_custom_test test_name) | ||
add_executable(${test_name} ${test_name}.cpp) | ||
target_link_libraries(${test_name} Catch2::Catch2WithMain myxml) | ||
target_compile_features(${test_name} PRIVATE cxx_std_17) | ||
target_compile_features(${test_name} PRIVATE cxx_std_17) | ||
add_test(NAME ${test_name} COMMAND ${test_name} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | ||
endfunction() | ||
|
||
target_link_libraries(element_test Catch2::Catch2WithMain myxml) | ||
target_link_libraries(parser_test Catch2::Catch2WithMain myxml) | ||
target_link_libraries(printable_test Catch2::Catch2WithMain myxml) | ||
target_link_libraries(document_test Catch2::Catch2WithMain myxml) | ||
target_link_libraries(buffer_test Catch2::Catch2WithMain myxml) | ||
|
||
target_compile_features(element_test PRIVATE cxx_std_17) | ||
target_compile_features(parser_test PRIVATE cxx_std_17) | ||
target_compile_features(printable_test PRIVATE cxx_std_17) | ||
target_compile_features(document_test PRIVATE cxx_std_17) | ||
target_compile_features(buffer_test PRIVATE cxx_std_17) | ||
|
||
add_test(NAME element_test COMMAND element_test) | ||
add_test(NAME parser_test COMMAND parser_test WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | ||
add_test(NAME printable_test COMMAND printable_test) | ||
add_test(NAME document_test COMMAND document_test) | ||
add_test(NAME buffer_test COMMAND buffer_test) | ||
add_custom_test(element_test) | ||
add_custom_test(parser_test) | ||
add_custom_test(printable_test) | ||
add_custom_test(document_test) | ||
add_custom_test(buffer_test) | ||
add_custom_test(doc_test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// All example codes in document | ||
#include <optional> | ||
#include <catch2/catch_test_macros.hpp> | ||
#include "myxml/document.hpp" | ||
#include "myxml/element.hpp" | ||
|
||
TEST_CASE("docs/examples", "[doc]") | ||
{ | ||
SECTION("1") | ||
{ | ||
using namespace myxml; | ||
std::string xml = "<root/>"; | ||
document doc = document::parse(xml); | ||
std::string path = "tests/data/example.xml"; | ||
doc = document::load(path); | ||
// get root elem | ||
std::optional<element> elem = doc.root().first_elem(); | ||
// or directly query elem in root | ||
elem = doc.first_elem(); | ||
// or query by name | ||
elem = doc.first_elem("elem"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters