Lines Matching refs:Twine
1 //===- TwineTest.cpp - Twine unit tests -----------------------------------===//
10 #include "llvm/ADT/Twine.h"
18 std::string repr(const Twine &Value) {
26 EXPECT_EQ("", Twine().str());
27 EXPECT_EQ("hi", Twine("hi").str());
28 EXPECT_EQ("hi", Twine(std::string("hi")).str());
29 EXPECT_EQ("hi", Twine(StringRef("hi")).str());
30 EXPECT_EQ("hi", Twine(StringRef(std::string("hi"))).str());
31 EXPECT_EQ("hi", Twine(StringRef("hithere", 2)).str());
32 EXPECT_EQ("hi", Twine(SmallString<4>("hi")).str());
36 EXPECT_EQ("123", Twine(123U).str());
37 EXPECT_EQ("123", Twine(123).str());
38 EXPECT_EQ("-123", Twine(-123).str());
39 EXPECT_EQ("123", Twine(123).str());
40 EXPECT_EQ("-123", Twine(-123).str());
42 EXPECT_EQ("7b", Twine::utohexstr(123).str());
46 EXPECT_EQ("x", Twine('x').str());
47 EXPECT_EQ("x", Twine(static_cast<unsigned char>('x')).str());
48 EXPECT_EQ("x", Twine(static_cast<signed char>('x')).str());
56 EXPECT_EQ("(Twine null empty)",
57 repr(Twine("hi").concat(Twine::createNull())));
58 EXPECT_EQ("(Twine null empty)",
59 repr(Twine::createNull().concat(Twine("hi"))));
62 EXPECT_EQ("(Twine cstring:\"hi\" empty)",
63 repr(Twine("hi").concat(Twine())));
64 EXPECT_EQ("(Twine cstring:\"hi\" empty)",
65 repr(Twine().concat(Twine("hi"))));
66 EXPECT_EQ("(Twine smallstring:\"hi\" empty)",
67 repr(Twine().concat(Twine(SmallString<5>("hi")))));
68 EXPECT_EQ("(Twine smallstring:\"hey\" cstring:\"there\")",
69 repr(Twine(SmallString<7>("hey")).concat(Twine("there"))));
72 EXPECT_EQ("(Twine cstring:\"a\" cstring:\"b\")",
73 repr(Twine("a").concat(Twine("b"))));
76 EXPECT_EQ("(Twine rope:(Twine cstring:\"a\" cstring:\"b\") cstring:\"c\")",
77 repr(Twine("a").concat(Twine("b")).concat(Twine("c"))));
78 EXPECT_EQ("(Twine cstring:\"a\" rope:(Twine cstring:\"b\" cstring:\"c\"))",
79 repr(Twine("a").concat(Twine("b").concat(Twine("c")))));
80 EXPECT_EQ("(Twine cstring:\"a\" rope:(Twine smallstring:\"b\" cstring:\"c\"))",
81 repr(Twine("a").concat(Twine(SmallString<3>("b")).concat(Twine("c")))));
86 EXPECT_EQ(0, *Twine("hello").toNullTerminatedStringRef(storage).end());
88 *Twine(StringRef("hello")).toNullTerminatedStringRef(storage).end());
89 EXPECT_EQ(0, *Twine(SmallString<11>("hello"))