mirror of
https://github.com/OpenMW/openmw.git
synced 2026-02-05 19:28:30 +00:00
Add more tests
This commit is contained in:
parent
dd0bce2406
commit
120c7adddb
1 changed files with 20 additions and 0 deletions
|
|
@ -1,3 +1,5 @@
|
|||
#include "gmock/gmock.h"
|
||||
#include <algorithm>
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
@ -22,10 +24,28 @@ namespace MWGui
|
|||
{
|
||||
EXPECT_EQ(weightedSearch(std::string("xyyzzz"), std::vector<std::string>{ "x", "y", "z" }), 3);
|
||||
}
|
||||
TEST(MWGuiWeightedSearchTests, weightedSearchShouldBeCaseInsensitive)
|
||||
{
|
||||
EXPECT_EQ(weightedSearch(std::string("XYZ"), std::vector<std::string>{ "x", "y", "z" }), 3);
|
||||
}
|
||||
TEST(MWGuiWeightedSearchTests, generatePatternArrayShouldReturnEmptyArrayIfInputIsEmptyOrOnlySpaces)
|
||||
{
|
||||
EXPECT_THAT(generatePatternArray(std::string("")), testing::IsEmpty());
|
||||
EXPECT_THAT(generatePatternArray(std::string(10, ' ')), testing::IsEmpty());
|
||||
}
|
||||
TEST(MWGuiWeightedSearchTests, generatePatternArrayBasicSplittingTest)
|
||||
{
|
||||
std::vector<std::string> expected = { "x", "y", "z" };
|
||||
std::sort(expected.begin(), expected.end());
|
||||
|
||||
std::vector<std::string> output1 = generatePatternArray(std::string("x y z"));
|
||||
std::sort(output1.begin(), output1.end());
|
||||
|
||||
std::vector<std::string> output2 = generatePatternArray(std::string(" x y z "));
|
||||
std::sort(output2.begin(), output2.end());
|
||||
|
||||
EXPECT_EQ(output1, expected);
|
||||
EXPECT_EQ(output2, expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue