1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/********************* */
/*! \file lfsc_proof_printer_black.h
** \verbatim
** Top contributors (to current version):
** Alex Ozdemir
** This file is part of the CVC4 project.
** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS
** in the top-level source directory) and their institutional affiliations.
** All rights reserved. See the file COPYING in the top-level source
** directory for licensing information.\endverbatim
**
** \brief Black box testing of LFSC proof printing
**/
#include <cxxtest/TestSuite.h>
#include "proof/lfsc_proof_printer.h"
#include "prop/sat_solver_types.h"
#include "proof/clause_id.h"
using namespace CVC4::proof;
using namespace CVC4::prop;
class LfscProofPrinterBlack : public CxxTest::TestSuite
{
public:
void setUp() override {}
void tearDown() override {}
void testPrintClause();
void testPrintSatInputProof();
void testPrintCMapProof();
};
void LfscProofPrinterBlack::testPrintClause()
{
SatClause clause{
SatLiteral(0, false), SatLiteral(1, true), SatLiteral(3, false)};
std::ostringstream lfsc;
LFSCProofPrinter::printSatClause(clause, lfsc, "");
std::string expectedLfsc =
"(clc (pos .v0) "
"(clc (neg .v1) "
"(clc (pos .v3) "
"cln)))";
TS_ASSERT_EQUALS(lfsc.str(), expectedLfsc);
}
void LfscProofPrinterBlack::testPrintSatInputProof()
{
std::vector<CVC4::ClauseId> ids{2, 40, 3};
std::ostringstream lfsc;
LFSCProofPrinter::printSatInputProof(ids, lfsc, "");
std::string expectedLfsc =
"(cnfc_proof _ _ _ .pb2 "
"(cnfc_proof _ _ _ .pb40 "
"(cnfc_proof _ _ _ .pb3 "
"cnfn_proof)))";
std::ostringstream lfscWithoutWhitespace;
for (char c : lfsc.str())
{
if (!std::isspace(c))
{
lfscWithoutWhitespace << c;
}
}
std::ostringstream expectedLfscWithoutWhitespace;
for (char c : expectedLfsc)
{
if (!std::isspace(c))
{
expectedLfscWithoutWhitespace << c;
}
}
TS_ASSERT_EQUALS(lfscWithoutWhitespace.str(),
expectedLfscWithoutWhitespace.str());
}
void LfscProofPrinterBlack::testPrintCMapProof()
{
std::vector<CVC4::ClauseId> ids{2, 40, 3};
std::ostringstream lfsc;
LFSCProofPrinter::printCMapProof(ids, lfsc, "");
std::string expectedLfsc =
"(CMapc_proof 1 _ _ _ .pb2 "
"(CMapc_proof 2 _ _ _ .pb40 "
"(CMapc_proof 3 _ _ _ .pb3 "
"CMapn_proof)))";
std::ostringstream lfscWithoutWhitespace;
for (char c : lfsc.str())
{
if (!std::isspace(c))
{
lfscWithoutWhitespace << c;
}
}
std::ostringstream expectedLfscWithoutWhitespace;
for (char c : expectedLfsc)
{
if (!std::isspace(c))
{
expectedLfscWithoutWhitespace << c;
}
}
TS_ASSERT_EQUALS(lfscWithoutWhitespace.str(),
expectedLfscWithoutWhitespace.str());
}
|