GCC Code Coverage Report
Directory: . Exec Total Coverage
File: test/unit/theory/theory_strings_utils_white.cpp Lines: 22 22 100.0 %
Date: 2021-05-22 Branches: 50 132 37.9 %

Line Exec Source
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
23
namespace cvc5 {
24
25
using namespace kind;
26
using namespace theory;
27
using namespace theory::strings;
28
29
namespace test {
30
31
4
class TestTheoryWhiteStringsUtils : public TestNode
32
{
33
};
34
35
10
TEST_F(TestTheoryWhiteStringsUtils, collect_empty_eqs)
36
{
37
4
  TypeNode strType = d_nodeManager->stringType();
38
39
4
  Node empty = d_nodeManager->mkConst(String(""));
40
4
  Node a = d_nodeManager->mkConst(::cvc5::String("A"));
41
4
  Node x = d_nodeManager->mkVar("x", strType);
42
43
4
  Node emptyEqX = empty.eqNode(x);
44
4
  Node emptyEqA = a.eqNode(empty);
45
4
  Node xEqA = x.eqNode(a);
46
47
4
  std::vector<Node> emptyNodes;
48
  bool allEmptyEqs;
49
4
  std::unordered_set<Node> expected = {a, x};
50
51
2
  std::tie(allEmptyEqs, emptyNodes) =
52
4
      utils::collectEmptyEqs(d_nodeManager->mkNode(AND, emptyEqX, emptyEqA));
53
2
  ASSERT_TRUE(allEmptyEqs);
54
2
  ASSERT_EQ(std::unordered_set<Node>(emptyNodes.begin(), emptyNodes.end()),
55
2
            expected);
56
57
4
  std::tie(allEmptyEqs, emptyNodes) = utils::collectEmptyEqs(
58
6
      d_nodeManager->mkNode(AND, emptyEqX, xEqA, emptyEqA));
59
2
  ASSERT_FALSE(allEmptyEqs);
60
2
  ASSERT_EQ(std::unordered_set<Node>(emptyNodes.begin(), emptyNodes.end()),
61
2
            expected);
62
}
63
64
}  // namespace test
65
9256
}  // namespace cvc5