Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * This file is part of the cvc5 project. 3 : : * 4 : : * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS 5 : : * in the top-level source directory and their institutional affiliations. 6 : : * All rights reserved. See the file COPYING in the top-level source 7 : : * directory for licensing information. 8 : : * **************************************************************************** 9 : : * 10 : : * Black box testing of cvc5::Kind. 11 : : */ 12 : : 13 : : #include <iostream> 14 : : #include <sstream> 15 : : #include <string> 16 : : 17 : : #include "expr/kind.h" 18 : : #include "test.h" 19 : : 20 : : namespace cvc5::internal { 21 : : 22 : : using namespace kind; 23 : : 24 : : namespace test { 25 : : 26 : : class TestNodeBlackKind : public TestInternal 27 : : { 28 : : protected: 29 : 4 : void SetUp() override 30 : : { 31 : 4 : d_undefined = Kind::UNDEFINED_KIND; 32 : 4 : d_null = Kind::NULL_EXPR; 33 : 4 : d_last = Kind::LAST_KIND; 34 : 4 : d_beyond = ((int32_t)Kind::LAST_KIND) + 1; 35 : 4 : d_unknown = (Kind)d_beyond; 36 : 4 : } 37 : : 38 : 3 : bool string_is_as_expected(Kind k, const char* s) 39 : : { 40 : 3 : std::stringstream act; 41 : 3 : std::stringstream exp; 42 : 3 : act << k; 43 : 3 : exp << s; 44 : 6 : return act.str() == exp.str(); 45 : 3 : } 46 : : 47 : : Kind d_undefined; 48 : : Kind d_unknown; 49 : : Kind d_null; 50 : : Kind d_last; 51 : : int32_t d_beyond; 52 : : }; 53 : : 54 : 4 : TEST_F(TestNodeBlackKind, equality) 55 : : { 56 [ - + ][ + - ]: 1 : ASSERT_EQ(d_undefined, Kind::UNDEFINED_KIND); 57 [ - + ][ + - ]: 1 : ASSERT_EQ(d_last, Kind::LAST_KIND); 58 : : } 59 : : 60 : 4 : TEST_F(TestNodeBlackKind, order) 61 : : { 62 [ - + ][ + - ]: 1 : ASSERT_LT((int32_t)d_undefined, (int32_t)d_null); 63 [ - + ][ + - ]: 1 : ASSERT_LT((int32_t)d_null, (int32_t)d_last); 64 [ - + ][ + - ]: 1 : ASSERT_LT((int32_t)d_undefined, (int32_t)d_last); 65 [ - + ][ + - ]: 1 : ASSERT_LT((int32_t)d_last, (int32_t)d_unknown); 66 : : } 67 : : 68 : 4 : TEST_F(TestNodeBlackKind, output) 69 : : { 70 [ - + ][ + - ]: 1 : ASSERT_TRUE(string_is_as_expected(d_undefined, "UNDEFINED_KIND")); 71 [ - + ][ + - ]: 1 : ASSERT_TRUE(string_is_as_expected(d_null, "NULL")); 72 [ - + ][ + - ]: 1 : ASSERT_TRUE(string_is_as_expected(d_last, "LAST_KIND")); 73 : : } 74 : : 75 : 4 : TEST_F(TestNodeBlackKind, output_concat) 76 : : { 77 : 1 : std::stringstream act, exp; 78 : 1 : act << d_undefined << d_null << d_last << d_unknown; 79 : : exp << "UNDEFINED_KIND" 80 : : << "NULL" 81 : : << "LAST_KIND" 82 : 1 : << "?"; 83 [ - + ][ + - ]: 2 : ASSERT_EQ(act.str(), exp.str()); 84 [ + - ][ + - ]: 1 : } 85 : : } // namespace test 86 : : } // namespace cvc5::internal