GCC Code Coverage Report
Directory: . Exec Total Coverage
File: test/unit/node/kind_black.cpp Lines: 32 32 100.0 %
Date: 2021-03-22 Branches: 55 190 28.9 %

Line Exec Source
1
/*********************                                                        */
2
/*! \file kind_black.cpp
3
 ** \verbatim
4
 ** Top contributors (to current version):
5
 **   Aina Niemetz
6
 ** This file is part of the CVC4 project.
7
 ** Copyright (c) 2009-2021 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.\endverbatim
11
 **
12
 ** \brief Black box testing of CVC4::Kind.
13
 **
14
 ** Black box testing of CVC4::Kind.
15
 **/
16
17
#include <iostream>
18
#include <sstream>
19
#include <string>
20
21
#include "expr/kind.h"
22
#include "test.h"
23
24
namespace CVC4 {
25
26
using namespace kind;
27
28
namespace test {
29
30
16
class TestNodeBlackKind : public TestInternal
31
{
32
 protected:
33
8
  void SetUp() override
34
  {
35
8
    d_undefined = UNDEFINED_KIND;
36
8
    d_null = NULL_EXPR;
37
8
    d_last = LAST_KIND;
38
8
    d_beyond = ((int32_t)LAST_KIND) + 1;
39
8
    d_unknown = (Kind)d_beyond;
40
8
  }
41
42
6
  bool string_is_as_expected(Kind k, const char* s)
43
  {
44
12
    std::stringstream act;
45
12
    std::stringstream exp;
46
6
    act << k;
47
6
    exp << s;
48
12
    return act.str() == exp.str();
49
  }
50
51
  Kind d_undefined;
52
  Kind d_unknown;
53
  Kind d_null;
54
  Kind d_last;
55
  int32_t d_beyond;
56
};
57
58
13
TEST_F(TestNodeBlackKind, equality)
59
{
60
2
  ASSERT_EQ(d_undefined, UNDEFINED_KIND);
61
2
  ASSERT_EQ(d_last, LAST_KIND);
62
}
63
64
13
TEST_F(TestNodeBlackKind, order)
65
{
66
2
  ASSERT_LT((int32_t)d_undefined, (int32_t)d_null);
67
2
  ASSERT_LT((int32_t)d_null, (int32_t)d_last);
68
2
  ASSERT_LT((int32_t)d_undefined, (int32_t)d_last);
69
2
  ASSERT_LT((int32_t)d_last, (int32_t)d_unknown);
70
}
71
72
13
TEST_F(TestNodeBlackKind, output)
73
{
74
2
  ASSERT_TRUE(string_is_as_expected(d_undefined, "UNDEFINED_KIND"));
75
2
  ASSERT_TRUE(string_is_as_expected(d_null, "NULL"));
76
2
  ASSERT_TRUE(string_is_as_expected(d_last, "LAST_KIND"));
77
}
78
79
13
TEST_F(TestNodeBlackKind, output_concat)
80
{
81
4
  std::stringstream act, exp;
82
2
  act << d_undefined << d_null << d_last << d_unknown;
83
  exp << "UNDEFINED_KIND"
84
      << "NULL"
85
      << "LAST_KIND"
86
2
      << "?";
87
2
  ASSERT_EQ(act.str(), exp.str());
88
}
89
}  // namespace test
90
15
}  // namespace CVC4