1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Aina Niemetz |
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 strings rewriter. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include <iostream> |
17 |
|
#include <memory> |
18 |
|
#include <vector> |
19 |
|
|
20 |
|
#include "expr/node.h" |
21 |
|
#include "expr/node_manager.h" |
22 |
|
#include "test_smt.h" |
23 |
|
#include "theory/rewriter.h" |
24 |
|
#include "theory/strings/strings_rewriter.h" |
25 |
|
#include "util/string.h" |
26 |
|
|
27 |
|
namespace cvc5 { |
28 |
|
|
29 |
|
using namespace kind; |
30 |
|
using namespace theory; |
31 |
|
using namespace theory::strings; |
32 |
|
|
33 |
|
namespace test { |
34 |
|
|
35 |
4 |
class TestTheoryWhiteStringsRewriter : public TestSmt |
36 |
|
{ |
37 |
|
}; |
38 |
|
|
39 |
10 |
TEST_F(TestTheoryWhiteStringsRewriter, rewrite_leq) |
40 |
|
{ |
41 |
4 |
TypeNode intType = d_nodeManager->integerType(); |
42 |
4 |
TypeNode strType = d_nodeManager->stringType(); |
43 |
|
|
44 |
4 |
Node a = d_nodeManager->mkConst(::cvc5::String("A")); |
45 |
4 |
Node bc = d_nodeManager->mkConst(::cvc5::String("BC")); |
46 |
4 |
Node x = d_nodeManager->mkVar("x", strType); |
47 |
4 |
Node y = d_nodeManager->mkVar("y", strType); |
48 |
|
|
49 |
4 |
Node ax = d_nodeManager->mkNode(STRING_CONCAT, a, x); |
50 |
4 |
Node bcy = d_nodeManager->mkNode(STRING_CONCAT, bc, y); |
51 |
|
|
52 |
|
{ |
53 |
4 |
Node leq = d_nodeManager->mkNode(STRING_LEQ, ax, bcy); |
54 |
2 |
ASSERT_EQ(Rewriter::rewrite(leq), d_nodeManager->mkConst(true)); |
55 |
|
} |
56 |
|
|
57 |
|
{ |
58 |
4 |
Node leq = d_nodeManager->mkNode(STRING_LEQ, bcy, ax); |
59 |
2 |
ASSERT_EQ(Rewriter::rewrite(leq), d_nodeManager->mkConst(false)); |
60 |
|
} |
61 |
|
} |
62 |
|
|
63 |
|
} // namespace test |
64 |
16176 |
} // namespace cvc5 |