aboutsummaryrefslogtreecommitdiffstats
path: root/unittests/ADT
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/ADT')
-rw-r--r--unittests/ADT/APFloatTest.cpp7
-rw-r--r--unittests/ADT/APIntTest.cpp240
-rw-r--r--unittests/ADT/ArrayRefTest.cpp28
-rw-r--r--unittests/ADT/DeltaAlgorithmTest.cpp2
-rw-r--r--unittests/ADT/DenseMapTest.cpp1
-rw-r--r--unittests/ADT/HashingTest.cpp1
-rw-r--r--unittests/ADT/MapVectorTest.cpp25
-rw-r--r--unittests/ADT/SCCIteratorTest.cpp4
-rw-r--r--unittests/ADT/SmallVectorTest.cpp19
-rw-r--r--unittests/ADT/TripleTest.cpp10
-rw-r--r--unittests/ADT/TwineTest.cpp10
-rw-r--r--unittests/ADT/ilistTest.cpp3
12 files changed, 327 insertions, 23 deletions
diff --git a/unittests/ADT/APFloatTest.cpp b/unittests/ADT/APFloatTest.cpp
index 8b82fb2..a4445f6 100644
--- a/unittests/ADT/APFloatTest.cpp
+++ b/unittests/ADT/APFloatTest.cpp
@@ -13,6 +13,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/raw_ostream.h"
#include "gtest/gtest.h"
+#include <cmath>
#include <ostream>
#include <string>
@@ -1305,13 +1306,13 @@ TEST(APFloatTest, roundToIntegral) {
EXPECT_EQ(-0.0, P.convertToDouble());
P = APFloat::getNaN(APFloat::IEEEdouble);
P.roundToIntegral(APFloat::rmTowardZero);
- EXPECT_TRUE(IsNAN(P.convertToDouble()));
+ EXPECT_TRUE(std::isnan(P.convertToDouble()));
P = APFloat::getInf(APFloat::IEEEdouble);
P.roundToIntegral(APFloat::rmTowardZero);
- EXPECT_TRUE(IsInf(P.convertToDouble()) && P.convertToDouble() > 0.0);
+ EXPECT_TRUE(std::isinf(P.convertToDouble()) && P.convertToDouble() > 0.0);
P = APFloat::getInf(APFloat::IEEEdouble, true);
P.roundToIntegral(APFloat::rmTowardZero);
- EXPECT_TRUE(IsInf(P.convertToDouble()) && P.convertToDouble() < 0.0);
+ EXPECT_TRUE(std::isinf(P.convertToDouble()) && P.convertToDouble() < 0.0);
}
diff --git a/unittests/ADT/APIntTest.cpp b/unittests/ADT/APIntTest.cpp
index 3b7ac5b..acdc1ec 100644
--- a/unittests/ADT/APIntTest.cpp
+++ b/unittests/ADT/APIntTest.cpp
@@ -209,6 +209,206 @@ TEST(APIntTest, i1) {
}
}
+TEST(APIntTest, divrem_big1) {
+ // Tests KnuthDiv rare step D6
+ APInt a{256, "1ffffffffffffffff", 16};
+ APInt b{256, "1ffffffffffffffff", 16};
+ APInt c{256, 0};
+
+ auto p = a * b + c;
+ auto q = p.udiv(a);
+ auto r = p.urem(a);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ APInt::udivrem(p, a, q, r);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ q = p.udiv(b);
+ r = p.urem(b);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+ APInt::udivrem(p, b, q, r);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+ q = p.sdiv(a);
+ r = p.srem(a);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ APInt::sdivrem(p, a, q, r);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ q = p.sdiv(b);
+ r = p.srem(b);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+ APInt::sdivrem(p, b, q, r);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+}
+
+TEST(APIntTest, divrem_big2) {
+ // Tests KnuthDiv rare step D6
+ APInt a{1024, "111111ffffffffffffffff"
+ "ffffffffffffffffffffffffffffffff"
+ "fffffffffffffffffffffffffffffccf"
+ "ffffffffffffffffffffffffffffff00", 16};
+ APInt b{1024, "112233ceff"
+ "cecece000000ffffffffffffffffffff"
+ "ffffffffffffffffffffffffffffffff"
+ "ffffffffffffffffffffffffffffffff"
+ "ffffffffffffffffffffffffffffff33", 16};
+ APInt c{1024, 7919};
+
+ auto p = a * b + c;
+ auto q = p.udiv(a);
+ auto r = p.urem(a);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ APInt::udivrem(p, a, q, r);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ q = p.udiv(b);
+ r = p.urem(b);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+ APInt::udivrem(p, b, q, r);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+ q = p.sdiv(a);
+ r = p.srem(a);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ APInt::sdivrem(p, a, q, r);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ q = p.sdiv(b);
+ r = p.srem(b);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+ APInt::sdivrem(p, b, q, r);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+}
+
+TEST(APIntTest, divrem_big3) {
+ // Tests KnuthDiv case without shift
+ APInt a{256, "ffffffffffffff0000000", 16};
+ APInt b{256, "80000001ffffffffffffffff", 16};
+ APInt c{256, 4219};
+
+ auto p = a * b + c;
+ auto q = p.udiv(a);
+ auto r = p.urem(a);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ APInt::udivrem(p, a, q, r);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ q = p.udiv(b);
+ r = p.urem(b);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+ APInt::udivrem(p, b, q, r);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+ q = p.sdiv(a);
+ r = p.srem(a);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ APInt::sdivrem(p, a, q, r);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ q = p.sdiv(b);
+ r = p.srem(b);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+ APInt::sdivrem(p, b, q, r);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+}
+
+TEST(APIntTest, divrem_big4) {
+ // Tests heap allocation in divide() enfoced by huge numbers
+ auto a = APInt{4096, 1}.shl(2000);
+ auto b = APInt{4096, 5}.shl(2001);
+ auto c = APInt{4096, 4219*13};
+
+ auto p = a * b + c;
+ auto q = p.udiv(a);
+ auto r = p.urem(a);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ q = APInt{1024, 0}; // test non-single word APInt conversion in divide()
+ r = APInt{1024, 0};
+ APInt::udivrem(p, a, q, r);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ q = p.udiv(b);
+ r = p.urem(b);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+ q = APInt{1024, 0};
+ r = APInt{1024, 0};
+ APInt::udivrem(p, b, q, r);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+ q = p.sdiv(a);
+ r = p.srem(a);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ q = APInt{1024, 0};
+ r = APInt{1024, 0};
+ APInt::sdivrem(p, a, q, r);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ q = p.sdiv(b);
+ r = p.srem(b);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+ q = APInt{1024, 0};
+ r = APInt{1024, 0};
+ APInt::sdivrem(p, b, q, r);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+}
+
+TEST(APIntTest, divrem_big5) {
+ // Tests one word divisor case of divide()
+ auto a = APInt{1024, 19}.shl(811);
+ auto b = APInt{1024, 4356013}; // one word
+ auto c = APInt{1024, 1};
+
+ auto p = a * b + c;
+ auto q = p.udiv(a);
+ auto r = p.urem(a);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ APInt::udivrem(p, a, q, r);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ q = p.udiv(b);
+ r = p.urem(b);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+ APInt::udivrem(p, b, q, r);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+ q = p.sdiv(a);
+ r = p.srem(a);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ APInt::sdivrem(p, a, q, r);
+ EXPECT_EQ(q, b);
+ EXPECT_EQ(r, c);
+ q = p.sdiv(b);
+ r = p.srem(b);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+ APInt::sdivrem(p, b, q, r);
+ EXPECT_EQ(q, a);
+ EXPECT_EQ(r, c);
+}
+
TEST(APIntTest, fromString) {
EXPECT_EQ(APInt(32, 0), APInt(32, "0", 2));
EXPECT_EQ(APInt(32, 1), APInt(32, "1", 2));
@@ -678,6 +878,46 @@ TEST(APIntTest, nearestLogBase2) {
EXPECT_EQ(A9.nearestLogBase2(), UINT32_MAX);
}
+TEST(APIntTest, IsSplat) {
+ APInt A(32, 0x01010101);
+ EXPECT_FALSE(A.isSplat(1));
+ EXPECT_FALSE(A.isSplat(2));
+ EXPECT_FALSE(A.isSplat(4));
+ EXPECT_TRUE(A.isSplat(8));
+ EXPECT_TRUE(A.isSplat(16));
+ EXPECT_TRUE(A.isSplat(32));
+
+ APInt B(24, 0xAAAAAA);
+ EXPECT_FALSE(B.isSplat(1));
+ EXPECT_TRUE(B.isSplat(2));
+ EXPECT_TRUE(B.isSplat(4));
+ EXPECT_TRUE(B.isSplat(8));
+ EXPECT_TRUE(B.isSplat(24));
+
+ APInt C(24, 0xABAAAB);
+ EXPECT_FALSE(C.isSplat(1));
+ EXPECT_FALSE(C.isSplat(2));
+ EXPECT_FALSE(C.isSplat(4));
+ EXPECT_FALSE(C.isSplat(8));
+ EXPECT_TRUE(C.isSplat(24));
+
+ APInt D(32, 0xABBAABBA);
+ EXPECT_FALSE(D.isSplat(1));
+ EXPECT_FALSE(D.isSplat(2));
+ EXPECT_FALSE(D.isSplat(4));
+ EXPECT_FALSE(D.isSplat(8));
+ EXPECT_TRUE(D.isSplat(16));
+ EXPECT_TRUE(D.isSplat(32));
+
+ APInt E(32, 0);
+ EXPECT_TRUE(E.isSplat(1));
+ EXPECT_TRUE(E.isSplat(2));
+ EXPECT_TRUE(E.isSplat(4));
+ EXPECT_TRUE(E.isSplat(8));
+ EXPECT_TRUE(E.isSplat(16));
+ EXPECT_TRUE(E.isSplat(32));
+}
+
#if defined(__clang__)
// Disable the pragma warning from versions of Clang without -Wself-move
#pragma clang diagnostic push
diff --git a/unittests/ADT/ArrayRefTest.cpp b/unittests/ADT/ArrayRefTest.cpp
index 70f8208..6955036 100644
--- a/unittests/ADT/ArrayRefTest.cpp
+++ b/unittests/ADT/ArrayRefTest.cpp
@@ -57,24 +57,24 @@ TEST(ArrayRefTest, DropBack) {
TEST(ArrayRefTest, Equals) {
static const int A1[] = {1, 2, 3, 4, 5, 6, 7, 8};
ArrayRef<int> AR1(A1);
- EXPECT_TRUE(AR1.equals(1, 2, 3, 4, 5, 6, 7, 8));
- EXPECT_FALSE(AR1.equals(8, 1, 2, 4, 5, 6, 6, 7));
- EXPECT_FALSE(AR1.equals(2, 4, 5, 6, 6, 7, 8, 1));
- EXPECT_FALSE(AR1.equals(0, 1, 2, 4, 5, 6, 6, 7));
- EXPECT_FALSE(AR1.equals(1, 2, 42, 4, 5, 6, 7, 8));
- EXPECT_FALSE(AR1.equals(42, 2, 3, 4, 5, 6, 7, 8));
- EXPECT_FALSE(AR1.equals(1, 2, 3, 4, 5, 6, 7, 42));
- EXPECT_FALSE(AR1.equals(1, 2, 3, 4, 5, 6, 7));
- EXPECT_FALSE(AR1.equals(1, 2, 3, 4, 5, 6, 7, 8, 9));
+ EXPECT_TRUE(AR1.equals({1, 2, 3, 4, 5, 6, 7, 8}));
+ EXPECT_FALSE(AR1.equals({8, 1, 2, 4, 5, 6, 6, 7}));
+ EXPECT_FALSE(AR1.equals({2, 4, 5, 6, 6, 7, 8, 1}));
+ EXPECT_FALSE(AR1.equals({0, 1, 2, 4, 5, 6, 6, 7}));
+ EXPECT_FALSE(AR1.equals({1, 2, 42, 4, 5, 6, 7, 8}));
+ EXPECT_FALSE(AR1.equals({42, 2, 3, 4, 5, 6, 7, 8}));
+ EXPECT_FALSE(AR1.equals({1, 2, 3, 4, 5, 6, 7, 42}));
+ EXPECT_FALSE(AR1.equals({1, 2, 3, 4, 5, 6, 7}));
+ EXPECT_FALSE(AR1.equals({1, 2, 3, 4, 5, 6, 7, 8, 9}));
ArrayRef<int> AR1a = AR1.drop_back();
- EXPECT_TRUE(AR1a.equals(1, 2, 3, 4, 5, 6, 7));
- EXPECT_FALSE(AR1a.equals(1, 2, 3, 4, 5, 6, 7, 8));
+ EXPECT_TRUE(AR1a.equals({1, 2, 3, 4, 5, 6, 7}));
+ EXPECT_FALSE(AR1a.equals({1, 2, 3, 4, 5, 6, 7, 8}));
ArrayRef<int> AR1b = AR1a.slice(2, 4);
- EXPECT_TRUE(AR1b.equals(3, 4, 5, 6));
- EXPECT_FALSE(AR1b.equals(2, 3, 4, 5, 6));
- EXPECT_FALSE(AR1b.equals(3, 4, 5, 6, 7));
+ EXPECT_TRUE(AR1b.equals({3, 4, 5, 6}));
+ EXPECT_FALSE(AR1b.equals({2, 3, 4, 5, 6}));
+ EXPECT_FALSE(AR1b.equals({3, 4, 5, 6, 7}));
}
TEST(ArrayRefTest, EmptyEquals) {
diff --git a/unittests/ADT/DeltaAlgorithmTest.cpp b/unittests/ADT/DeltaAlgorithmTest.cpp
index a1884cd..a33f2b4 100644
--- a/unittests/ADT/DeltaAlgorithmTest.cpp
+++ b/unittests/ADT/DeltaAlgorithmTest.cpp
@@ -32,7 +32,7 @@ std::ostream &operator<<(std::ostream &OS,
namespace {
-class FixedDeltaAlgorithm : public DeltaAlgorithm {
+class FixedDeltaAlgorithm final : public DeltaAlgorithm {
changeset_ty FailingSet;
unsigned NumTests;
diff --git a/unittests/ADT/DenseMapTest.cpp b/unittests/ADT/DenseMapTest.cpp
index f497983..9780777 100644
--- a/unittests/ADT/DenseMapTest.cpp
+++ b/unittests/ADT/DenseMapTest.cpp
@@ -46,6 +46,7 @@ public:
CtorTester(const CtorTester &Arg) : Value(Arg.Value) {
EXPECT_TRUE(Constructed.insert(this).second);
}
+ CtorTester &operator=(const CtorTester &) = default;
~CtorTester() {
EXPECT_EQ(1u, Constructed.erase(this));
}
diff --git a/unittests/ADT/HashingTest.cpp b/unittests/ADT/HashingTest.cpp
index 34eb5a5..b28561b 100644
--- a/unittests/ADT/HashingTest.cpp
+++ b/unittests/ADT/HashingTest.cpp
@@ -33,7 +33,6 @@ struct LargeTestInteger { uint64_t arr[8]; };
struct NonPOD {
uint64_t x, y;
NonPOD(uint64_t x, uint64_t y) : x(x), y(y) {}
- ~NonPOD() {}
friend hash_code hash_value(const NonPOD &obj) {
return hash_combine(obj.x, obj.y);
}
diff --git a/unittests/ADT/MapVectorTest.cpp b/unittests/ADT/MapVectorTest.cpp
index 2caa8c7..ff84642 100644
--- a/unittests/ADT/MapVectorTest.cpp
+++ b/unittests/ADT/MapVectorTest.cpp
@@ -14,6 +14,31 @@
using namespace llvm;
+TEST(MapVectorTest, swap) {
+ MapVector<int, int> MV1, MV2;
+ std::pair<MapVector<int, int>::iterator, bool> R;
+
+ R = MV1.insert(std::make_pair(1, 2));
+ ASSERT_EQ(R.first, MV1.begin());
+ EXPECT_EQ(R.first->first, 1);
+ EXPECT_EQ(R.first->second, 2);
+ EXPECT_TRUE(R.second);
+
+ EXPECT_FALSE(MV1.empty());
+ EXPECT_TRUE(MV2.empty());
+ MV2.swap(MV1);
+ EXPECT_TRUE(MV1.empty());
+ EXPECT_FALSE(MV2.empty());
+
+ auto I = MV1.find(1);
+ ASSERT_EQ(MV1.end(), I);
+
+ I = MV2.find(1);
+ ASSERT_EQ(I, MV2.begin());
+ EXPECT_EQ(I->first, 1);
+ EXPECT_EQ(I->second, 2);
+}
+
TEST(MapVectorTest, insert_pop) {
MapVector<int, int> MV;
std::pair<MapVector<int, int>::iterator, bool> R;
diff --git a/unittests/ADT/SCCIteratorTest.cpp b/unittests/ADT/SCCIteratorTest.cpp
index 3f1ba1c..da8c044 100644
--- a/unittests/ADT/SCCIteratorTest.cpp
+++ b/unittests/ADT/SCCIteratorTest.cpp
@@ -39,8 +39,6 @@ public:
NodeSubset() : Elements(0) {
assert(N <= sizeof(BitVector)*CHAR_BIT && "Graph too big!");
}
- /// NodeSubset - Copy constructor.
- NodeSubset(const NodeSubset &other) : Elements(other.Elements) {}
/// Comparison operators.
bool operator==(const NodeSubset &other) const {
@@ -252,7 +250,7 @@ TEST(SCCIteratorTest, AllSmallGraphs) {
typedef Graph<NUM_NODES> GT;
/// Enumerate all graphs using NUM_GRAPHS bits.
- assert(NUM_GRAPHS < sizeof(unsigned) * CHAR_BIT && "Too many graphs!");
+ static_assert(NUM_GRAPHS < sizeof(unsigned) * CHAR_BIT, "Too many graphs!");
for (unsigned GraphDescriptor = 0; GraphDescriptor < (1U << NUM_GRAPHS);
++GraphDescriptor) {
GT G;
diff --git a/unittests/ADT/SmallVectorTest.cpp b/unittests/ADT/SmallVectorTest.cpp
index 2bbb4ed..97ff90b 100644
--- a/unittests/ADT/SmallVectorTest.cpp
+++ b/unittests/ADT/SmallVectorTest.cpp
@@ -11,6 +11,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Compiler.h"
#include "gtest/gtest.h"
@@ -906,4 +907,22 @@ TEST(SmallVectorTest, EmplaceBack) {
}
}
+TEST(SmallVectorTest, InitializerList) {
+ SmallVector<int, 2> V1 = {};
+ EXPECT_TRUE(V1.empty());
+ V1 = {0, 0};
+ EXPECT_TRUE(makeArrayRef(V1).equals({0, 0}));
+ V1 = {-1, -1};
+ EXPECT_TRUE(makeArrayRef(V1).equals({-1, -1}));
+
+ SmallVector<int, 2> V2 = {1, 2, 3, 4};
+ EXPECT_TRUE(makeArrayRef(V2).equals({1, 2, 3, 4}));
+ V2.assign({4});
+ EXPECT_TRUE(makeArrayRef(V2).equals({4}));
+ V2.append({3, 2});
+ EXPECT_TRUE(makeArrayRef(V2).equals({4, 3, 2}));
+ V2.insert(V2.begin() + 1, 5);
+ EXPECT_TRUE(makeArrayRef(V2).equals({4, 5, 3, 2}));
+}
+
} // end namespace
diff --git a/unittests/ADT/TripleTest.cpp b/unittests/ADT/TripleTest.cpp
index 1f9aa32..1113bb6 100644
--- a/unittests/ADT/TripleTest.cpp
+++ b/unittests/ADT/TripleTest.cpp
@@ -159,6 +159,12 @@ TEST(TripleTest, ParsedIDs) {
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::UnknownOS, T.getOS());
+ T = Triple("x86_64-unknown-cloudabi");
+ EXPECT_EQ(Triple::x86_64, T.getArch());
+ EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+ EXPECT_EQ(Triple::CloudABI, T.getOS());
+ EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+
T = Triple("huh");
EXPECT_EQ(Triple::UnknownArch, T.getArch());
}
@@ -663,6 +669,10 @@ TEST(TripleTest, getARMCPUForArch) {
EXPECT_STREQ("cortex-a8", Triple.getARMCPUForArch());
EXPECT_STREQ("swift", Triple.getARMCPUForArch("armv7s"));
}
+ {
+ llvm::Triple Triple("arm--nacl");
+ EXPECT_STREQ("cortex-a8", Triple.getARMCPUForArch("arm"));
+ }
}
}
diff --git a/unittests/ADT/TwineTest.cpp b/unittests/ADT/TwineTest.cpp
index 39d3b56..9683e97 100644
--- a/unittests/ADT/TwineTest.cpp
+++ b/unittests/ADT/TwineTest.cpp
@@ -29,6 +29,7 @@ TEST(TwineTest, Construction) {
EXPECT_EQ("hi", Twine(StringRef("hi")).str());
EXPECT_EQ("hi", Twine(StringRef(std::string("hi"))).str());
EXPECT_EQ("hi", Twine(StringRef("hithere", 2)).str());
+ EXPECT_EQ("hi", Twine(SmallString<4>("hi")).str());
}
TEST(TwineTest, Numbers) {
@@ -62,6 +63,10 @@ TEST(TwineTest, Concat) {
repr(Twine("hi").concat(Twine())));
EXPECT_EQ("(Twine cstring:\"hi\" empty)",
repr(Twine().concat(Twine("hi"))));
+ EXPECT_EQ("(Twine smallstring:\"hi\" empty)",
+ repr(Twine().concat(Twine(SmallString<5>("hi")))));
+ EXPECT_EQ("(Twine smallstring:\"hey\" cstring:\"there\")",
+ repr(Twine(SmallString<7>("hey")).concat(Twine("there"))));
// Concatenation of unary ropes.
EXPECT_EQ("(Twine cstring:\"a\" cstring:\"b\")",
@@ -72,6 +77,8 @@ TEST(TwineTest, Concat) {
repr(Twine("a").concat(Twine("b")).concat(Twine("c"))));
EXPECT_EQ("(Twine cstring:\"a\" rope:(Twine cstring:\"b\" cstring:\"c\"))",
repr(Twine("a").concat(Twine("b").concat(Twine("c")))));
+ EXPECT_EQ("(Twine cstring:\"a\" rope:(Twine smallstring:\"b\" cstring:\"c\"))",
+ repr(Twine("a").concat(Twine(SmallString<3>("b")).concat(Twine("c")))));
}
TEST(TwineTest, toNullTerminatedStringRef) {
@@ -79,6 +86,9 @@ TEST(TwineTest, toNullTerminatedStringRef) {
EXPECT_EQ(0, *Twine("hello").toNullTerminatedStringRef(storage).end());
EXPECT_EQ(0,
*Twine(StringRef("hello")).toNullTerminatedStringRef(storage).end());
+ EXPECT_EQ(0, *Twine(SmallString<11>("hello"))
+ .toNullTerminatedStringRef(storage)
+ .end());
}
// I suppose linking in the entire code generator to add a unit test to check
diff --git a/unittests/ADT/ilistTest.cpp b/unittests/ADT/ilistTest.cpp
index 44442eb..9127b05 100644
--- a/unittests/ADT/ilistTest.cpp
+++ b/unittests/ADT/ilistTest.cpp
@@ -21,7 +21,8 @@ struct Node : ilist_node<Node> {
int Value;
Node() {}
- Node(int _Value) : Value(_Value) {}
+ Node(int Value) : Value(Value) {}
+ Node(const Node&) = default;
~Node() { Value = -1; }
};