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