Skip to content

Commit 2467c34

Browse files
committed
review: add missing param error testcase
1 parent 21d31c5 commit 2467c34

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedEndOfStreamTest) {
377377
ASSERT_TRUE(Consumer->isSatisfied());
378378
}
379379

380-
TEST_F(ParseHLSLRootSignatureTest, InvalidMissingParameterTest) {
380+
TEST_F(ParseHLSLRootSignatureTest, InvalidMissingDTParameterTest) {
381381
// This test will check that the parsing fails due a mandatory
382382
// parameter (register) not being specified
383383
const llvm::StringLiteral Source = R"cc(
@@ -401,6 +401,28 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingParameterTest) {
401401
ASSERT_TRUE(Consumer->isSatisfied());
402402
}
403403

404+
TEST_F(ParseHLSLRootSignatureTest, InvalidMissingRCParameterTest) {
405+
// This test will check that the parsing fails due a mandatory
406+
// parameter (num32BitConstants) not being specified
407+
const llvm::StringLiteral Source = R"cc(
408+
RootConstants(b0)
409+
)cc";
410+
411+
TrivialModuleLoader ModLoader;
412+
auto PP = createPP(Source, ModLoader);
413+
auto TokLoc = SourceLocation();
414+
415+
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
416+
SmallVector<RootElement> Elements;
417+
hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
418+
419+
// Test correct diagnostic produced
420+
Consumer->setExpected(diag::err_hlsl_rootsig_missing_param);
421+
ASSERT_TRUE(Parser.parse());
422+
423+
ASSERT_TRUE(Consumer->isSatisfied());
424+
}
425+
404426
TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryDTParameterTest) {
405427
// This test will check that the parsing fails due the same mandatory
406428
// parameter being specified multiple times

0 commit comments

Comments
 (0)