1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andres Noetzli |
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 |
|
* Unit tests for the string utils |
14 |
|
*/ |
15 |
|
|
16 |
|
#include <unordered_set> |
17 |
|
#include <vector> |
18 |
|
|
19 |
|
#include "expr/node.h" |
20 |
|
#include "test_node.h" |
21 |
|
#include "theory/strings/theory_strings_utils.h" |
22 |
|
#include "util/string.h" |
23 |
|
|
24 |
|
namespace cvc5 { |
25 |
|
|
26 |
|
using namespace kind; |
27 |
|
using namespace theory; |
28 |
|
using namespace theory::strings; |
29 |
|
|
30 |
|
namespace test { |
31 |
|
|
32 |
4 |
class TestTheoryWhiteStringsUtils : public TestNode |
33 |
|
{ |
34 |
|
}; |
35 |
|
|
36 |
10 |
TEST_F(TestTheoryWhiteStringsUtils, collect_empty_eqs) |
37 |
|
{ |
38 |
4 |
TypeNode strType = d_nodeManager->stringType(); |
39 |
|
|
40 |
4 |
Node empty = d_nodeManager->mkConst(String("")); |
41 |
4 |
Node a = d_nodeManager->mkConst(::cvc5::String("A")); |
42 |
4 |
Node x = d_nodeManager->mkVar("x", strType); |
43 |
|
|
44 |
4 |
Node emptyEqX = empty.eqNode(x); |
45 |
4 |
Node emptyEqA = a.eqNode(empty); |
46 |
4 |
Node xEqA = x.eqNode(a); |
47 |
|
|
48 |
4 |
std::vector<Node> emptyNodes; |
49 |
|
bool allEmptyEqs; |
50 |
4 |
std::unordered_set<Node> expected = {a, x}; |
51 |
|
|
52 |
2 |
std::tie(allEmptyEqs, emptyNodes) = |
53 |
4 |
utils::collectEmptyEqs(d_nodeManager->mkNode(AND, emptyEqX, emptyEqA)); |
54 |
2 |
ASSERT_TRUE(allEmptyEqs); |
55 |
2 |
ASSERT_EQ(std::unordered_set<Node>(emptyNodes.begin(), emptyNodes.end()), |
56 |
2 |
expected); |
57 |
|
|
58 |
4 |
std::tie(allEmptyEqs, emptyNodes) = utils::collectEmptyEqs( |
59 |
6 |
d_nodeManager->mkNode(AND, emptyEqX, xEqA, emptyEqA)); |
60 |
2 |
ASSERT_FALSE(allEmptyEqs); |
61 |
2 |
ASSERT_EQ(std::unordered_set<Node>(emptyNodes.begin(), emptyNodes.end()), |
62 |
2 |
expected); |
63 |
|
} |
64 |
|
|
65 |
|
} // namespace test |
66 |
6 |
} // namespace cvc5 |