1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
/******************************************************************************
* Top contributors (to current version):
* Aina Niemetz, Andrew Reynolds, Tim King
*
* This file is part of the cvc5 project.
*
* Copyright (c) 2009-2025 by the authors listed in the file AUTHORS
* in the top-level source directory and their institutional affiliations.
* All rights reserved. See the file COPYING in the top-level source
* directory for licensing information.
* ****************************************************************************
*
* Black box testing of cvc5::expr::NodeSelfIterator.
*/
#include "expr/node.h"
#include "expr/node_builder.h"
#include "expr/node_self_iterator.h"
#include "test_node.h"
namespace cvc5::internal {
using namespace kind;
using namespace expr;
namespace test {
class TestNodeBlackNodeSelfIterator : public TestNode
{
};
TEST_F(TestNodeBlackNodeSelfIterator, iteration)
{
Node x = d_skolemManager->mkDummySkolem("x", *d_boolTypeNode);
Node y = d_skolemManager->mkDummySkolem("y", *d_boolTypeNode);
Node x_and_y = x.andNode(y);
NodeSelfIterator i = x_and_y, j = NodeSelfIterator::self(x_and_y);
ASSERT_NE(i, x_and_y.end());
ASSERT_NE(j, x_and_y.end());
ASSERT_EQ(*i, x_and_y);
ASSERT_EQ(*j, x_and_y);
ASSERT_EQ(*i++, x_and_y);
ASSERT_EQ(*j++, x_and_y);
ASSERT_EQ(i, NodeSelfIterator::selfEnd(x_and_y));
ASSERT_EQ(j, NodeSelfIterator::selfEnd(x_and_y));
ASSERT_EQ(i, x_and_y.end());
ASSERT_EQ(j, x_and_y.end());
i = x_and_y.begin();
ASSERT_NE(i, x_and_y.end());
ASSERT_EQ(*i, x);
ASSERT_EQ(*++i, y);
ASSERT_EQ(++i, x_and_y.end());
}
} // namespace test
} // namespace cvc5::internal
|