Branch data Line data Source code
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-2024 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 cvc5::Kind. 14 : : */ 15 : : 16 : : #include <iostream> 17 : : #include <sstream> 18 : : #include <string> 19 : : 20 : : #include "expr/kind.h" 21 : : #include "test.h" 22 : : 23 : : namespace cvc5::internal { 24 : : 25 : : using namespace kind; 26 : : 27 : : namespace test { 28 : : 29 : : class TestNodeBlackKind : public TestInternal 30 : : { 31 : : protected: 32 : 4 : void SetUp() override 33 : : { 34 : 4 : d_undefined = Kind::UNDEFINED_KIND; 35 : 4 : d_null = Kind::NULL_EXPR; 36 : 4 : d_last = Kind::LAST_KIND; 37 : 4 : d_beyond = ((int32_t)Kind::LAST_KIND) + 1; 38 : 4 : d_unknown = (Kind)d_beyond; 39 : 4 : } 40 : : 41 : 3 : bool string_is_as_expected(Kind k, const char* s) 42 : : { 43 : 6 : std::stringstream act; 44 : 3 : std::stringstream exp; 45 : 3 : act << k; 46 : 3 : exp << s; 47 : 6 : return act.str() == exp.str(); 48 : : } 49 : : 50 : : Kind d_undefined; 51 : : Kind d_unknown; 52 : : Kind d_null; 53 : : Kind d_last; 54 : : int32_t d_beyond; 55 : : }; 56 : : 57 : 2 : TEST_F(TestNodeBlackKind, equality) 58 : : { 59 [ - + ]: 1 : ASSERT_EQ(d_undefined, Kind::UNDEFINED_KIND); 60 [ - + ]: 1 : ASSERT_EQ(d_last, Kind::LAST_KIND); 61 : : } 62 : : 63 : 2 : TEST_F(TestNodeBlackKind, order) 64 : : { 65 [ - + ]: 1 : ASSERT_LT((int32_t)d_undefined, (int32_t)d_null); 66 [ - + ]: 1 : ASSERT_LT((int32_t)d_null, (int32_t)d_last); 67 [ - + ]: 1 : ASSERT_LT((int32_t)d_undefined, (int32_t)d_last); 68 [ - + ]: 1 : ASSERT_LT((int32_t)d_last, (int32_t)d_unknown); 69 : : } 70 : : 71 : 2 : TEST_F(TestNodeBlackKind, output) 72 : : { 73 [ - + ]: 1 : ASSERT_TRUE(string_is_as_expected(d_undefined, "UNDEFINED_KIND")); 74 [ - + ]: 1 : ASSERT_TRUE(string_is_as_expected(d_null, "NULL")); 75 [ - + ]: 1 : ASSERT_TRUE(string_is_as_expected(d_last, "LAST_KIND")); 76 : : } 77 : : 78 : 2 : TEST_F(TestNodeBlackKind, output_concat) 79 : : { 80 : 1 : std::stringstream act, exp; 81 : 1 : act << d_undefined << d_null << d_last << d_unknown; 82 : : exp << "UNDEFINED_KIND" 83 : : << "NULL" 84 : : << "LAST_KIND" 85 : 1 : << "?"; 86 [ - + ]: 2 : ASSERT_EQ(act.str(), exp.str()); 87 : : } 88 : : } // namespace test 89 : : } // namespace cvc5::internal