1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
/******************************************************************************
* Top contributors (to current version):
* Aina Niemetz, Andrew Reynolds, Mathias Preiner
*
* This file is part of the cvc5 project.
*
* Copyright (c) 2009-2025 by the authors listed in the file AUTHORS
* in the top-level source directory and their institutional affiliations.
* All rights reserved. See the file COPYING in the top-level source
* directory for licensing information.
* ****************************************************************************
*
* Unit tests for the strings rewriter.
*/
#include <iostream>
#include <memory>
#include <vector>
#include "expr/node.h"
#include "expr/node_manager.h"
#include "test_smt.h"
#include "theory/rewriter.h"
#include "theory/strings/strings_rewriter.h"
#include "util/string.h"
namespace cvc5::internal {
using namespace theory;
using namespace theory::strings;
namespace test {
class TestTheoryWhiteStringsRewriter : public TestSmt
{
};
TEST_F(TestTheoryWhiteStringsRewriter, rewrite_leq)
{
Rewriter* rr = d_slvEngine->getEnv().getRewriter();
TypeNode intType = d_nodeManager->integerType();
TypeNode strType = d_nodeManager->stringType();
Node a = d_nodeManager->mkConst(String("A"));
Node bc = d_nodeManager->mkConst(String("BC"));
Node x = d_nodeManager->mkVar("x", strType);
Node y = d_nodeManager->mkVar("y", strType);
Node ax = d_nodeManager->mkNode(Kind::STRING_CONCAT, a, x);
Node bcy = d_nodeManager->mkNode(Kind::STRING_CONCAT, bc, y);
{
Node leq = d_nodeManager->mkNode(Kind::STRING_LEQ, ax, bcy);
ASSERT_EQ(rr->rewrite(leq), d_nodeManager->mkConst(true));
}
{
Node leq = d_nodeManager->mkNode(Kind::STRING_LEQ, bcy, ax);
ASSERT_EQ(rr->rewrite(leq), d_nodeManager->mkConst(false));
}
}
} // namespace test
} // namespace cvc5::internal
|