2022-03-23 16:56:33 -05:00
|
|
|
/******************************************************************************
|
|
|
|
|
* Top contributors (to current version):
|
2024-03-12 09:35:09 -07:00
|
|
|
* Andrew Reynolds, Aina Niemetz, Gereon Kremer
|
2022-03-23 16:56:33 -05:00
|
|
|
*
|
|
|
|
|
* This file is part of the cvc5 project.
|
|
|
|
|
*
|
2025-01-23 09:54:20 -08:00
|
|
|
* Copyright (c) 2009-2025 by the authors listed in the file AUTHORS
|
2022-03-23 16:56:33 -05:00
|
|
|
* 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"
|
|
|
|
|
|
2022-03-29 16:23:01 -07:00
|
|
|
namespace cvc5::internal {
|
2022-03-23 16:56:33 -05:00
|
|
|
|
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
|
|
class TestApiBlackSynthResult : public TestApi
|
|
|
|
|
{
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TEST_F(TestApiBlackSynthResult, isNull)
|
|
|
|
|
{
|
2022-03-29 16:23:01 -07:00
|
|
|
cvc5::SynthResult res_null;
|
2022-03-23 16:56:33 -05:00
|
|
|
ASSERT_TRUE(res_null.isNull());
|
|
|
|
|
ASSERT_FALSE(res_null.hasSolution());
|
|
|
|
|
ASSERT_FALSE(res_null.hasNoSolution());
|
|
|
|
|
ASSERT_FALSE(res_null.isUnknown());
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-25 15:00:14 -05:00
|
|
|
TEST_F(TestApiBlackSynthResult, hasSolution)
|
|
|
|
|
{
|
2024-03-08 11:39:13 -08:00
|
|
|
d_solver->setOption("sygus", "true");
|
2024-06-28 21:59:21 -07:00
|
|
|
(void)d_solver->synthFun("f", {}, d_tm.getBooleanSort());
|
2024-03-08 11:39:13 -08:00
|
|
|
Term boolTerm = d_tm.mkTrue();
|
|
|
|
|
d_solver->addSygusConstraint(boolTerm);
|
|
|
|
|
cvc5::SynthResult res = d_solver->checkSynth();
|
2022-03-25 15:00:14 -05:00
|
|
|
ASSERT_FALSE(res.isNull());
|
|
|
|
|
ASSERT_TRUE(res.hasSolution());
|
|
|
|
|
ASSERT_FALSE(res.hasNoSolution());
|
|
|
|
|
ASSERT_FALSE(res.isUnknown());
|
2022-04-28 17:47:10 -07:00
|
|
|
ASSERT_EQ(res.toString(), "(SOLUTION)");
|
2022-05-02 14:08:58 -07:00
|
|
|
{
|
|
|
|
|
std::stringstream ss;
|
|
|
|
|
ss << res;
|
|
|
|
|
ASSERT_EQ(res.toString(), ss.str());
|
|
|
|
|
}
|
2022-03-25 15:00:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(TestApiBlackSynthResult, hasNoSolution)
|
|
|
|
|
{
|
2022-03-29 16:23:01 -07:00
|
|
|
cvc5::SynthResult res_null;
|
2022-03-25 15:00:14 -05:00
|
|
|
ASSERT_FALSE(res_null.hasNoSolution());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(TestApiBlackSynthResult, isUnknown)
|
|
|
|
|
{
|
2024-03-08 11:39:13 -08:00
|
|
|
d_solver->setOption("sygus", "true");
|
2024-06-28 21:59:21 -07:00
|
|
|
(void)d_solver->synthFun("f", {}, d_tm.getBooleanSort());
|
2024-03-08 11:39:13 -08:00
|
|
|
Term boolTerm = d_tm.mkFalse();
|
|
|
|
|
d_solver->addSygusConstraint(boolTerm);
|
|
|
|
|
cvc5::SynthResult res = d_solver->checkSynth();
|
2022-03-25 15:00:14 -05:00
|
|
|
ASSERT_FALSE(res.isNull());
|
|
|
|
|
ASSERT_FALSE(res.hasSolution());
|
2022-10-13 10:56:55 -05:00
|
|
|
ASSERT_TRUE(res.hasNoSolution());
|
|
|
|
|
ASSERT_FALSE(res.isUnknown());
|
2022-03-25 15:00:14 -05:00
|
|
|
}
|
|
|
|
|
|
2024-07-10 10:54:35 -07:00
|
|
|
TEST_F(TestApiBlackSynthResult, equalHash)
|
2024-07-09 14:24:26 -07:00
|
|
|
{
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-23 16:56:33 -05:00
|
|
|
} // namespace test
|
2022-03-29 16:23:01 -07:00
|
|
|
} // namespace cvc5::internal
|