From 3d97f7c7223cea8070a23256770b5537e60466cf Mon Sep 17 00:00:00 2001 From: "Dr. Colin Hirsch" Date: Mon, 9 Dec 2024 20:21:40 +0100 Subject: [PATCH] Improve test coverage. --- .../tao/pegtl/internal/mmap_file_posix.hpp | 5 - .../tao/pegtl/internal/mmap_file_win32.hpp | 5 - src/test/pegtl/CMakeLists.txt | 1 + src/test/pegtl/debug_coverage.cpp | 10 +- src/test/pegtl/internal_constexpr.cpp | 173 ++++++++++++++++++ src/test/pegtl/internal_file_mapper.cpp | 45 ++--- src/test/pegtl/internal_file_opener.cpp | 39 ---- src/test/pegtl/internal_lazy_scan_traits.cpp | 7 +- src/test/pegtl/internal_mmap_input.cpp | 19 +- src/test/pegtl/mmap_input.cpp | 19 +- 10 files changed, 226 insertions(+), 97 deletions(-) create mode 100644 src/test/pegtl/internal_constexpr.cpp delete mode 100644 src/test/pegtl/internal_file_opener.cpp diff --git a/include/tao/pegtl/internal/mmap_file_posix.hpp b/include/tao/pegtl/internal/mmap_file_posix.hpp index 492046319..7e257e717 100644 --- a/include/tao/pegtl/internal/mmap_file_posix.hpp +++ b/include/tao/pegtl/internal/mmap_file_posix.hpp @@ -122,11 +122,6 @@ namespace TAO_PEGTL_NAMESPACE::internal mmap_file_posix& operator=( const mmap_file_posix& ) = delete; mmap_file_posix& operator=( mmap_file_posix&& ) = delete; - [[nodiscard]] bool empty() const noexcept - { - return m_size == 0; - } - [[nodiscard]] std::size_t size() const noexcept { return m_size; diff --git a/include/tao/pegtl/internal/mmap_file_win32.hpp b/include/tao/pegtl/internal/mmap_file_win32.hpp index 37039d09d..929c4790c 100644 --- a/include/tao/pegtl/internal/mmap_file_win32.hpp +++ b/include/tao/pegtl/internal/mmap_file_win32.hpp @@ -207,11 +207,6 @@ namespace TAO_PEGTL_NAMESPACE::internal mmap_file_win32& operator=( const mmap_file_win32& ) = delete; mmap_file_win32& operator=( mmap_file_win32&& ) = delete; - [[nodiscard]] bool empty() const noexcept - { - return m_size == 0; - } - [[nodiscard]] std::size_t size() const noexcept { return m_size; diff --git a/src/test/pegtl/CMakeLists.txt b/src/test/pegtl/CMakeLists.txt index 6b1b57cf9..b486daf42 100644 --- a/src/test/pegtl/CMakeLists.txt +++ b/src/test/pegtl/CMakeLists.txt @@ -103,6 +103,7 @@ set(test_sources internal_base_inputs.cpp internal_byteswap.cpp internal_char_scan_traits.cpp + internal_constexpr.cpp internal_copy_input.cpp internal_data_and_size.cpp internal_endian.cpp diff --git a/src/test/pegtl/debug_coverage.cpp b/src/test/pegtl/debug_coverage.cpp index 37c240d06..0308079d8 100644 --- a/src/test/pegtl/debug_coverage.cpp +++ b/src/test/pegtl/debug_coverage.cpp @@ -25,7 +25,7 @@ namespace TAO_PEGTL_NAMESPACE } #if defined( __cpp_exceptions ) - using grammar = seq< sor< try_catch_return_false< must< one< 'a' > > >, one< 'F' > >, eof >; + using grammar = seq< sor< try_catch_return_false< must< one< 'a' > > >, seq< at< one< 'F' > >, one< 'F' > >, digit >, eof >; void unit_test() { @@ -35,14 +35,16 @@ namespace TAO_PEGTL_NAMESPACE const bool success = coverage< grammar >( in, result ); std::cout << result; // To manually see that printing does the right thing, too. TAO_PEGTL_TEST_ASSERT( success ); - TAO_PEGTL_TEST_ASSERT( result.coverage.size() == 7 ); + TAO_PEGTL_TEST_ASSERT( result.coverage.size() == 10 ); TAO_PEGTL_TEST_ASSERT( equals< grammar >( result, coverage_info{ 1, 1, 0, 0, 0 } ) ); TAO_PEGTL_TEST_ASSERT( equals< one< 'a' > >( result, coverage_info{ 1, 0, 1, 0, 1 } ) ); // TODO: Should this really be counted as both failure and raise? - TAO_PEGTL_TEST_ASSERT( equals< one< 'F' > >( result, coverage_info{ 1, 1, 0, 0, 0 } ) ); + TAO_PEGTL_TEST_ASSERT( equals< one< 'F' > >( result, coverage_info{ 2, 2, 0, 0, 0 } ) ); + TAO_PEGTL_TEST_ASSERT( equals< at< one< 'F' > > >( result, coverage_info{ 1, 1, 0, 0, 0 } ) ); TAO_PEGTL_TEST_ASSERT( equals< eof >( result, coverage_info{ 1, 1, 0, 0, 0 } ) ); TAO_PEGTL_TEST_ASSERT( equals< try_catch_return_false< must< one< 'a' > > > >( result, coverage_info{ 1, 0, 1, 0, 0 } ) ); TAO_PEGTL_TEST_ASSERT( equals< must< one< 'a' > > >( result, coverage_info{ 1, 0, 0, 1, 0 } ) ); - TAO_PEGTL_TEST_ASSERT( equals< sor< try_catch_return_false< must< one< 'a' > > >, one< 'F' > > >( result, coverage_info{ 1, 1, 0, 0, 0 } ) ); + TAO_PEGTL_TEST_ASSERT( equals< digit >( result, coverage_info{ 0, 0, 0, 0, 0 } ) ); + TAO_PEGTL_TEST_ASSERT( equals< sor< try_catch_return_false< must< one< 'a' > > >, seq< at< one< 'F' > >, one< 'F' > >, digit > >( result, coverage_info{ 1, 1, 0, 0, 0 } ) ); } #else using grammar = seq< sor< one< 'a' >, one< 'F' > >, eof >; diff --git a/src/test/pegtl/internal_constexpr.cpp b/src/test/pegtl/internal_constexpr.cpp new file mode 100644 index 000000000..6a8dd6c3d --- /dev/null +++ b/src/test/pegtl/internal_constexpr.cpp @@ -0,0 +1,173 @@ +// Copyright (c) 2024 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#include "test.hpp" + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +namespace TAO_PEGTL_NAMESPACE +{ + struct foo + { + int bar; + }; + + void unit_test() + { + using in8 = internal::view_input< std::uint8_t >; + using in16 = internal::view_input< std::uint16_t >; + using in32 = internal::view_input< std::uint32_t >; + using in64 = internal::view_input< std::uint64_t >; + + TAO_PEGTL_TEST_ASSERT( internal::peek_char::bulk< in8 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_char::size< in8 >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_seven::bulk< in8 >() == false ); + TAO_PEGTL_TEST_ASSERT( internal::peek_seven::size< in8 >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_utf8::bulk< in8 >() == false ); + TAO_PEGTL_TEST_ASSERT( internal::peek_utf8::size< in8 >() == 0 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_utf16_be::bulk< in8 >() == false ); + TAO_PEGTL_TEST_ASSERT( internal::peek_utf16_be::size< in8 >() == 0 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_utf16_le::bulk< in16 >() == false ); + TAO_PEGTL_TEST_ASSERT( internal::peek_utf16_le::size< in16 >() == 0 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_utf32_be::bulk< in8 >() == false ); + TAO_PEGTL_TEST_ASSERT( internal::peek_utf32_be::size< in8 >() == 4 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_utf32_le::bulk< in32 >() == false ); + TAO_PEGTL_TEST_ASSERT( internal::peek_utf32_le::size< in32 >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_int8::bulk< in8 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_int8::size< in8 >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_int16_be::bulk< in8 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_int16_be::size< in8 >() == 2 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_int16_le::bulk< in16 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_int16_le::size< in16 >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_int32_be::bulk< in8 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_int32_be::size< in8 >() == 4 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_int32_le::bulk< in32 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_int32_le::size< in32 >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_int64_be::bulk< in8 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_int64_be::size< in8 >() == 8 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_int64_le::bulk< in64 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_int64_le::size< in64 >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_uint8::bulk< in8 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_uint8::size< in8 >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_uint16_be::bulk< in8 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_uint16_be::size< in8 >() == 2 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_uint16_le::bulk< in16 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_uint16_le::size< in16 >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_uint32_be::bulk< in8 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_uint32_be::size< in8 >() == 4 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_uint32_le::bulk< in32 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_uint32_le::size< in32 >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_uint64_be::bulk< in8 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_uint64_be::size< in8 >() == 8 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_uint64_le::bulk< in64 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_uint64_le::size< in64 >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_int8< 42 >::bulk< in8 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_int8< 43 >::size< in8 >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_int16_be< 42 >::bulk< in8 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_int16_be< 43 >::size< in8 >() == 2 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_int16_le< 42 >::bulk< in16 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_int16_le< 43 >::size< in16 >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_int32_be< 42 >::bulk< in8 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_int32_be< 43 >::size< in8 >() == 4 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_int32_le< 42 >::bulk< in32 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_int32_le< 43 >::size< in32 >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_int64_be< 42 >::bulk< in8 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_int64_be< 43 >::size< in8 >() == 8 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_int64_le< 42 >::bulk< in64 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_int64_le< 43 >::size< in64 >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_uint8< 42 >::bulk< in8 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_uint8< 43 >::size< in8 >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_uint16_be< 42 >::bulk< in8 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_uint16_be< 43 >::size< in8 >() == 2 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_uint16_le< 42 >::bulk< in16 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_uint16_le< 43 >::size< in16 >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_uint32_be< 42 >::bulk< in8 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_uint32_be< 43 >::size< in8 >() == 4 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_uint32_le< 42 >::bulk< in32 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_uint32_le< 43 >::size< in32 >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_uint64_be< 42 >::bulk< in8 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_uint64_be< 43 >::size< in8 >() == 8 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_uint64_le< 42 >::bulk< in64 >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_mask_uint64_le< 43 >::size< in64 >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::peek_member< &foo::bar >::bulk< void >() == true ); + TAO_PEGTL_TEST_ASSERT( internal::peek_member< &foo::bar >::size< void >() == 1 ); + + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_1( 0x0000 ) == true ); + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_1( 0x007f ) == true ); + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_1( 0x0080 ) == false ); + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_1( 0xffff ) == false ); + + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_2( 0x007f ) == false ); + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_2( 0x0080 ) == true ); + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_2( 0x07ff ) == true ); + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_2( 0x0800 ) == false ); + + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_3( 0x007ff ) == false ); + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_3( 0x00800 ) == true ); + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_3( 0x0ffff ) == true ); + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_3( 0x10000 ) == false ); + + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_3( 0x0d7ff ) == true ); + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_3( 0x0d800 ) == false ); + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_3( 0x0dfff ) == false ); + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_3( 0x0e000 ) == true ); + + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_4( 0x00ffff ) == false ); + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_4( 0x010000 ) == true ); + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_4( 0x10ffff ) == true ); + TAO_PEGTL_TEST_ASSERT( internal::has_utf8_length_4( 0x110000 ) == false ); + } + +} // namespace TAO_PEGTL_NAMESPACE + +#include "main.hpp" diff --git a/src/test/pegtl/internal_file_mapper.cpp b/src/test/pegtl/internal_file_mapper.cpp index 5fa649239..ba3519ad8 100644 --- a/src/test/pegtl/internal_file_mapper.cpp +++ b/src/test/pegtl/internal_file_mapper.cpp @@ -2,50 +2,37 @@ // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) -#if !defined( __cpp_exceptions ) || !defined( _POSIX_MAPPED_FILES ) -#include -int main() -{ - std::cout << "Exception support disabled, skipping test..." << std::endl; -} -#else - -#include - #include "test.hpp" +#if defined( __cpp_exceptions ) && defined( _POSIX_MAPPED_FILES ) + namespace TAO_PEGTL_NAMESPACE { void unit_test() { - try { - internal::file_mapper dummy( "include" ); - // LCOV_EXCL_START - std::cerr << "pegtl: unit test failed for [ internal::file_mapper ]" << std::endl; - ++failed; - // LCOV_EXCL_STOP - } - catch( const std::filesystem::filesystem_error& ) { - } - // LCOV_EXCL_START - catch( ... ) { - std::cerr << "pegtl: unit test failed for [ internal::file_mapper ] with unexpected exception" << std::endl; - ++failed; - } - // LCOV_EXCL_STOP + TAO_PEGTL_TEST_THROWS( internal::mmap_file_impl( "include" ) ); const std::string s = "dummy content\n"; const std::string dummy_content = s + s + s + s + s + s + s + s + s + s + s; - internal::file_mapper mapper( "src/test/pegtl/data/test_data.txt" ); - TAO_PEGTL_TEST_ASSERT( !mapper.empty() ); + internal::mmap_file_impl mapper( "src/test/pegtl/data/test_data.txt" ); TAO_PEGTL_TEST_ASSERT( mapper.size() == 154 ); TAO_PEGTL_TEST_ASSERT( std::string_view( mapper.data(), mapper.size() ) == dummy_content ); - TAO_PEGTL_TEST_ASSERT( std::string_view( mapper.begin(), mapper.end() - mapper.begin() ) == dummy_content ); } } // namespace TAO_PEGTL_NAMESPACE -#include "main.hpp" +#else + +namespace TAO_PEGTL_NAMESPACE +{ + void unit_test() + { + std::cerr << "Skipping mmap test..." << std::endl; + } + +} // namespace TAO_PEGTL_NAMESPACE #endif + +#include "main.hpp" diff --git a/src/test/pegtl/internal_file_opener.cpp b/src/test/pegtl/internal_file_opener.cpp deleted file mode 100644 index e742509f6..000000000 --- a/src/test/pegtl/internal_file_opener.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2015-2024 Dr. Colin Hirsch and Daniel Frey -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) - -#if !defined( __cpp_exceptions ) || !defined( _POSIX_MAPPED_FILES ) -#include -int main() -{ - std::cout << "Exception support disabled, skipping test..." << std::endl; -} -#else - -#include - -#include "test.hpp" - -namespace TAO_PEGTL_NAMESPACE -{ - void unit_test() - { - const internal::file_opener fo( "Makefile" ); - ::close( fo.m_fd ); // Provoke exception, nobody would normally do this. - try { - (void)fo.size(); // expected to throw - - // LCOV_EXCL_START - std::cerr << "pegtl: unit test failed for [ internal::file_opener ] " << std::endl; - ++failed; - // LCOV_EXCL_STOP - } - catch( const std::exception& ) { - } - } - -} // namespace TAO_PEGTL_NAMESPACE - -#include "main.hpp" - -#endif diff --git a/src/test/pegtl/internal_lazy_scan_traits.cpp b/src/test/pegtl/internal_lazy_scan_traits.cpp index 9d50db5a6..dfd0ebfde 100644 --- a/src/test/pegtl/internal_lazy_scan_traits.cpp +++ b/src/test/pegtl/internal_lazy_scan_traits.cpp @@ -21,7 +21,7 @@ namespace TAO_PEGTL_NAMESPACE { text_position pos; internal::scan_input< char > in( str.data(), str.size() ); - internal::lazy_scan_traits< typename Eol::rule_t, internal::peek_char >::scan( pos, in ); + internal::lazy_scan_traits< typename Eol::rule_t, internal::peek_seven >::scan( pos, in ); TAO_PEGTL_TEST_ASSERT( test::equal( pos, line, column, count ) ); } @@ -77,6 +77,11 @@ namespace TAO_PEGTL_NAMESPACE lazy_test< ascii::lf_crlf >( "\n\r", 2, 2, 2 ); lazy_test< ascii::lf_crlf >( "\r\n", 2, 1, 2 ); lazy_test< ascii::lf_crlf >( " \r\n ", 2, 3, 6 ); + +#if defined( __cpp_exceptions ) + const auto c = char( 0x80 ); + TAO_PEGTL_TEST_THROWS( lazy_test< ascii::lf_crlf >( std::string( c, 1 ), 0, 0, 0 ) ); +#endif } } // namespace TAO_PEGTL_NAMESPACE diff --git a/src/test/pegtl/internal_mmap_input.cpp b/src/test/pegtl/internal_mmap_input.cpp index 3deb932e7..c70af87ed 100644 --- a/src/test/pegtl/internal_mmap_input.cpp +++ b/src/test/pegtl/internal_mmap_input.cpp @@ -2,16 +2,17 @@ // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) +#include "test.hpp" + #if defined( _POSIX_MAPPED_FILES ) || defined( _WIN32 ) -#include "test.hpp" #include "verify_file.hpp" namespace TAO_PEGTL_NAMESPACE { void unit_test() { - TAO_PEGTL_TEST_THROWS( internal::mmap_input< std::size_t > in( "src/test/pegtl/data/duseltronik.txt" ) ); + TAO_PEGTL_TEST_THROWS( internal::mmap_input< std::size_t >( "src/test/pegtl/data/duseltronik.txt" ) ); const internal::mmap_input< char > in( "src/test/pegtl/data/duseltronik.txt" ); const std::string data( in.start(), in.end() ); TAO_PEGTL_TEST_ASSERT( data == "duseltronik" ); @@ -19,13 +20,17 @@ namespace TAO_PEGTL_NAMESPACE } // namespace TAO_PEGTL_NAMESPACE -#include "main.hpp" - #else -int main() +namespace TAO_PEGTL_NAMESPACE { - return 0; -} + void unit_test() + { + std::cerr << "Skipping mmap test..." << std::endl; + } + +} // namespace TAO_PEGTL_NAMESPACE #endif + +#include "main.hpp" diff --git a/src/test/pegtl/mmap_input.cpp b/src/test/pegtl/mmap_input.cpp index aea43836e..e909198fb 100644 --- a/src/test/pegtl/mmap_input.cpp +++ b/src/test/pegtl/mmap_input.cpp @@ -2,11 +2,12 @@ // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) -#if defined( _POSIX_MAPPED_FILES ) || defined( _WIN32 ) - #include #include "test.hpp" + +#if defined( _POSIX_MAPPED_FILES ) || defined( _WIN32 ) + #include "verify_file.hpp" namespace TAO_PEGTL_NAMESPACE @@ -25,13 +26,17 @@ namespace TAO_PEGTL_NAMESPACE } // namespace TAO_PEGTL_NAMESPACE -#include "main.hpp" - #else -int main() +namespace TAO_PEGTL_NAMESPACE { - return 0; -} + void unit_test() + { + std::cerr << "Skipping mmap test..." << std::endl; + } + +} // namespace TAO_PEGTL_NAMESPACE #endif + +#include "main.hpp"