-
Notifications
You must be signed in to change notification settings - Fork 230
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
Showing
17 changed files
with
582 additions
and
213 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
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
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// 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 <tao/pegtl/buffer.hpp> | ||
|
||
namespace TAO_PEGTL_NAMESPACE | ||
{ | ||
template< typename ParseInput > | ||
void main_test( ParseInput& in ) | ||
{ | ||
in.require( 10 ); | ||
const auto m = in.rewind_position(); | ||
TAO_PEGTL_TEST_ASSERT( in.previous( m ) == in.current() ); | ||
in.consume< any >( 6 ); | ||
TAO_PEGTL_TEST_ASSERT( in.previous( m ) + 6 == in.current() ); | ||
in.rewind_to_position( m ); | ||
TAO_PEGTL_TEST_ASSERT( in.previous( m ) == in.current() ); | ||
TAO_PEGTL_TEST_ASSERT( &in.current_position() == &in.direct_position() ); | ||
TAO_PEGTL_TEST_ASSERT( in.direct_count() == in.current_position().count ); | ||
TAO_PEGTL_TEST_ASSERT( in.direct_line() == in.current_position().line ); | ||
TAO_PEGTL_TEST_ASSERT( in.direct_column() == in.current_position().column ); | ||
in.consume< alpha >( 5 ); | ||
const auto n = in.rewind_position(); | ||
in.consume< eol >( 1 ); | ||
TAO_PEGTL_TEST_ASSERT( in.direct_count() == 6 ); | ||
TAO_PEGTL_TEST_ASSERT( in.direct_line() == 2 ); | ||
TAO_PEGTL_TEST_ASSERT( in.direct_column() == 1 ); | ||
const auto p = in.previous_position( n ); | ||
TAO_PEGTL_TEST_ASSERT( p.count == 5 ); | ||
TAO_PEGTL_TEST_ASSERT( p.line == 1 ); | ||
TAO_PEGTL_TEST_ASSERT( p.column == 6 ); | ||
} | ||
|
||
void unit_test() | ||
{ | ||
dynamic_text_cstring_input<> i1( 50, 10, "input\ndata" ); | ||
main_test( i1 ); | ||
dynamic_text_cstring_input< tao_buffer_eol, std::string > i2( "source", 50, 10, "input\ndata" ); | ||
main_test( i2 ); | ||
TAO_PEGTL_TEST_ASSERT( i2.direct_source() == "source" ); | ||
} | ||
|
||
} // namespace TAO_PEGTL_NAMESPACE | ||
|
||
#include "main.hpp" |
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,33 @@ | ||
// 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 <string_view> | ||
|
||
#include "test.hpp" | ||
#include "test_utility.hpp" | ||
|
||
#include <tao/pegtl/contrib/input_with_depth.hpp> | ||
|
||
namespace TAO_PEGTL_NAMESPACE | ||
{ | ||
void unit_test() | ||
{ | ||
using input_t = input_with_depth< text_view_input< scan::lf > >; | ||
const std::string_view data = "test"; | ||
input_t in( data ); | ||
TAO_PEGTL_TEST_ASSERT( in.current() == data.data() ); | ||
TAO_PEGTL_TEST_ASSERT( in.current_depth() == 0 ); | ||
{ | ||
const auto dg = in.make_depth_guard(); | ||
TAO_PEGTL_TEST_ASSERT( in.current_depth() == 1 ); | ||
in.consume< alpha >( 2 ); | ||
TAO_PEGTL_TEST_ASSERT( in.current() == data.data() + 2 ); | ||
} | ||
TAO_PEGTL_TEST_ASSERT( in.current() == data.data() + 2 ); | ||
TAO_PEGTL_TEST_ASSERT( in.current_depth() == 0 ); | ||
} | ||
|
||
} // namespace TAO_PEGTL_NAMESPACE | ||
|
||
#include "main.hpp" |
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
Oops, something went wrong.