blob: a61800f3f57df6983192faddf84670a6f36b5708 [file] [log] [blame]
William A. Kennington III6e767bf2023-07-24 17:08:45 -07001#include <stdplus/str/buf.hpp>
William A. Kennington III60479702022-12-07 02:55:24 -08002#include <stdplus/str/cat.hpp>
William A. Kennington III178cfda2023-07-24 17:08:14 -07003#include <stdplus/zstring_view.hpp>
Patrick Williamsd1984dd2023-05-10 16:12:44 -05004
William A. Kennington III4ef36e72019-06-27 12:48:59 -07005#include <string>
6#include <string_view>
7
Patrick Williamsd1984dd2023-05-10 16:12:44 -05008#include <gtest/gtest.h>
9
William A. Kennington III4ef36e72019-06-27 12:48:59 -070010namespace stdplus
11{
William A. Kennington III4ef36e72019-06-27 12:48:59 -070012
13using namespace std::string_literals;
14using namespace std::string_view_literals;
15
William A. Kennington III4ef36e72019-06-27 12:48:59 -070016TEST(StrCat, NoStr)
17{
18 EXPECT_EQ("", strCat());
19}
20
21TEST(StrCat, SingleStr)
22{
23 EXPECT_EQ("func", strCat("func"));
24}
25
26TEST(StrCat, Multi)
27{
William A. Kennington III178cfda2023-07-24 17:08:14 -070028 EXPECT_EQ("func world test ff",
29 strCat("func", " world"sv, " test"s, " ff"_zsv));
William A. Kennington III4ef36e72019-06-27 12:48:59 -070030}
31
32TEST(StrCat, MoveStr)
33{
34 EXPECT_EQ("func", strCat("func"s));
35 EXPECT_EQ("func world", strCat("func"s, " world"));
36}
37
William A. Kennington III6e767bf2023-07-24 17:08:45 -070038TEST(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 III4ef36e72019-06-27 12:48:59 -070047} // namespace stdplus