GCC Code Coverage Report
Directory: . Exec Total Coverage
File: test/unit/printer/smt2_printer_black.cpp Lines: 20 20 100.0 %
Date: 2021-09-29 Branches: 38 84 45.2 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Aina Niemetz, 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
 * Black box testing of the SMT2 printer.
14
 */
15
16
#include <iostream>
17
18
#include "api/cpp/cvc5.h"
19
#include "expr/node.h"
20
#include "expr/node_manager.h"
21
#include "options/language.h"
22
#include "smt/smt_engine.h"
23
#include "test_smt.h"
24
#include "util/regexp.h"
25
#include "util/string.h"
26
27
namespace cvc5 {
28
29
using namespace kind;
30
31
namespace test {
32
33
8
class TestPrinterBlackSmt2 : public TestSmt
34
{
35
 protected:
36
4
  void checkToString(TNode n, const std::string& expected)
37
  {
38
8
    std::stringstream ss;
39
    ss << Node::setdepth(-1) << Node::setlanguage(Language::LANG_SMTLIB_V2_6)
40
4
       << n;
41
4
    ASSERT_EQ(ss.str(), expected);
42
  }
43
};
44
45
11
TEST_F(TestPrinterBlackSmt2, regexp_repeat)
46
{
47
2
  Node n = d_nodeManager->mkNode(
48
4
      d_nodeManager->mkConst(RegExpRepeat(5)),
49
6
      d_nodeManager->mkNode(STRING_TO_REGEXP,
50
12
                            d_nodeManager->mkConst(String("x"))));
51
2
  checkToString(n, "((_ re.^ 5) (str.to_re \"x\"))");
52
2
}
53
54
11
TEST_F(TestPrinterBlackSmt2, regexp_loop)
55
{
56
2
  Node n = d_nodeManager->mkNode(
57
4
      d_nodeManager->mkConst(RegExpLoop(1, 3)),
58
6
      d_nodeManager->mkNode(STRING_TO_REGEXP,
59
12
                            d_nodeManager->mkConst(String("x"))));
60
2
  checkToString(n, "((_ re.loop 1 3) (str.to_re \"x\"))");
61
2
}
62
}  // namespace test
63
9
}  // namespace cvc5