From 0c6fd47460cb59c1b58c8870a4d2f05c23d8f357 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 27 Nov 2016 11:18:27 +0100 Subject: [PATCH] Add unit test for StringUtil's newly added JoinStrings --- Source/UnitTests/Common/CMakeLists.txt | 1 + Source/UnitTests/Common/StringUtilTest.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 Source/UnitTests/Common/StringUtilTest.cpp diff --git a/Source/UnitTests/Common/CMakeLists.txt b/Source/UnitTests/Common/CMakeLists.txt index 238dbeddb7..28ca1237b3 100644 --- a/Source/UnitTests/Common/CMakeLists.txt +++ b/Source/UnitTests/Common/CMakeLists.txt @@ -9,4 +9,5 @@ add_dolphin_test(FixedSizeQueueTest FixedSizeQueueTest.cpp) add_dolphin_test(FlagTest FlagTest.cpp) add_dolphin_test(MathUtilTest MathUtilTest.cpp) add_dolphin_test(NandPathsTest NandPathsTest.cpp) +add_dolphin_test(StringUtilTest StringUtilTest.cpp) add_dolphin_test(x64EmitterTest x64EmitterTest.cpp) diff --git a/Source/UnitTests/Common/StringUtilTest.cpp b/Source/UnitTests/Common/StringUtilTest.cpp new file mode 100644 index 0000000000..603c99d80c --- /dev/null +++ b/Source/UnitTests/Common/StringUtilTest.cpp @@ -0,0 +1,18 @@ +// Copyright 2016 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include +#include +#include + +#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({"?", "?"}, "?")); +}