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
|
/******************************************************************************
* Top contributors (to current version):
* Andrew Reynolds, Aina Niemetz, Gereon Kremer
*
* This file is part of the cvc5 project.
*
* Copyright (c) 2009-2025 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.
* ****************************************************************************
*
* Black box testing of the SynthResult class
*/
#include "test_api.h"
namespace cvc5::internal {
namespace test {
class TestApiBlackSynthResult : public TestApi
{
};
TEST_F(TestApiBlackSynthResult, isNull)
{
cvc5::SynthResult res_null;
ASSERT_TRUE(res_null.isNull());
ASSERT_FALSE(res_null.hasSolution());
ASSERT_FALSE(res_null.hasNoSolution());
ASSERT_FALSE(res_null.isUnknown());
}
TEST_F(TestApiBlackSynthResult, hasSolution)
{
d_solver->setOption("sygus", "true");
(void)d_solver->synthFun("f", {}, d_tm.getBooleanSort());
Term boolTerm = d_tm.mkTrue();
d_solver->addSygusConstraint(boolTerm);
cvc5::SynthResult res = d_solver->checkSynth();
ASSERT_FALSE(res.isNull());
ASSERT_TRUE(res.hasSolution());
ASSERT_FALSE(res.hasNoSolution());
ASSERT_FALSE(res.isUnknown());
ASSERT_EQ(res.toString(), "(SOLUTION)");
{
std::stringstream ss;
ss << res;
ASSERT_EQ(res.toString(), ss.str());
}
}
TEST_F(TestApiBlackSynthResult, hasNoSolution)
{
cvc5::SynthResult res_null;
ASSERT_FALSE(res_null.hasNoSolution());
}
TEST_F(TestApiBlackSynthResult, isUnknown)
{
d_solver->setOption("sygus", "true");
(void)d_solver->synthFun("f", {}, d_tm.getBooleanSort());
Term boolTerm = d_tm.mkFalse();
d_solver->addSygusConstraint(boolTerm);
cvc5::SynthResult res = d_solver->checkSynth();
ASSERT_FALSE(res.isNull());
ASSERT_FALSE(res.hasSolution());
ASSERT_TRUE(res.hasNoSolution());
ASSERT_FALSE(res.isUnknown());
}
TEST_F(TestApiBlackSynthResult, equalHash)
{
d_solver->setOption("sygus", "true");
(void)d_solver->synthFun("f", {}, d_bool);
Term tfalse = d_tm.mkFalse();
Term ttrue = d_tm.mkTrue();
d_solver->addSygusConstraint(ttrue);
cvc5::SynthResult res1 = d_solver->checkSynth();
d_solver->addSygusConstraint(tfalse);
cvc5::SynthResult res2 = d_solver->checkSynth();
ASSERT_EQ(res1, res1);
ASSERT_NE(res1, res2);
ASSERT_NE(res1, cvc5::SynthResult());
ASSERT_NE(cvc5::SynthResult(), res1);
ASSERT_EQ(std::hash<cvc5::SynthResult>{}(res1),
std::hash<cvc5::SynthResult>{}(res1));
ASSERT_NE(std::hash<cvc5::SynthResult>{}(res1),
std::hash<cvc5::SynthResult>{}(res2));
ASSERT_NE(std::hash<cvc5::SynthResult>{}(cvc5::SynthResult()),
std::hash<cvc5::SynthResult>{}(res2));
}
} // namespace test
} // namespace cvc5::internal
|