Skip to content

Commit

Permalink
added error case test for custom from_node test
Browse files Browse the repository at this point in the history
  • Loading branch information
fktn-k committed Nov 9, 2023
1 parent 31eb7f0 commit 4b179fe
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/unit_test/test_custom_from_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,17 @@ TEST_CASE("FromNodeTest_UserDefinedTypeVectorTest", "[FromNodeTest]")
REQUIRE(novels[1].title == "Frankenstein");
REQUIRE(novels[1].author == "Mary Shelly");
REQUIRE(novels[1].year == 1818);
}

TEST_CASE("FromNodeTest_UserDefinedTypeVectorErrorTest", "[FromNodeTest]")
{
std::string input = "novels:\n"
" - title: Robinson Crusoe\n"
" author: Daniel Defoe\n"
" year: 1678\n"
" - title: Frankenstein\n"
" author: Mary Shelly\n"
" year: 1818\n";
fkyaml::node node = fkyaml::node::deserialize(input);
REQUIRE_THROWS_AS(node.get_value<std::vector<test::novel>>(), fkyaml::exception);
}

0 comments on commit 4b179fe

Please # to comment.