1 //===- llvm/unittest/ADT/APSIntTest.cpp - APSInt unit tests ---------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "llvm/ADT/APSInt.h" 11 #include "gtest/gtest.h" 12 13 using namespace llvm; 14 15 namespace { 16 17 TEST(APSIntTest, MoveTest) { 18 APSInt A(32, true); 19 EXPECT_TRUE(A.isUnsigned()); 20 21 APSInt B(128, false); 22 A = B; 23 EXPECT_FALSE(A.isUnsigned()); 24 25 APSInt C(B); 26 EXPECT_FALSE(C.isUnsigned()); 27 28 APInt Wide(256, 0); 29 const uint64_t *Bits = Wide.getRawData(); 30 APSInt D(std::move(Wide)); 31 EXPECT_TRUE(D.isUnsigned()); 32 EXPECT_EQ(Bits, D.getRawData()); // Verify that "Wide" was really moved. 33 34 A = APSInt(64, true); 35 EXPECT_TRUE(A.isUnsigned()); 36 37 Wide = APInt(128, 1); 38 Bits = Wide.getRawData(); 39 A = std::move(Wide); 40 EXPECT_TRUE(A.isUnsigned()); 41 EXPECT_EQ(Bits, A.getRawData()); // Verify that "Wide" was really moved. 42 } 43 44 } 45