diff --git a/.gitmodules b/.gitmodules index 84ad92e..90ae49a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "tinyxml2"] path = tinyxml2 url = https://github.com/leethomason/tinyxml2.git -[submodule "catch"] - path = catch - url = https://github.com/philsquared/Catch.git +[submodule "Catch2"] + path = Catch2 + url = https://github.com/catchorg/Catch2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 10b4a17..c41dea2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ add_subdirectory (src) if(BUILD_TESTS) enable_testing() + add_subdirectory(Catch2) add_subdirectory (tests) endif(BUILD_TESTS) diff --git a/Catch2 b/Catch2 new file mode 160000 index 0000000..914aeec --- /dev/null +++ b/Catch2 @@ -0,0 +1 @@ +Subproject commit 914aeecfe23b1e16af6ea675a4fb5dbd5a5b8d0a diff --git a/catch b/catch deleted file mode 160000 index d758428..0000000 --- a/catch +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d758428fe297655e558a86cc6a013fcb1bcc8c7d diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2859a55..3f7a414 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,7 +6,7 @@ # endfunction(add_test_executable) # Includes Catch in the project: #add_subdirectory(${EXT_PROJECTS_DIR}/catch) -include_directories(${PROJECT_SOURCE_DIR}/catch/include) +# include_directories(${PROJECT_SOURCE_DIR}/Catch2/include) FASTTYPEGEN_TARGET(simple_types1 simple1.xml) @@ -28,7 +28,6 @@ FASTTYPEGEN_TARGET(test_types5 test5.xml) FASTTYPEGEN_TARGET(test_scp scp.xml) add_executable (mfast_test - test_main.cpp arena_allocator_test.cpp field_ref_test.cpp fast_istream_test.cpp @@ -63,11 +62,12 @@ add_executable (mfast_test scp_reset_test.cpp ) -target_link_libraries (mfast_test +target_link_libraries (mfast_test PRIVATE mfast_static mfast_coder_static mfast_json_static - mfast_xml_parser_static) + mfast_xml_parser_static + Catch2::Catch2WithMain) if(${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten") diff --git a/tests/aggregate_view_test.cpp b/tests/aggregate_view_test.cpp index 379ff24..2b2309d 100644 --- a/tests/aggregate_view_test.cpp +++ b/tests/aggregate_view_test.cpp @@ -17,7 +17,7 @@ // along with mFast. If not, see . // -#include "catch.hpp" +#include #include #include "mfast.h" diff --git a/tests/arena_allocator_test.cpp b/tests/arena_allocator_test.cpp index 73dba4c..e2cf070 100644 --- a/tests/arena_allocator_test.cpp +++ b/tests/arena_allocator_test.cpp @@ -16,7 +16,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with mFast. If not, see . // -#include "catch.hpp" +#include #include #include diff --git a/tests/coder_test.cpp b/tests/coder_test.cpp index 749ea3a..c63e573 100644 --- a/tests/coder_test.cpp +++ b/tests/coder_test.cpp @@ -17,8 +17,7 @@ // along with mFast. If not, see . // -#include "catch.hpp" - +#include #include #include #include diff --git a/tests/composite_type_test.cpp b/tests/composite_type_test.cpp index 95a4ea3..da05423 100644 --- a/tests/composite_type_test.cpp +++ b/tests/composite_type_test.cpp @@ -17,7 +17,7 @@ // along with mFast. If not, see . // -#include "catch.hpp" +#include #include "test4.h" #include diff --git a/tests/debug_allocator.h b/tests/debug_allocator.h index 19f6e7b..7b167ee 100644 --- a/tests/debug_allocator.h +++ b/tests/debug_allocator.h @@ -18,7 +18,7 @@ // #pragma once -#include "catch.hpp" +#include #include #include #include diff --git a/tests/decoder_operator_test.cpp b/tests/decoder_operator_test.cpp index f9599c4..abaa379 100644 --- a/tests/decoder_operator_test.cpp +++ b/tests/decoder_operator_test.cpp @@ -16,7 +16,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with mFast. If not, see . // -#include "catch.hpp" +#include #include #include @@ -497,9 +497,9 @@ TEST_CASE("test the decoding of fast operator copy","[operator_copy_decode_test] inst.prev_value().present(false); // // When the value is not present in the stream there are three cases depending on the state of the previous value: // // * empty – the value of the field is empty. If the field is optional the value is considered absent. It is a dynamic error [ERR D6] if the field is mandatory. - REQUIRE_THROWS_AS(decode_mref("\x80\x80", HAS_PMAP_BIT, result, CHANGE_PREVIOUS_VALUE), const mfast::fast_error& ); + REQUIRE_THROWS_AS(decode_mref("\x80\x80", HAS_PMAP_BIT, result, CHANGE_PREVIOUS_VALUE), mfast::fast_error ); inst.prev_value().present(false); - REQUIRE_THROWS_AS(decode_ext_mref("\x80\x80", HAS_PMAP_BIT, ext_mref(result), CHANGE_PREVIOUS_VALUE), const mfast::fast_error& ); + REQUIRE_THROWS_AS(decode_ext_mref("\x80\x80", HAS_PMAP_BIT, ext_mref(result), CHANGE_PREVIOUS_VALUE), mfast::fast_error ); } { @@ -644,8 +644,8 @@ TEST_CASE("test the decoding of fast operator increment","[operator_increment_de inst.prev_value().present(false); // When the value is not present in the stream there are three cases depending on the state of the previous value: // * empty – the value of the field is empty. If the field is optional the value is considered absent. It is a dynamic error [ERR D6] if the field is mandatory. - REQUIRE_THROWS_AS(decode_mref("\x80\x80", HAS_PMAP_BIT, result, CHANGE_PREVIOUS_VALUE), const mfast::fast_error&); - REQUIRE_THROWS_AS(decode_ext_mref("\x80\x80", HAS_PMAP_BIT, ext_mref(result), CHANGE_PREVIOUS_VALUE), const mfast::fast_error&); + REQUIRE_THROWS_AS(decode_mref("\x80\x80", HAS_PMAP_BIT, result, CHANGE_PREVIOUS_VALUE), mfast::fast_error); + REQUIRE_THROWS_AS(decode_ext_mref("\x80\x80", HAS_PMAP_BIT, ext_mref(result), CHANGE_PREVIOUS_VALUE), mfast::fast_error); } { @@ -980,10 +980,10 @@ TEST_CASE("test the decoding of fast operator delta for ascii string","[operator REQUIRE_THROWS_AS(decode_mref("\xC0\x86\x76\x61\x6C\x75\xE5", NO_PMAP_BIT, result, - CHANGE_PREVIOUS_VALUE), const mfast::fast_error&); + CHANGE_PREVIOUS_VALUE), mfast::fast_error); inst.prev_value().defined(false); // reset the previous value to undefined again REQUIRE_THROWS_AS(decode_ext_mref("\xC0\x86\x76\x61\x6C\x75\xE5", NO_PMAP_BIT, ext_mref( - result), CHANGE_PREVIOUS_VALUE), const mfast::fast_error&); + result), CHANGE_PREVIOUS_VALUE), mfast::fast_error); inst.destruct_value(storage, &alloc); } @@ -1117,10 +1117,10 @@ TEST_CASE("test the decoding of fast operator delta for unicode string","[operat // result.as("initial_value"); REQUIRE_THROWS_AS(decode_mref("\xC0\x86\x85\x76\x61\x6C\x75\x65", NO_PMAP_BIT, result, CHANGE_PREVIOUS_VALUE), - const mfast::fast_error& ); + mfast::fast_error ); REQUIRE_THROWS_AS(decode_ext_mref("\xC0\x86\x85\x76\x61\x6C\x75\x65", NO_PMAP_BIT, ext_mref(result), CHANGE_PREVIOUS_VALUE), - const mfast::fast_error& ); + mfast::fast_error ); inst.destruct_value(storage, &alloc); } @@ -1256,7 +1256,7 @@ TEST_CASE("test the decoding of fast operator tail for ascii string","[operator_ // undefined – the value of the field is the initial value that also becomes the new previous value. // It is a dynamic error [ERR D6] if the instruction context has no initial value. - REQUIRE_THROWS_AS(decode_mref("\x80\x80", HAS_PMAP_BIT, result, CHANGE_PREVIOUS_VALUE), const mfast::fast_error& ); + REQUIRE_THROWS_AS(decode_mref("\x80\x80", HAS_PMAP_BIT, result, CHANGE_PREVIOUS_VALUE), mfast::fast_error ); inst.destruct_value(storage, &alloc); } diff --git a/tests/dictionary_builder_test.cpp b/tests/dictionary_builder_test.cpp index 934f4a7..9c4c328 100644 --- a/tests/dictionary_builder_test.cpp +++ b/tests/dictionary_builder_test.cpp @@ -16,7 +16,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with mFast. If not, see . // -#include "catch.hpp" +#include #include #include diff --git a/tests/encoder_operator_test.cpp b/tests/encoder_operator_test.cpp index 288828a..59aab36 100644 --- a/tests/encoder_operator_test.cpp +++ b/tests/encoder_operator_test.cpp @@ -17,7 +17,7 @@ // along with mFast. If not, see . // -#include "catch.hpp" +#include #include #include #include @@ -528,12 +528,12 @@ TEST_CASE("test the encoding of fast operator copy","[operator_copy_encode_test] inst.prev_value().present(false); // // When the value is not present in the stream there are three cases depending on the state of the previous value: // // * empty – the value of the field is empty. If the field is optional the value is considered absent. It is a dynamic error [ERR D6] if the field is mandatory. - REQUIRE_THROWS_AS( encode_mref("\x80", result, CHANGE_PREVIOUS_VALUE), const mfast::fast_error& ); + REQUIRE_THROWS_AS( encode_mref("\x80", result, CHANGE_PREVIOUS_VALUE), mfast::fast_error); inst.prev_value().present(false); // // When the value is not present in the stream there are three cases depending on the state of the previous value: REQUIRE_THROWS_AS( encode_ext_cref("\x80", ext_cref(result), CHANGE_PREVIOUS_VALUE, &allocator ) - , const mfast::fast_error& ); + , mfast::fast_error ); } { @@ -687,12 +687,12 @@ TEST_CASE("test the encoding of fast operator increment","[operator_increment_en inst.prev_value().present(false); // When the value is not present in the stream there are three cases depending on the state of the previous value: // * empty – the value of the field is empty. If the field is optional the value is considered absent. It is a dynamic error [ERR D6] if the field is mandatory. - REQUIRE_THROWS_AS( encode_mref("\x80\x80", result, CHANGE_PREVIOUS_VALUE), const mfast::fast_error&); + REQUIRE_THROWS_AS( encode_mref("\x80\x80", result, CHANGE_PREVIOUS_VALUE), mfast::fast_error); inst.prev_value().present(false); REQUIRE_THROWS_AS( encode_ext_cref("\x80\x80", ext_cref(result), CHANGE_PREVIOUS_VALUE, &allocator ), - const mfast::fast_error&); + mfast::fast_error); } { @@ -983,7 +983,6 @@ TEST_CASE("test the encoding of fast no operator for ascii string", "[operator_n value_storage storage; { // testing Option assci field with no operator - const char* default_value = "initial_string"; ascii_field_instruction inst(operator_none, presence_optional, 1, diff --git a/tests/fast_istream_test.cpp b/tests/fast_istream_test.cpp index e8bd36c..ca961cd 100644 --- a/tests/fast_istream_test.cpp +++ b/tests/fast_istream_test.cpp @@ -17,7 +17,7 @@ // along with mFast. If not, see . // -#include "catch.hpp" +#include #include #include #include @@ -104,7 +104,6 @@ decode_string(const byte_stream& bs, bool nullable, const char* result, std::siz if ((str == nullptr && not_null == false) || (str && len == result_len && memcmp(str, result, len) == 0) ) return true; - bool res( false ); if (not_null) { INFO( "Got \"" << byte_stream(str, len) << "\" instead." ); } @@ -126,9 +125,9 @@ TEST_CASE("test the fast decoding of ascii string","[ascii_string_test]") REQUIRE(decode_string( "\x40\x40\xC0", true, "\x40\x40\xC0", 3)); REQUIRE(decode_string( "\x40\x40\xC0", false, "\x40\x40\xC0", 3)); - REQUIRE_THROWS_AS(decode_string("\x00\xC0", false, nullptr, 0), const mfast::fast_error& ); - REQUIRE_THROWS_AS(decode_string("\x00\xC0", true, nullptr, 0), const mfast::fast_error& ); - REQUIRE_THROWS_AS(decode_string("\x00\x00\xC0", true, nullptr, 0), const mfast::fast_error& ); + REQUIRE_THROWS_AS(decode_string("\x00\xC0", false, nullptr, 0), mfast::fast_error); + REQUIRE_THROWS_AS(decode_string("\x00\xC0", true, nullptr, 0), mfast::fast_error); + REQUIRE_THROWS_AS(decode_string("\x00\x00\xC0", true, nullptr, 0), mfast::fast_error); } bool diff --git a/tests/fast_ostream_test.cpp b/tests/fast_ostream_test.cpp index 11a6b69..bd02417 100644 --- a/tests/fast_ostream_test.cpp +++ b/tests/fast_ostream_test.cpp @@ -17,7 +17,7 @@ // along with mFast. If not, see . // -#include "catch.hpp" +#include #include #include diff --git a/tests/fast_type_gen_test.cpp b/tests/fast_type_gen_test.cpp index 4656cf9..945a9a8 100644 --- a/tests/fast_type_gen_test.cpp +++ b/tests/fast_type_gen_test.cpp @@ -4,7 +4,7 @@ // This file is part of mFAST. // See the file license.txt for licensing information. -#include "catch.hpp" +#include #include "debug_allocator.h" #include "test1.h" diff --git a/tests/field_comparator_test.cpp b/tests/field_comparator_test.cpp index e7893f3..06681e9 100644 --- a/tests/field_comparator_test.cpp +++ b/tests/field_comparator_test.cpp @@ -16,7 +16,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with mFast. If not, see . // -#include "catch.hpp" +#include #include #include diff --git a/tests/field_ref_test.cpp b/tests/field_ref_test.cpp index d4e3043..c50a445 100644 --- a/tests/field_ref_test.cpp +++ b/tests/field_ref_test.cpp @@ -18,7 +18,8 @@ // -#include "catch.hpp" +#include +#include #include #include @@ -108,7 +109,7 @@ TEST_CASE("test the operations of interger_field","[integer_field_test]") #ifndef EMSCRIPTEN { helper.save_previous_value(ref); - REQUIRE_THROWS_AS(helper.delta_base_value_of(ref), const mfast::fast_error&); + REQUIRE_THROWS_AS(helper.delta_base_value_of(ref), mfast::fast_error); } #endif { @@ -307,7 +308,7 @@ TEST_CASE("test the operations of decimal_field without mantissa instruction","[ { ref.omit(); helper.save_previous_value(ref); - REQUIRE_THROWS_AS(helper.delta_base_value_of(ref), const mfast::fast_error&); + REQUIRE_THROWS_AS(helper.delta_base_value_of(ref), mfast::fast_error); } #endif { @@ -450,7 +451,7 @@ TEST_CASE("test the operations of decimal_field with mantissa instruction","[dec x.mref ().as (9664.3); double y(x.cref()); - REQUIRE(y == Approx( 9664.3)); + REQUIRE(y == Catch::Approx( 9664.3)); x.mref ().as (0); REQUIRE(x.cref().mantissa() == 0LL); @@ -588,7 +589,7 @@ TEST_CASE("test the operations of string_field","[string_field_test]") #ifndef EMSCRIPTEN { helper.save_previous_value(ref); - REQUIRE_THROWS_AS(helper.delta_base_value_of(ref), const mfast::fast_error&); + REQUIRE_THROWS_AS(helper.delta_base_value_of(ref), mfast::fast_error); } #endif { diff --git a/tests/int_vector_test.cpp b/tests/int_vector_test.cpp index f069d90..ffb579e 100644 --- a/tests/int_vector_test.cpp +++ b/tests/int_vector_test.cpp @@ -17,7 +17,7 @@ // along with mFast. If not, see . // -#include "catch.hpp" +#include #include #include diff --git a/tests/json_test.cpp b/tests/json_test.cpp index 834510c..5663c82 100644 --- a/tests/json_test.cpp +++ b/tests/json_test.cpp @@ -16,7 +16,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with mFast. If not, see . // -#include "catch.hpp" +#include #include "test3.h" #include @@ -128,7 +128,7 @@ TEST_CASE("test json_encode with product type","[json_encode_product_test]") product_ref.omit_stock(); REQUIRE(product_ref.get_stock().absent()); - REQUIRE_THROWS_AS(product_ref.try_get_stock(), const mfast::bad_optional_access&); + REQUIRE_THROWS_AS(product_ref.try_get_stock(), mfast::bad_optional_access); } TEST_CASE("test json_encode with person type","[json_encode_person_test]") diff --git a/tests/scp_reset_test.cpp b/tests/scp_reset_test.cpp index 27003f8..693e3f1 100644 --- a/tests/scp_reset_test.cpp +++ b/tests/scp_reset_test.cpp @@ -1,4 +1,4 @@ -#include "catch.hpp" +#include #include #include #include diff --git a/tests/simple_coder_test.cpp b/tests/simple_coder_test.cpp index 6aed49c..9d0b3cf 100644 --- a/tests/simple_coder_test.cpp +++ b/tests/simple_coder_test.cpp @@ -17,7 +17,7 @@ // along with mFast. If not, see . // -#include "catch.hpp" +#include #include #include #include diff --git a/tests/test_main.cpp b/tests/test_main.cpp index 32c2645..c646c2a 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -21,4 +21,4 @@ #define CATCH_CONFIG_MAIN -#include "catch.hpp" +#include diff --git a/tests/value_storage_test.cpp b/tests/value_storage_test.cpp index 57f7ac8..3129c95 100644 --- a/tests/value_storage_test.cpp +++ b/tests/value_storage_test.cpp @@ -17,7 +17,7 @@ // along with mFast. If not, see . // -#include "catch.hpp" +#include #include using namespace mfast;