Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * This file is part of the cvc5 project. 3 : : * 4 : : * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS 5 : : * in the top-level source directory and their institutional affiliations. 6 : : * All rights reserved. See the file COPYING in the top-level source 7 : : * directory for licensing information. 8 : : * **************************************************************************** 9 : : * 10 : : * Black box testing of cvc5::Stat and associated classes. 11 : : */ 12 : : 13 : : #include "test.h" 14 : : #include "util/didyoumean.h" 15 : : 16 : : namespace cvc5::internal::test { 17 : : 18 : : class TestUtilDidYouMean : public TestInternal 19 : : { 20 : : }; 21 : : 22 : 4 : TEST_F(TestUtilDidYouMean, getMatch) 23 : : { 24 : : { 25 : 1 : DidYouMean dym; 26 [ + + ][ - - ]: 4 : dym.addWords({"abfish", "cdfish", "whale"}); 27 : : { 28 : 4 : auto expected = std::vector<std::string>{"abfish"}; 29 [ - + ]: 2 : EXPECT_EQ(dym.getMatch("abfish"), expected); 30 : 1 : } 31 : : { 32 : 4 : auto expected = std::vector<std::string>{"whale"}; 33 [ - + ]: 2 : EXPECT_EQ(dym.getMatch("wahl"), expected); 34 : 1 : } 35 : : { 36 : 5 : auto expected = std::vector<std::string>{"abfish", "cdfish"}; 37 [ - + ]: 2 : EXPECT_EQ(dym.getMatch("fish"), expected); 38 : 1 : } 39 : : { 40 : 1 : auto expected = std::vector<std::string>{}; 41 [ - + ]: 2 : EXPECT_EQ(dym.getMatch("elephant"), expected); 42 : 1 : } 43 : 1 : } 44 : 1 : } 45 : : 46 : 4 : TEST_F(TestUtilDidYouMean, getMatchAsString) 47 : : { 48 : 1 : DidYouMean dym; 49 [ + + ][ - - ]: 4 : dym.addWords({"abfish", "cdfish", "whale"}); 50 : : { 51 : 1 : std::string expected = ""; 52 [ - + ]: 2 : EXPECT_EQ(dym.getMatchAsString("elephant"), expected); 53 : 1 : } 54 : : { 55 : 1 : std::string expected = R"FOOBAR( 56 : : 57 : : Did you mean this? 58 : : whale)FOOBAR"; 59 [ - + ]: 2 : EXPECT_EQ(dym.getMatchAsString("wahl"), expected); 60 : 1 : } 61 : : { 62 : 1 : std::string expected = R"FOOBAR( 63 : : 64 : : Did you mean any of these? 65 : : abfish 66 : : cdfish)FOOBAR"; 67 [ - + ]: 2 : EXPECT_EQ(dym.getMatchAsString("fish"), expected); 68 : 1 : } 69 : 1 : } 70 : : 71 : : } // namespace cvc5::internal::test