Files
spirit_x4/test/x4/eps.cpp
Nana Sakisaka 05bf2eb30b Migrate to Catch2 (#48)
* Migrate to Catch2

* Enable colors in Catch2

* CI: Cache Catch2

* Remove unused variable

* Supply compiler flags to `Catch2WithMain`

* CI: Fix Catch2 cache

* Fix styling
2025-09-25 17:26:35 +09:00

44 lines
1.3 KiB
C++

/*=============================================================================
Copyright (c) 2001-2015 Joel de Guzman
Copyright (c) 2025 Nana Sakisaka
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include "test.hpp"
#include <boost/spirit/x4/auxiliary/eps.hpp>
#include <boost/spirit/x4/operator/not_predicate.hpp>
TEST_CASE("eps")
{
using x4::eps;
{
BOOST_SPIRIT_X4_ASSERT_CONSTEXPR_CTORS(eps);
CHECK(parse("", eps));
CHECK(parse("xxx", eps).is_partial_match());
CHECK(!parse("", !eps));
}
{
// test non-lazy semantic predicate
BOOST_SPIRIT_X4_ASSERT_CONSTEXPR_CTORS(eps(true));
CHECK(parse("", eps(true)));
CHECK(!parse("", eps(false)));
CHECK(parse("", !eps(false)));
}
{
// test lazy semantic predicate
constexpr auto true_fn = [] { return true; };
constexpr auto false_Fn = [] { return false; };
BOOST_SPIRIT_X4_ASSERT_CONSTEXPR_CTORS(eps(std::true_type{}));
CHECK(parse("", eps(true_fn)));
CHECK(!parse("", eps(false_Fn)));
CHECK(parse("", !eps(false_Fn)));
}
}