2016-11-27 11:18:27 +01:00
|
|
|
// Copyright 2016 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Common/StringUtil.h"
|
|
|
|
|
|
|
|
TEST(StringUtil, JoinStrings)
|
|
|
|
{
|
|
|
|
EXPECT_EQ("", JoinStrings({}, ", "));
|
|
|
|
EXPECT_EQ("a", JoinStrings({"a"}, ","));
|
|
|
|
EXPECT_EQ("ab", JoinStrings({"a", "b"}, ""));
|
|
|
|
EXPECT_EQ("a, bb, c", JoinStrings({"a", "bb", "c"}, ", "));
|
|
|
|
EXPECT_EQ("???", JoinStrings({"?", "?"}, "?"));
|
|
|
|
}
|
2016-12-06 16:43:41 +01:00
|
|
|
|
|
|
|
TEST(StringUtil, StringBeginsWith)
|
|
|
|
{
|
2017-03-25 01:23:38 +01:00
|
|
|
EXPECT_TRUE(StringBeginsWith("abc", "a"));
|
|
|
|
EXPECT_FALSE(StringBeginsWith("abc", "b"));
|
|
|
|
EXPECT_TRUE(StringBeginsWith("abc", "ab"));
|
|
|
|
EXPECT_FALSE(StringBeginsWith("a", "ab"));
|
|
|
|
EXPECT_FALSE(StringBeginsWith("", "a"));
|
|
|
|
EXPECT_FALSE(StringBeginsWith("", "ab"));
|
|
|
|
EXPECT_TRUE(StringBeginsWith("abc", ""));
|
|
|
|
EXPECT_TRUE(StringBeginsWith("", ""));
|
2016-12-06 16:43:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(StringUtil, StringEndsWith)
|
|
|
|
{
|
2017-03-25 01:23:38 +01:00
|
|
|
EXPECT_TRUE(StringEndsWith("abc", "c"));
|
|
|
|
EXPECT_FALSE(StringEndsWith("abc", "b"));
|
|
|
|
EXPECT_TRUE(StringEndsWith("abc", "bc"));
|
|
|
|
EXPECT_FALSE(StringEndsWith("a", "ab"));
|
|
|
|
EXPECT_FALSE(StringEndsWith("", "a"));
|
|
|
|
EXPECT_FALSE(StringEndsWith("", "ab"));
|
|
|
|
EXPECT_TRUE(StringEndsWith("abc", ""));
|
|
|
|
EXPECT_TRUE(StringEndsWith("", ""));
|
2016-12-06 16:43:41 +01:00
|
|
|
}
|