From 36f2a15ab09ceb741d260f5ee6911f4cf8e3f4bf Mon Sep 17 00:00:00 2001 From: Aina Niemetz Date: Fri, 26 Feb 2021 19:51:25 -0800 Subject: [PATCH] google test: util: Migrate exception_black. (#6020) --- test/unit/util/CMakeLists.txt | 2 +- test/unit/util/exception_black.cpp | 55 ++++++++++++++++++++++++++++ test/unit/util/exception_black.h | 57 ------------------------------ 3 files changed, 56 insertions(+), 58 deletions(-) create mode 100644 test/unit/util/exception_black.cpp delete mode 100644 test/unit/util/exception_black.h diff --git a/test/unit/util/CMakeLists.txt b/test/unit/util/CMakeLists.txt index 11469be75..a5b71b92d 100644 --- a/test/unit/util/CMakeLists.txt +++ b/test/unit/util/CMakeLists.txt @@ -20,7 +20,7 @@ cvc4_add_unit_test_black(cardinality_black util) cvc4_add_unit_test_white(check_white util) cvc4_add_cxx_unit_test_black(configuration_black util) cvc4_add_cxx_unit_test_black(datatype_black util) -cvc4_add_cxx_unit_test_black(exception_black util) +cvc4_add_unit_test_black(exception_black util) if(CVC4_USE_SYMFPU) cvc4_add_cxx_unit_test_black(floatingpoint_black util) endif() diff --git a/test/unit/util/exception_black.cpp b/test/unit/util/exception_black.cpp new file mode 100644 index 000000000..7219ce080 --- /dev/null +++ b/test/unit/util/exception_black.cpp @@ -0,0 +1,55 @@ +/********************* */ +/*! \file exception_black.cpp + ** \verbatim + ** Top contributors (to current version): + ** Aina Niemetz, Morgan Deters + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2020 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 CVC4::Exception. + ** + ** Black box testing of CVC4::Exception. + **/ + +#include +#include + +#include "base/exception.h" +#include "test.h" + +namespace CVC4 { +namespace test { + +class TestUtilBlackException : public TestInternal +{ +}; + +// CVC4::Exception is a simple class, just test it all at once. +TEST_F(TestUtilBlackException, exceptions) +{ + Exception e1; + Exception e2(std::string("foo!")); + Exception e3("bar!"); + + ASSERT_EQ(e1.toString(), std::string("Unknown exception")); + ASSERT_EQ(e2.toString(), std::string("foo!")); + ASSERT_EQ(e3.toString(), std::string("bar!")); + + e1.setMessage("blah"); + e2.setMessage("another"); + e3.setMessage("three of 'em!"); + + std::stringstream s1, s2, s3; + s1 << e1; + s2 << e2; + s3 << e3; + + ASSERT_EQ(s1.str(), std::string("blah")); + ASSERT_EQ(s2.str(), std::string("another")); + ASSERT_EQ(s3.str(), std::string("three of 'em!")); +} +} // namespace test +} // namespace CVC4 diff --git a/test/unit/util/exception_black.h b/test/unit/util/exception_black.h deleted file mode 100644 index a475f226e..000000000 --- a/test/unit/util/exception_black.h +++ /dev/null @@ -1,57 +0,0 @@ -/********************* */ -/*! \file exception_black.h - ** \verbatim - ** Top contributors (to current version): - ** Morgan Deters, Andres Noetzli - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2020 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 CVC4::Exception. - ** - ** Black box testing of CVC4::Exception. - **/ - -#include - -#include -#include - -#include "base/exception.h" - -using namespace CVC4; -using namespace std; - -class ExceptionBlack : public CxxTest::TestSuite { - public: - void setUp() override {} - - void tearDown() override {} - - // CVC4::Exception is a simple class, just test it all at once. - void testExceptions() - { - Exception e1; - Exception e2(string("foo!")); - Exception e3("bar!"); - - TS_ASSERT_EQUALS(e1.toString(), string("Unknown exception")); - TS_ASSERT_EQUALS(e2.toString(), string("foo!")); - TS_ASSERT_EQUALS(e3.toString(), string("bar!")); - - e1.setMessage("blah"); - e2.setMessage("another"); - e3.setMessage("three of 'em!"); - - stringstream s1, s2, s3; - s1 << e1; - s2 << e2; - s3 << e3; - - TS_ASSERT_EQUALS(s1.str(), string("blah")); - TS_ASSERT_EQUALS(s2.str(), string("another")); - TS_ASSERT_EQUALS(s3.str(), string("three of 'em!")); - } -}; -- 2.30.2