blob: 7c67e9b4fb87bf89ba31e78733a0846370be83d2 [file] [log] [blame]
#include "utils.hpp"
#include <gtest/gtest.h>
constexpr std::string_view helloWorld = "Hello World";
TEST(IfindFirstTest, BasicMatch)
{
auto match = iFindFirst(helloWorld, "World");
EXPECT_TRUE(match);
EXPECT_EQ(std::distance(helloWorld.begin(), match.begin()), 6);
EXPECT_EQ(std::distance(helloWorld.begin(), match.end()), 11);
}
TEST(IfindFirstTest, CaseInsensitiveMatch)
{
auto match = iFindFirst(helloWorld, "world");
EXPECT_TRUE(match);
EXPECT_EQ(std::distance(helloWorld.begin(), match.begin()), 6);
EXPECT_EQ(std::distance(helloWorld.begin(), match.end()), 11);
}
TEST(IfindFirstTest, NoMatch)
{
auto match = iFindFirst(helloWorld, "Planet");
EXPECT_FALSE(match);
}
TEST(IfindFirstTest, MatchAtStart)
{
auto match = iFindFirst(helloWorld, "HeLLo");
EXPECT_TRUE(match);
EXPECT_EQ(std::distance(helloWorld.begin(), match.begin()), 0);
EXPECT_EQ(std::distance(helloWorld.begin(), match.end()), 5);
}
TEST(IfindFirstTest, MatchAtEnd)
{
auto match = iFindFirst(helloWorld, "LD");
EXPECT_TRUE(match);
EXPECT_EQ(std::distance(helloWorld.begin(), match.begin()), 9);
EXPECT_EQ(std::distance(helloWorld.begin(), match.end()), 11);
}
TEST(IfindFirstTest, EmptySubstring)
{
auto match = iFindFirst(helloWorld, "");
EXPECT_FALSE(match);
}
TEST(IfindFirstTest, EmptyString)
{
auto match = iFindFirst("", "Hello");
EXPECT_FALSE(match);
}