GCC Code Coverage Report
Directory: . Exec Total Coverage
File: test/unit/api/solver_white.cpp Lines: 21 21 100.0 %
Date: 2021-09-18 Branches: 55 134 41.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Aina Niemetz, Makai Mann, Andrew Reynolds
4
 *
5
 * This file is part of the cvc5 project.
6
 *
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.
11
 * ****************************************************************************
12
 *
13
 * Black box testing of the Solver class of the  C++ API.
14
 */
15
16
#include "base/configuration.h"
17
#include "test_api.h"
18
19
namespace cvc5 {
20
21
using namespace api;
22
23
namespace test {
24
25
4
class TestApiWhiteSolver : public TestApi
26
{
27
};
28
29
10
TEST_F(TestApiWhiteSolver, getOp)
30
{
31
4
  DatatypeDecl consListSpec = d_solver.mkDatatypeDecl("list");
32
4
  DatatypeConstructorDecl cons = d_solver.mkDatatypeConstructorDecl("cons");
33
2
  cons.addSelector("head", d_solver.getIntegerSort());
34
2
  cons.addSelectorSelf("tail");
35
2
  consListSpec.addConstructor(cons);
36
4
  DatatypeConstructorDecl nil = d_solver.mkDatatypeConstructorDecl("nil");
37
2
  consListSpec.addConstructor(nil);
38
4
  Sort consListSort = d_solver.mkDatatypeSort(consListSpec);
39
4
  Datatype consList = consListSort.getDatatype();
40
41
4
  Term nilTerm = consList.getConstructorTerm("nil");
42
4
  Term consTerm = consList.getConstructorTerm("cons");
43
4
  Term headTerm = consList["cons"].getSelectorTerm("head");
44
45
4
  Term listnil = d_solver.mkTerm(APPLY_CONSTRUCTOR, nilTerm);
46
  Term listcons1 = d_solver.mkTerm(
47
4
      APPLY_CONSTRUCTOR, consTerm, d_solver.mkInteger(1), listnil);
48
4
  Term listhead = d_solver.mkTerm(APPLY_SELECTOR, headTerm, listcons1);
49
50
2
  ASSERT_EQ(listnil.getOp(), Op(&d_solver, APPLY_CONSTRUCTOR));
51
2
  ASSERT_EQ(listcons1.getOp(), Op(&d_solver, APPLY_CONSTRUCTOR));
52
2
  ASSERT_EQ(listhead.getOp(), Op(&d_solver, APPLY_SELECTOR));
53
}
54
55
}  // namespace test
56
6
}  // namespace cvc5