Mercurial > hg > CbC > CbC_llvm
comparison unittests/ADT/SmallPtrSetTest.cpp @ 148:63bd29f05246
merged
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 14 Aug 2019 19:46:37 +0900 |
parents | c2174574ed3a |
children |
comparison
equal
deleted
inserted
replaced
146:3fc4d5c3e21e | 148:63bd29f05246 |
---|---|
1 //===- llvm/unittest/ADT/SmallPtrSetTest.cpp ------------------------------===// | 1 //===- llvm/unittest/ADT/SmallPtrSetTest.cpp ------------------------------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 // | 4 // See https://llvm.org/LICENSE.txt for license information. |
5 // This file is distributed under the University of Illinois Open Source | 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 // License. See LICENSE.TXT for details. | |
7 // | 6 // |
8 //===----------------------------------------------------------------------===// | 7 //===----------------------------------------------------------------------===// |
9 // | 8 // |
10 // SmallPtrSet unit tests. | 9 // SmallPtrSet unit tests. |
11 // | 10 // |
26 SmallPtrSet<int *, 4> s1 = {&buf[0], &buf[1]}; | 25 SmallPtrSet<int *, 4> s1 = {&buf[0], &buf[1]}; |
27 SmallPtrSet<int *, 4> s2; | 26 SmallPtrSet<int *, 4> s2; |
28 (s2 = s1).insert(&buf[2]); | 27 (s2 = s1).insert(&buf[2]); |
29 | 28 |
30 // Self assign as well. | 29 // Self assign as well. |
31 (s2 = s2).insert(&buf[3]); | 30 (s2 = static_cast<SmallPtrSet<int *, 4> &>(s2)).insert(&buf[3]); |
32 | 31 |
33 s1 = s2; | 32 s1 = s2; |
34 EXPECT_EQ(4U, s1.size()); | 33 EXPECT_EQ(4U, s1.size()); |
35 for (int i = 0; i < 8; ++i) | 34 for (int i = 0; i < 8; ++i) |
36 if (i < 4) | 35 if (i < 4) |
54 for(i=0; i<8; ++i) buf[i]=0; | 53 for(i=0; i<8; ++i) buf[i]=0; |
55 | 54 |
56 | 55 |
57 SmallPtrSet<int *, 4> s; | 56 SmallPtrSet<int *, 4> s; |
58 typedef SmallPtrSet<int *, 4>::iterator iter; | 57 typedef SmallPtrSet<int *, 4>::iterator iter; |
59 | 58 |
60 s.insert(&buf[0]); | 59 s.insert(&buf[0]); |
61 s.insert(&buf[1]); | 60 s.insert(&buf[1]); |
62 s.insert(&buf[2]); | 61 s.insert(&buf[2]); |
63 s.insert(&buf[3]); | 62 s.insert(&buf[3]); |
64 EXPECT_EQ(4U, s.size()); | 63 EXPECT_EQ(4U, s.size()); |
297 for (auto F = S.find(&I), E = S.end(); F != E; ++F) | 296 for (auto F = S.find(&I), E = S.end(); F != E; ++F) |
298 ++Found[*F - Ints]; | 297 ++Found[*F - Ints]; |
299 | 298 |
300 // Sort. We should hit the first element just once and the final element N | 299 // Sort. We should hit the first element just once and the final element N |
301 // times. | 300 // times. |
302 std::sort(std::begin(Found), std::end(Found)); | 301 llvm::sort(std::begin(Found), std::end(Found)); |
303 for (auto F = std::begin(Found), E = std::end(Found); F != E; ++F) | 302 for (auto F = std::begin(Found), E = std::end(Found); F != E; ++F) |
304 EXPECT_EQ(F - Found + 1, *F); | 303 EXPECT_EQ(F - Found + 1, *F); |
305 } | 304 } |
306 | 305 |
307 // Verify that const pointers work for count and find even when the underlying | 306 // Verify that const pointers work for count and find even when the underlying |