12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #include <catch2/catch_test_macros.hpp>
- #include <catch2/generators/catch_generators.hpp>
- #include <string>
- struct TestSubject {
-
-
- size_t GetLength( const std::string& input ) const { return input.size(); }
- };
- TEST_CASE("Table allows pre-computed test inputs and outputs", "[example][generator]") {
- using std::make_tuple;
-
- TestSubject subj;
- SECTION("This section is run for each row in the table") {
- std::string test_input;
- size_t expected_output;
- std::tie( test_input, expected_output ) =
- GENERATE( table<std::string, size_t>(
- {
- make_tuple( "one", 3 ),
- make_tuple( "two", 3 ),
- make_tuple( "three", 5 ),
- make_tuple( "four", 4 ) } ) );
-
- auto result = subj.GetLength(test_input);
-
- CAPTURE(test_input);
-
- REQUIRE(result == expected_output);
- }
- }
|