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