1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Aina Niemetz, Andres Noetzli, Andrew Reynolds |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 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. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* White box testing of cvc5::NodeManager. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include <string> |
17 |
|
|
18 |
|
#include "expr/node_manager.h" |
19 |
|
#include "test_node.h" |
20 |
|
#include "util/integer.h" |
21 |
|
#include "util/rational.h" |
22 |
|
|
23 |
|
namespace cvc5 { |
24 |
|
|
25 |
|
using namespace cvc5::expr; |
26 |
|
|
27 |
|
namespace test { |
28 |
|
|
29 |
12 |
class TestNodeWhiteNodeManager : public TestNode |
30 |
|
{ |
31 |
|
}; |
32 |
|
|
33 |
12 |
TEST_F(TestNodeWhiteNodeManager, mkConst_rational) |
34 |
|
{ |
35 |
4 |
Rational i("3"); |
36 |
4 |
Node n = d_nodeManager->mkConst(i); |
37 |
4 |
Node m = d_nodeManager->mkConst(i); |
38 |
2 |
ASSERT_EQ(n.getId(), m.getId()); |
39 |
|
} |
40 |
|
|
41 |
12 |
TEST_F(TestNodeWhiteNodeManager, oversized_node_builder) |
42 |
|
{ |
43 |
4 |
NodeBuilder nb; |
44 |
|
|
45 |
2 |
ASSERT_NO_THROW(nb.realloc(15)); |
46 |
2 |
ASSERT_NO_THROW(nb.realloc(25)); |
47 |
2 |
ASSERT_NO_THROW(nb.realloc(256)); |
48 |
|
#ifdef CVC5_ASSERTIONS |
49 |
2 |
ASSERT_DEATH(nb.realloc(100), "toSize > d_nvMaxChildren"); |
50 |
|
#endif /* CVC5_ASSERTIONS */ |
51 |
2 |
ASSERT_NO_THROW(nb.realloc(257)); |
52 |
2 |
ASSERT_NO_THROW(nb.realloc(4000)); |
53 |
2 |
ASSERT_NO_THROW(nb.realloc(20000)); |
54 |
2 |
ASSERT_NO_THROW(nb.realloc(60000)); |
55 |
2 |
ASSERT_NO_THROW(nb.realloc(65535)); |
56 |
2 |
ASSERT_NO_THROW(nb.realloc(65536)); |
57 |
2 |
ASSERT_NO_THROW(nb.realloc(67108863)); |
58 |
|
#ifdef CVC5_ASSERTIONS |
59 |
2 |
ASSERT_DEATH(nb.realloc(67108863), "toSize > d_nvMaxChildren"); |
60 |
|
#endif /* CVC5_ASSERTIONS */ |
61 |
|
} |
62 |
|
|
63 |
12 |
TEST_F(TestNodeWhiteNodeManager, topological_sort) |
64 |
|
{ |
65 |
4 |
TypeNode boolType = d_nodeManager->booleanType(); |
66 |
4 |
Node i = d_skolemManager->mkDummySkolem("i", boolType); |
67 |
4 |
Node j = d_skolemManager->mkDummySkolem("j", boolType); |
68 |
4 |
Node n1 = d_nodeManager->mkNode(kind::AND, j, j); |
69 |
4 |
Node n2 = d_nodeManager->mkNode(kind::AND, i, n1); |
70 |
|
|
71 |
|
{ |
72 |
4 |
std::vector<NodeValue*> roots = {n1.d_nv}; |
73 |
2 |
ASSERT_EQ(NodeManager::TopologicalSort(roots), roots); |
74 |
|
} |
75 |
|
|
76 |
|
{ |
77 |
4 |
std::vector<NodeValue*> roots = {n2.d_nv, n1.d_nv}; |
78 |
4 |
std::vector<NodeValue*> result = {n1.d_nv, n2.d_nv}; |
79 |
2 |
ASSERT_EQ(NodeManager::TopologicalSort(roots), result); |
80 |
|
} |
81 |
|
} |
82 |
|
} // namespace test |
83 |
25558 |
} // namespace cvc5 |