1 /********************* */
2 /*! \file node_white.cpp
4 ** Top contributors (to current version):
5 ** Aina Niemetz, Morgan Deters
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS
8 ** in the top-level source directory and their institutional affiliations.
9 ** All rights reserved. See the file COPYING in the top-level source
10 ** directory for licensing information.\endverbatim
12 ** \brief White box testing of CVC4::Node.
14 ** White box testing of CVC4::Node.
19 #include "base/check.h"
20 #include "test_node.h"
29 class TestNodeWhiteNode
: public TestNodeWhite
33 TEST_F(TestNodeWhiteNode
, null
) { ASSERT_EQ(Node::null(), Node::s_null
); }
35 TEST_F(TestNodeWhiteNode
, copy_ctor
) { Node
e(Node::s_null
); }
37 TEST_F(TestNodeWhiteNode
, builder
)
40 ASSERT_TRUE(b
.d_nv
->getId() == 0);
41 ASSERT_TRUE(b
.d_nv
->getKind() == UNDEFINED_KIND
);
42 ASSERT_EQ(b
.d_nv
->d_nchildren
, 0u);
46 TEST_F(TestNodeWhiteNode
, iterators
)
48 Node x
= d_nodeManager
->mkVar("x", d_nodeManager
->integerType());
49 Node y
= d_nodeManager
->mkVar("y", d_nodeManager
->integerType());
50 Node x_plus_y
= d_nodeManager
->mkNode(PLUS
, x
, y
);
51 Node two
= d_nodeManager
->mkConst(Rational(2));
52 Node x_times_2
= d_nodeManager
->mkNode(MULT
, x
, two
);
54 Node n
= d_nodeManager
->mkNode(PLUS
, x_times_2
, x_plus_y
, y
);
58 i
= std::find(n
.begin(), n
.end(), x_plus_y
);
59 ASSERT_TRUE(i
!= n
.end());
60 ASSERT_TRUE(*i
== x_plus_y
);
62 i
= std::find(n
.begin(), n
.end(), x
);
63 ASSERT_TRUE(i
== n
.end());
65 i
= std::find(x_times_2
.begin(), x_times_2
.end(), two
);
66 ASSERT_TRUE(i
!= x_times_2
.end());
67 ASSERT_TRUE(*i
== two
);
69 i
= std::find(n
.begin(), n
.end(), y
);
70 ASSERT_TRUE(i
!= n
.end());
74 copy(n
.begin(), n
.end(), back_inserter(v
));
75 ASSERT_EQ(n
.getNumChildren(), v
.size());
76 ASSERT_EQ(3, v
.size());
77 ASSERT_EQ(v
[0], x_times_2
);
78 ASSERT_EQ(v
[1], x_plus_y
);