Skip to content

Commit

Permalink
New testcase.
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinH committed Dec 1, 2024
1 parent 513a4d1 commit 58ed294
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/test/pegtl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ set(test_sources
buffer_cstring_input.cpp
buffer_discard_input.cpp
buffer_dynamic_buffer.cpp
buffer_endless_input.cpp
buffer_istream_input.cpp
buffer_rule_discard.cpp
buffer_rule_is_buffer.cpp
Expand Down
42 changes: 42 additions & 0 deletions src/test/pegtl/buffer_endless_input.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// 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>

#include "test.hpp"

#include <tao/pegtl/buffer.hpp>

namespace TAO_PEGTL_NAMESPACE
{
void test_single()
{
static_endless_input< void > in( 'a' );

for( std::size_t i = 0; i < 42; ++i ) {
TAO_PEGTL_TEST_ASSERT( parse< rep< 3000, one< 'a' > > >( in ) );
TAO_PEGTL_TEST_ASSERT( parse< discard >( in ) );
}
}

void test_multiple()
{
static_endless_input< void > in( "abc" );
TAO_PEGTL_TEST_ASSERT( parse< not_at< eof > >( in ) );

for( std::size_t i = 0; i < 42; ++i ) {
TAO_PEGTL_TEST_ASSERT( parse< rep< 1000, string< 'a', 'b', 'c' > > >( in ) );
TAO_PEGTL_TEST_ASSERT( parse< discard >( in ) );
}
}

void unit_test()
{
test_single();
test_multiple();
}

} // namespace TAO_PEGTL_NAMESPACE

#include "main.hpp"

0 comments on commit 58ed294

Please sign in to comment.