2012-08-19 19:23:46 +00:00
|
|
|
#include <gtest/gtest.h>
|
2013-08-30 19:51:23 +00:00
|
|
|
#include "components/misc/stringops.hpp"
|
2012-08-19 19:23:46 +00:00
|
|
|
|
2013-08-30 19:51:23 +00:00
|
|
|
struct StringOpsTest : public ::testing::Test
|
2012-08-19 19:23:46 +00:00
|
|
|
{
|
2013-08-30 19:51:23 +00:00
|
|
|
protected:
|
|
|
|
virtual void SetUp()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void TearDown()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(StringOpsTest, begins_matching)
|
|
|
|
{
|
2013-08-30 20:44:03 +00:00
|
|
|
ASSERT_TRUE(Misc::begins("abc", "a"));
|
|
|
|
ASSERT_TRUE(Misc::begins("abc", "ab"));
|
|
|
|
ASSERT_TRUE(Misc::begins("abc", "abc"));
|
|
|
|
ASSERT_TRUE(Misc::begins("abcd", "abc"));
|
2013-08-30 19:51:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(StringOpsTest, begins_not_matching)
|
|
|
|
{
|
2013-08-30 20:44:03 +00:00
|
|
|
ASSERT_FALSE(Misc::begins("abc", "b"));
|
|
|
|
ASSERT_FALSE(Misc::begins("abc", "bc"));
|
|
|
|
ASSERT_FALSE(Misc::begins("abc", "bcd"));
|
|
|
|
ASSERT_FALSE(Misc::begins("abc", "abcd"));
|
2013-08-30 19:51:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(StringOpsTest, ibegins_matching)
|
|
|
|
{
|
2013-08-30 20:44:03 +00:00
|
|
|
ASSERT_TRUE(Misc::ibegins("Abc", "a"));
|
|
|
|
ASSERT_TRUE(Misc::ibegins("aBc", "ab"));
|
|
|
|
ASSERT_TRUE(Misc::ibegins("abC", "abc"));
|
|
|
|
ASSERT_TRUE(Misc::ibegins("abcD", "abc"));
|
2013-08-30 19:51:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(StringOpsTest, ibegins_not_matching)
|
|
|
|
{
|
2013-08-30 20:44:03 +00:00
|
|
|
ASSERT_FALSE(Misc::ibegins("abc", "b"));
|
|
|
|
ASSERT_FALSE(Misc::ibegins("abc", "bc"));
|
|
|
|
ASSERT_FALSE(Misc::ibegins("abc", "bcd"));
|
|
|
|
ASSERT_FALSE(Misc::ibegins("abc", "abcd"));
|
2013-08-30 19:51:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(StringOpsTest, ends_matching)
|
|
|
|
{
|
2013-08-30 20:44:03 +00:00
|
|
|
ASSERT_TRUE(Misc::ends("abc", "c"));
|
|
|
|
ASSERT_TRUE(Misc::ends("abc", "bc"));
|
|
|
|
ASSERT_TRUE(Misc::ends("abc", "abc"));
|
|
|
|
ASSERT_TRUE(Misc::ends("abcd", "abcd"));
|
2013-08-30 19:51:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(StringOpsTest, ends_not_matching)
|
|
|
|
{
|
2013-08-30 20:44:03 +00:00
|
|
|
ASSERT_FALSE(Misc::ends("abc", "b"));
|
|
|
|
ASSERT_FALSE(Misc::ends("abc", "ab"));
|
|
|
|
ASSERT_FALSE(Misc::ends("abc", "bcd"));
|
|
|
|
ASSERT_FALSE(Misc::ends("abc", "abcd"));
|
2013-08-30 19:51:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(StringOpsTest, iends_matching)
|
|
|
|
{
|
2013-08-30 20:44:03 +00:00
|
|
|
ASSERT_TRUE(Misc::iends("Abc", "c"));
|
|
|
|
ASSERT_TRUE(Misc::iends("aBc", "bc"));
|
|
|
|
ASSERT_TRUE(Misc::iends("abC", "abc"));
|
|
|
|
ASSERT_TRUE(Misc::iends("abcD", "abcd"));
|
2013-08-30 19:51:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(StringOpsTest, iends_not_matching)
|
|
|
|
{
|
2013-08-30 20:44:03 +00:00
|
|
|
ASSERT_FALSE(Misc::iends("abc", "b"));
|
|
|
|
ASSERT_FALSE(Misc::iends("abc", "ab"));
|
|
|
|
ASSERT_FALSE(Misc::iends("abc", "bcd"));
|
|
|
|
ASSERT_FALSE(Misc::iends("abc", "abcd"));
|
2012-08-19 19:23:46 +00:00
|
|
|
}
|
|
|
|
|