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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
/********************* */
/*! \file node_self_iterator_black.h
** \verbatim
** Top contributors (to current version):
** Morgan Deters, Christopher L. Conway, Tim King
** This file is part of the CVC4 project.
** Copyright (c) 2009-2020 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.\endverbatim
**
** \brief Black box testing of CVC4::expr::NodeSelfIterator
**
** Black box testing of CVC4::expr::NodeSelfIterator
**/
#include <cxxtest/TestSuite.h>
#include "expr/node.h"
#include "expr/node_self_iterator.h"
#include "expr/node_builder.h"
using namespace CVC4;
using namespace CVC4::kind;
using namespace CVC4::expr;
using namespace std;
class NodeSelfIteratorBlack : public CxxTest::TestSuite {
private:
NodeManager* d_nodeManager;
NodeManagerScope* d_scope;
TypeNode* d_booleanType;
TypeNode* d_realType;
public:
void setUp() override
{
d_nodeManager = new NodeManager(NULL);
d_scope = new NodeManagerScope(d_nodeManager);
d_booleanType = new TypeNode(d_nodeManager->booleanType());
d_realType = new TypeNode(d_nodeManager->realType());
}
void tearDown() override
{
delete d_booleanType;
delete d_scope;
delete d_nodeManager;
}
void testSelfIteration() {
Node x = d_nodeManager->mkSkolem("x", *d_booleanType);
Node y = d_nodeManager->mkSkolem("y", *d_booleanType);
Node x_and_y = x.andNode(y);
NodeSelfIterator i = x_and_y, j = NodeSelfIterator::self(x_and_y);
TS_ASSERT(i != x_and_y.end());
TS_ASSERT(j != x_and_y.end());
TS_ASSERT(*i == x_and_y);
TS_ASSERT(*j == x_and_y);
TS_ASSERT(*i++ == x_and_y);
TS_ASSERT(*j++ == x_and_y);
TS_ASSERT(i == NodeSelfIterator::selfEnd(x_and_y));
TS_ASSERT(j == NodeSelfIterator::selfEnd(x_and_y));
TS_ASSERT(i == x_and_y.end());
TS_ASSERT(j == x_and_y.end());
i = x_and_y.begin();
TS_ASSERT(i != x_and_y.end());
TS_ASSERT(*i == x);
TS_ASSERT(*++i == y);
TS_ASSERT(++i == x_and_y.end());
}
};
|