2023-10-02 10:51:32 -05:00
|
|
|
/******************************************************************************
|
|
|
|
|
* Top contributors (to current version):
|
|
|
|
|
* Andrew Reynolds
|
|
|
|
|
*
|
|
|
|
|
* This file is part of the cvc5 project.
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2009-2023 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 cvc5::parser::Command.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <cvc5/cvc5.h>
|
|
|
|
|
#include <cvc5/cvc5_parser.h>
|
|
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
|
|
#include "base/output.h"
|
|
|
|
|
#include "options/base_options.h"
|
|
|
|
|
#include "options/language.h"
|
|
|
|
|
#include "options/options.h"
|
2023-11-28 11:53:30 -06:00
|
|
|
#include <cvc5/cvc5_parser.h>
|
2023-10-02 10:51:32 -05:00
|
|
|
#include "test_parser.h"
|
|
|
|
|
|
|
|
|
|
using namespace cvc5::parser;
|
|
|
|
|
|
|
|
|
|
namespace cvc5::internal {
|
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
|
|
class TestCommandBlack : public TestParser
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
TestCommandBlack() {}
|
|
|
|
|
virtual ~TestCommandBlack() {}
|
|
|
|
|
|
|
|
|
|
Command parseCommand(const std::string& cmdStr)
|
|
|
|
|
{
|
|
|
|
|
std::stringstream ss;
|
|
|
|
|
ss << cmdStr << std::endl;
|
|
|
|
|
InputParser parser(&d_solver, d_symman.get());
|
|
|
|
|
parser.setStreamInput(
|
2023-11-28 11:53:30 -06:00
|
|
|
modes::InputLanguage::SMT_LIB_2_6, ss, "command_black");
|
2023-10-02 10:51:32 -05:00
|
|
|
return parser.nextCommand();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TEST_F(TestCommandBlack, invoke)
|
|
|
|
|
{
|
|
|
|
|
std::stringstream out;
|
|
|
|
|
Command cmd;
|
|
|
|
|
// set logic command can be executed
|
|
|
|
|
cmd = parseCommand("(set-logic QF_LIA)");
|
|
|
|
|
ASSERT_NE(cmd.isNull(), true);
|
|
|
|
|
cmd.invoke(&d_solver, d_symman.get(), out);
|
|
|
|
|
// get model not available
|
|
|
|
|
cmd = parseCommand("(get-model)");
|
|
|
|
|
ASSERT_NE(cmd.isNull(), true);
|
|
|
|
|
cmd.invoke(&d_solver, d_symman.get(), out);
|
2023-12-13 10:42:40 -06:00
|
|
|
std::string result = out.str();
|
|
|
|
|
ASSERT_EQ(
|
|
|
|
|
"(error \"Cannot get model unless model generation is enabled (try "
|
|
|
|
|
"--produce-models)\")\n",
|
|
|
|
|
result);
|
2023-10-02 10:51:32 -05:00
|
|
|
// logic already set
|
|
|
|
|
ASSERT_THROW(parseCommand("(set-logic QF_LRA)"), ParserException);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(TestCommandBlack, toString)
|
|
|
|
|
{
|
|
|
|
|
Command cmd;
|
|
|
|
|
cmd = parseCommand("(set-logic QF_LIA )");
|
|
|
|
|
ASSERT_NE(cmd.isNull(), true);
|
|
|
|
|
// note normalizes wrt whitespace
|
2023-12-15 16:46:41 -06:00
|
|
|
ASSERT_EQ(cmd.toString(), "(set-logic QF_LIA)");
|
2023-10-03 19:24:08 -05:00
|
|
|
std::stringstream ss;
|
|
|
|
|
ss << cmd;
|
|
|
|
|
ASSERT_EQ(cmd.toString(), ss.str());
|
2023-10-02 10:51:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(TestCommandBlack, getCommandName)
|
|
|
|
|
{
|
|
|
|
|
Command cmd;
|
|
|
|
|
cmd = parseCommand("(get-model)");
|
|
|
|
|
ASSERT_NE(cmd.isNull(), true);
|
|
|
|
|
ASSERT_EQ(cmd.getCommandName(), "get-model");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace test
|
|
|
|
|
} // namespace cvc5::internal
|