@@ -71,6 +71,50 @@ TEST(AutoDiffIndexSubset, Equality) {
71
71
/* indices*/ {}));
72
72
}
73
73
74
+ TEST (AutoDiffIndexSubset, Initializers) {
75
+ TestContext ctx;
76
+ // Default init.
77
+ EXPECT_EQ (AutoDiffIndexSubset::getDefault (ctx.Ctx , /* capacity*/ 5 ,
78
+ /* includeAll*/ true ),
79
+ AutoDiffIndexSubset::get (ctx.Ctx , /* capacity*/ 5 ,
80
+ /* indices*/ {0 , 1 , 2 , 3 , 4 }));
81
+ EXPECT_EQ (AutoDiffIndexSubset::getDefault (ctx.Ctx , /* capacity*/ 5 ,
82
+ /* includeAll*/ false ),
83
+ AutoDiffIndexSubset::get (ctx.Ctx , /* capacity*/ 5 , /* indices*/ {}));
84
+ EXPECT_EQ (AutoDiffIndexSubset::getDefault (ctx.Ctx , /* capacity*/ 0 ,
85
+ /* includeAll*/ true ),
86
+ AutoDiffIndexSubset::get (ctx.Ctx , /* capacity*/ 0 ,
87
+ /* indices*/ {}));
88
+ EXPECT_EQ (AutoDiffIndexSubset::getDefault (ctx.Ctx , /* capacity*/ 0 ,
89
+ /* includeAll*/ false ),
90
+ AutoDiffIndexSubset::get (ctx.Ctx , /* capacity*/ 0 , /* indices*/ {}));
91
+ // Bit vector init.
92
+ {
93
+ llvm::SmallBitVector bitVec (6 );
94
+ bitVec.set (1 , 4 );
95
+ EXPECT_EQ (AutoDiffIndexSubset::get (ctx.Ctx , bitVec),
96
+ AutoDiffIndexSubset::get (ctx.Ctx , /* capacity*/ 6 ,
97
+ /* indices*/ {1 , 2 , 3 }));
98
+ }
99
+ {
100
+ llvm::SmallBitVector bitVec (0 );
101
+ EXPECT_EQ (AutoDiffIndexSubset::get (ctx.Ctx , bitVec),
102
+ AutoDiffIndexSubset::get (ctx.Ctx , /* capacity*/ 0 ,
103
+ /* indices*/ {}));
104
+ }
105
+ // String init.
106
+ EXPECT_EQ (AutoDiffIndexSubset::getFromString (ctx.Ctx , " SSSSS" ),
107
+ AutoDiffIndexSubset::get (ctx.Ctx , /* capacity*/ 5 ,
108
+ /* indices*/ {0 , 1 , 2 , 3 , 4 }));
109
+ EXPECT_EQ (AutoDiffIndexSubset::getFromString (ctx.Ctx , " UUUUU" ),
110
+ AutoDiffIndexSubset::get (ctx.Ctx , /* capacity*/ 5 , /* indices*/ {}));
111
+ EXPECT_EQ (AutoDiffIndexSubset::getFromString (ctx.Ctx , " SUSUS" ),
112
+ AutoDiffIndexSubset::get (ctx.Ctx , /* capacity*/ 5 ,
113
+ /* indices*/ {0 , 2 , 4 }));
114
+ EXPECT_EQ (AutoDiffIndexSubset::getFromString (ctx.Ctx , " " ),
115
+ AutoDiffIndexSubset::get (ctx.Ctx , /* capacity*/ 0 , /* indices*/ {}));
116
+ }
117
+
74
118
TEST (AutoDiffIndexSubset, Bits) {
75
119
TestContext ctx;
76
120
auto *indices1 = AutoDiffIndexSubset::get (ctx.Ctx , /* capacity*/ 5 ,
0 commit comments