William A. Kennington III | 6e767bf | 2023-07-24 17:08:45 -0700 | [diff] [blame] | 1 | #include <stdplus/str/buf.hpp> |
William A. Kennington III | 6047970 | 2022-12-07 02:55:24 -0800 | [diff] [blame] | 2 | #include <stdplus/str/cat.hpp> |
William A. Kennington III | 178cfda | 2023-07-24 17:08:14 -0700 | [diff] [blame] | 3 | #include <stdplus/zstring_view.hpp> |
Patrick Williams | d1984dd | 2023-05-10 16:12:44 -0500 | [diff] [blame] | 4 | |
William A. Kennington III | 4ef36e7 | 2019-06-27 12:48:59 -0700 | [diff] [blame] | 5 | #include <string> |
| 6 | #include <string_view> |
| 7 | |
Patrick Williams | d1984dd | 2023-05-10 16:12:44 -0500 | [diff] [blame] | 8 | #include <gtest/gtest.h> |
| 9 | |
William A. Kennington III | 4ef36e7 | 2019-06-27 12:48:59 -0700 | [diff] [blame] | 10 | namespace stdplus |
| 11 | { |
William A. Kennington III | 4ef36e7 | 2019-06-27 12:48:59 -0700 | [diff] [blame] | 12 | |
| 13 | using namespace std::string_literals; |
| 14 | using namespace std::string_view_literals; |
| 15 | |
William A. Kennington III | 4ef36e7 | 2019-06-27 12:48:59 -0700 | [diff] [blame] | 16 | TEST(StrCat, NoStr) |
| 17 | { |
| 18 | EXPECT_EQ("", strCat()); |
| 19 | } |
| 20 | |
| 21 | TEST(StrCat, SingleStr) |
| 22 | { |
| 23 | EXPECT_EQ("func", strCat("func")); |
| 24 | } |
| 25 | |
| 26 | TEST(StrCat, Multi) |
| 27 | { |
William A. Kennington III | 178cfda | 2023-07-24 17:08:14 -0700 | [diff] [blame] | 28 | EXPECT_EQ("func world test ff", |
| 29 | strCat("func", " world"sv, " test"s, " ff"_zsv)); |
William A. Kennington III | 4ef36e7 | 2019-06-27 12:48:59 -0700 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | TEST(StrCat, MoveStr) |
| 33 | { |
| 34 | EXPECT_EQ("func", strCat("func"s)); |
| 35 | EXPECT_EQ("func world", strCat("func"s, " world")); |
| 36 | } |
| 37 | |
William A. Kennington III | 6e767bf | 2023-07-24 17:08:45 -0700 | [diff] [blame] | 38 | TEST(StrAppend, Buf) |
| 39 | { |
| 40 | StrBuf buf; |
| 41 | strAppend(buf, "a "); |
| 42 | strAppend(buf); |
| 43 | strAppend(buf, "b"s, " c"sv); |
| 44 | EXPECT_EQ("a b c", buf); |
| 45 | } |
| 46 | |
William A. Kennington III | 4ef36e7 | 2019-06-27 12:48:59 -0700 | [diff] [blame] | 47 | } // namespace stdplus |