Improve options tests (#7761)
authorGereon Kremer <gkremer@stanford.edu>
Wed, 8 Dec 2021 00:14:55 +0000 (16:14 -0800)
committerGitHub <noreply@github.com>
Wed, 8 Dec 2021 00:14:55 +0000 (00:14 +0000)
This PR adds unit tests for a few more corners of the options code.

test/unit/options/options_black.cpp

index 1ab4bce23abe832e29893e1dad0240a941ad591d..0aa1606772440709215460ec0d307d1ab3ad3a48 100644 (file)
@@ -92,11 +92,13 @@ TEST_F(TestBlackOptions, set)
                 }
                 EXPECT_NO_THROW(d_solver.setOption(
                     name, std::to_string((range.first + range.second) / 2)));
+                EXPECT_THROW(d_solver.setOption(name, "0123abc"), CVC5ApiOptionException);
               },
               [this, &name](const OptionInfo::NumberInfo<uint64_t>& v) {
                 std::pair<uint64_t, uint64_t> range{
                     std::numeric_limits<uint64_t>::min(),
                     std::numeric_limits<uint64_t>::max()};
+                EXPECT_THROW(d_solver.setOption(name, "-1"), CVC5ApiOptionException);
                 if (v.minimum)
                 {
                   EXPECT_THROW(
@@ -117,6 +119,7 @@ TEST_F(TestBlackOptions, set)
                 }
                 EXPECT_NO_THROW(d_solver.setOption(
                     name, std::to_string((range.first + range.second) / 2)));
+                EXPECT_THROW(d_solver.setOption(name, "0123abc"), CVC5ApiOptionException);
               },
               [this, &name](const OptionInfo::NumberInfo<double>& v) {
                 std::pair<double, double> range{
@@ -149,7 +152,9 @@ TEST_F(TestBlackOptions, set)
                 for (const auto& m : v.modes)
                 {
                   d_solver.setOption(name, m);
+                  EXPECT_EQ(d_solver.getOption(name), m);
                 }
+                EXPECT_DEATH(d_solver.setOption(name, "help"), "");
               },
           },
           info.valueInfo);