File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,40 @@ TEST(SmallSetTest, Insert) {
41
41
EXPECT_EQ (0u , s1.count (4 ));
42
42
}
43
43
44
+ TEST (SmallSetTest, InsertPerfectFwd) {
45
+ struct Value {
46
+ int Key;
47
+ bool Moved;
48
+
49
+ Value (int Key) : Key(Key), Moved(false ) {}
50
+ Value (const Value &) = default ;
51
+ Value (Value &&Other) : Key(Other.Key), Moved(false ) { Other.Moved = true ; }
52
+ bool operator ==(const Value &Other) const { return Key == Other.Key ; }
53
+ bool operator <(const Value &Other) const { return Key < Other.Key ; }
54
+ };
55
+
56
+ {
57
+ SmallSet<Value, 4 > S;
58
+ Value V1 (1 ), V2 (2 );
59
+
60
+ S.insert (V1);
61
+ EXPECT_EQ (V1.Moved , false );
62
+
63
+ S.insert (std::move (V2));
64
+ EXPECT_EQ (V2.Moved , true );
65
+ }
66
+ {
67
+ SmallSet<Value, 1 > S;
68
+ Value V1 (1 ), V2 (2 );
69
+
70
+ S.insert (V1);
71
+ EXPECT_EQ (V1.Moved , false );
72
+
73
+ S.insert (std::move (V2));
74
+ EXPECT_EQ (V2.Moved , true );
75
+ }
76
+ }
77
+
44
78
TEST (SmallSetTest, Grow) {
45
79
SmallSet<int , 4 > s1;
46
80
You can’t perform that action at this time.
0 commit comments