aboutsummaryrefslogtreecommitdiffstats
path: root/unittests/ADT/APSIntTest.cpp
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-04-23 16:57:46 -0700
committerStephen Hines <srhines@google.com>2014-04-24 15:53:16 -0700
commit36b56886974eae4f9c5ebc96befd3e7bfe5de338 (patch)
treee6cfb69fbbd937f450eeb83bfb83b9da3b01275a /unittests/ADT/APSIntTest.cpp
parent69a8640022b04415ae9fac62f8ab090601d8f889 (diff)
downloadexternal_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.zip
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.gz
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.bz2
Update to LLVM 3.5a.
Change-Id: Ifadecab779f128e62e430c2b4f6ddd84953ed617
Diffstat (limited to 'unittests/ADT/APSIntTest.cpp')
-rw-r--r--unittests/ADT/APSIntTest.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/unittests/ADT/APSIntTest.cpp b/unittests/ADT/APSIntTest.cpp
new file mode 100644
index 0000000..eef9c8a
--- /dev/null
+++ b/unittests/ADT/APSIntTest.cpp
@@ -0,0 +1,44 @@
+//===- llvm/unittest/ADT/APSIntTest.cpp - APSInt unit tests ---------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ADT/APSInt.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+namespace {
+
+TEST(APSIntTest, MoveTest) {
+ APSInt A(32, true);
+ EXPECT_TRUE(A.isUnsigned());
+
+ APSInt B(128, false);
+ A = B;
+ EXPECT_FALSE(A.isUnsigned());
+
+ APSInt C(B);
+ EXPECT_FALSE(C.isUnsigned());
+
+ APInt Wide(256, 0);
+ const uint64_t *Bits = Wide.getRawData();
+ APSInt D(std::move(Wide));
+ EXPECT_TRUE(D.isUnsigned());
+ EXPECT_EQ(Bits, D.getRawData()); // Verify that "Wide" was really moved.
+
+ A = APSInt(64, true);
+ EXPECT_TRUE(A.isUnsigned());
+
+ Wide = APInt(128, 1);
+ Bits = Wide.getRawData();
+ A = std::move(Wide);
+ EXPECT_TRUE(A.isUnsigned());
+ EXPECT_EQ(Bits, A.getRawData()); // Verify that "Wide" was really moved.
+}
+
+}