Skip to content

Commit 99957a7

Browse files
committed
add test
1 parent 4da0129 commit 99957a7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

llvm/unittests/Frontend/HLSLBindingTest.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,21 @@ TEST(HLSLBindingTest, TestFindAvailable) {
273273
// In an empty space we find the slot at the beginning.
274274
EXPECT_THAT(V, HasSpecificValue(0u));
275275
}
276+
277+
// Test that add duplicate bindings are correctly de-duplicated
278+
TEST(HLSLBindingTest, TestNoOverlapWithDuplicates) {
279+
hlsl::BindingInfoBuilder Builder;
280+
281+
// We add the same binding three times, and just use `nullptr` for the cookie
282+
// so that they should all be uniqued away.
283+
Builder.trackBinding(ResourceClass::SRV, /*Space=*/0, /*LowerBound=*/5,
284+
/*UpperBound=*/5, /*Cookie=*/nullptr);
285+
Builder.trackBinding(ResourceClass::SRV, /*Space=*/0, /*LowerBound=*/5,
286+
/*UpperBound=*/5, /*Cookie=*/nullptr);
287+
Builder.trackBinding(ResourceClass::SRV, /*Space=*/0, /*LowerBound=*/5,
288+
/*UpperBound=*/5, /*Cookie=*/nullptr);
289+
bool HasOverlap;
290+
hlsl::BindingInfo Info = Builder.calculateBindingInfo(HasOverlap);
291+
292+
EXPECT_FALSE(HasOverlap);
293+
}

0 commit comments

Comments
 (0)