@@ -254,7 +254,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidSamplerFlagsTest) {
254254
255255TEST_F (ParseHLSLRootSignatureTest, ValidParseRootConsantsTest) {
256256 const llvm::StringLiteral Source = R"cc(
257- RootConstants()
257+ RootConstants(num32BitConstants = 1, b0),
258+ RootConstants(b42, num32BitConstants = 4294967295)
258259 )cc" ;
259260
260261 TrivialModuleLoader ModLoader;
@@ -270,10 +271,19 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootConsantsTest) {
270271
271272 ASSERT_FALSE (Parser.parse ());
272273
273- ASSERT_EQ (Elements.size (), 1u );
274+ ASSERT_EQ (Elements.size (), 2u );
274275
275276 RootElement Elem = Elements[0 ];
276277 ASSERT_TRUE (std::holds_alternative<RootConstants>(Elem));
278+ ASSERT_EQ (std::get<RootConstants>(Elem).Num32BitConstants , 1u );
279+ ASSERT_EQ (std::get<RootConstants>(Elem).Reg .ViewType , RegisterType::BReg);
280+ ASSERT_EQ (std::get<RootConstants>(Elem).Reg .Number , 0u );
281+
282+ Elem = Elements[1 ];
283+ ASSERT_TRUE (std::holds_alternative<RootConstants>(Elem));
284+ ASSERT_EQ (std::get<RootConstants>(Elem).Num32BitConstants , 4294967295u );
285+ ASSERT_EQ (std::get<RootConstants>(Elem).Reg .ViewType , RegisterType::BReg);
286+ ASSERT_EQ (std::get<RootConstants>(Elem).Reg .Number , 42u );
277287
278288 ASSERT_TRUE (Consumer->isSatisfied ());
279289}
@@ -367,7 +377,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedEndOfStreamTest) {
367377 ASSERT_TRUE (Consumer->isSatisfied ());
368378}
369379
370- TEST_F (ParseHLSLRootSignatureTest, InvalidMissingParameterTest ) {
380+ TEST_F (ParseHLSLRootSignatureTest, InvalidMissingDTParameterTest ) {
371381 // This test will check that the parsing fails due a mandatory
372382 // parameter (register) not being specified
373383 const llvm::StringLiteral Source = R"cc(
@@ -391,7 +401,29 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingParameterTest) {
391401 ASSERT_TRUE (Consumer->isSatisfied ());
392402}
393403
394- TEST_F (ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryParameterTest) {
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+
426+ TEST_F (ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryDTParameterTest) {
395427 // This test will check that the parsing fails due the same mandatory
396428 // parameter being specified multiple times
397429 const llvm::StringLiteral Source = R"cc(
@@ -415,6 +447,28 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryParameterTest) {
415447 ASSERT_TRUE (Consumer->isSatisfied ());
416448}
417449
450+ TEST_F (ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryRCParameterTest) {
451+ // This test will check that the parsing fails due the same mandatory
452+ // parameter being specified multiple times
453+ const llvm::StringLiteral Source = R"cc(
454+ RootConstants(num32BitConstants = 32, num32BitConstants = 24)
455+ )cc" ;
456+
457+ TrivialModuleLoader ModLoader;
458+ auto PP = createPP (Source, ModLoader);
459+ auto TokLoc = SourceLocation ();
460+
461+ hlsl::RootSignatureLexer Lexer (Source, TokLoc);
462+ SmallVector<RootElement> Elements;
463+ hlsl::RootSignatureParser Parser (Elements, Lexer, *PP);
464+
465+ // Test correct diagnostic produced
466+ Consumer->setExpected (diag::err_hlsl_rootsig_repeat_param);
467+ ASSERT_TRUE (Parser.parse ());
468+
469+ ASSERT_TRUE (Consumer->isSatisfied ());
470+ }
471+
418472TEST_F (ParseHLSLRootSignatureTest, InvalidRepeatedOptionalParameterTest) {
419473 // This test will check that the parsing fails due the same optional
420474 // parameter being specified multiple times
0 commit comments