Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * Top contributors (to current version): 3 : : * Aina Niemetz, Andrew Reynolds, Mathias Preiner 4 : : * 5 : : * This file is part of the cvc5 project. 6 : : * 7 : : * Copyright (c) 2009-2025 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::internal { 28 : : 29 : : using namespace theory; 30 : : using namespace theory::strings; 31 : : 32 : : namespace test { 33 : : 34 : : class TestTheoryWhiteStringsRewriter : public TestSmt 35 : : { 36 : : }; 37 : : 38 : 2 : TEST_F(TestTheoryWhiteStringsRewriter, rewrite_leq) 39 : : { 40 : 1 : Rewriter* rr = d_slvEngine->getEnv().getRewriter(); 41 : 1 : TypeNode intType = d_nodeManager->integerType(); 42 : 1 : TypeNode strType = d_nodeManager->stringType(); 43 : : 44 : 1 : Node a = d_nodeManager->mkConst(String("A")); 45 : 1 : Node bc = d_nodeManager->mkConst(String("BC")); 46 : 2 : Node x = d_nodeManager->mkVar("x", strType); 47 : 2 : Node y = d_nodeManager->mkVar("y", strType); 48 : : 49 : 2 : Node ax = d_nodeManager->mkNode(Kind::STRING_CONCAT, a, x); 50 : 2 : Node bcy = d_nodeManager->mkNode(Kind::STRING_CONCAT, bc, y); 51 : : 52 : : { 53 : 2 : Node leq = d_nodeManager->mkNode(Kind::STRING_LEQ, ax, bcy); 54 [ - + ]: 2 : ASSERT_EQ(rr->rewrite(leq), d_nodeManager->mkConst(true)); 55 : : } 56 : : 57 : : { 58 : 2 : Node leq = d_nodeManager->mkNode(Kind::STRING_LEQ, bcy, ax); 59 [ - + ]: 2 : ASSERT_EQ(rr->rewrite(leq), d_nodeManager->mkConst(false)); 60 : : } 61 : : } 62 : : 63 : : } // namespace test 64 : : } // namespace cvc5::internal