blob: 26658a5cd9127273a0471458c47303a6d6ae3c2f [file] [log] [blame]
William A. Kennington III4ef36e72019-06-27 12:48:59 -07001#include <gtest/gtest.h>
2#include <stdplus/util/string.hpp>
3#include <string>
4#include <string_view>
5
6namespace stdplus
7{
8namespace util
9{
10namespace
11{
12
13using namespace std::string_literals;
14using namespace std::string_view_literals;
15
William A. Kennington IIIe1721982021-02-23 03:15:01 -080016TEST(CStr, Basic)
17{
18 std::string s1 = "a";
19 EXPECT_EQ(s1, cStr(s1));
20 const std::string s2 = "b";
21 EXPECT_EQ(s2, cStr(s2));
22 char s3[] = "c";
23 EXPECT_EQ(s3, cStr(s3));
24 const char* s4 = "d";
25 EXPECT_EQ(s4, cStr(s4));
26}
27
William A. Kennington III4ef36e72019-06-27 12:48:59 -070028TEST(StrCat, NoStr)
29{
30 EXPECT_EQ("", strCat());
31}
32
33TEST(StrCat, SingleStr)
34{
35 EXPECT_EQ("func", strCat("func"));
36}
37
38TEST(StrCat, Multi)
39{
40 EXPECT_EQ("func world test", strCat("func", " world"sv, " test"s));
41}
42
43TEST(StrCat, MoveStr)
44{
45 EXPECT_EQ("func", strCat("func"s));
46 EXPECT_EQ("func world", strCat("func"s, " world"));
47}
48
49} // namespace
50} // namespace util
51} // namespace stdplus