blob: eef9c8a90af98c5f2361ed9cec3ea2e6f26a20a4 [file] [log] [blame]
Benjamin Kramer49c8ae22014-03-02 20:56:28 +00001//===- 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
13using namespace llvm;
14
15namespace {
16
17TEST(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}