@@ -111,10 +111,39 @@ class ParseHLSLRootSignatureTest : public ::testing::Test {
111111
112112// Valid Lexing Tests
113113
114+ TEST_F (ParseHLSLRootSignatureTest, ValidLexNumbersTest) {
115+ // This test will check that we can lex different number tokens
116+ const llvm::StringLiteral Source = R"cc(
117+ -42 42 +42
118+ )cc" ;
119+
120+ TrivialModuleLoader ModLoader;
121+ auto PP = CreatePP (Source, ModLoader);
122+ auto TokLoc = SourceLocation ();
123+
124+ // Test no diagnostics produced
125+ Consumer->SetNoDiag ();
126+
127+ hlsl::RootSignatureLexer Lexer (Source, TokLoc, *PP);
128+
129+ SmallVector<hlsl::RootSignatureToken> Tokens;
130+ ASSERT_FALSE (Lexer.Lex (Tokens));
131+ ASSERT_TRUE (Consumer->IsSatisfied ());
132+
133+ SmallVector<hlsl::TokenKind> Expected = {
134+ hlsl::TokenKind::int_literal,
135+ hlsl::TokenKind::int_literal,
136+ hlsl::TokenKind::int_literal,
137+ };
138+ CheckTokens (Tokens, Expected);
139+ }
140+
114141TEST_F (ParseHLSLRootSignatureTest, ValidLexAllTokensTest) {
115142 // This test will check that we can lex all defined tokens as defined in
116143 // HLSLRootSignatureTokenKinds.def, plus some additional integer variations
117144 const llvm::StringLiteral Source = R"cc(
145+ 42
146+
118147 (),|=
119148 )cc" ;
120149
@@ -144,6 +173,46 @@ TEST_F(ParseHLSLRootSignatureTest, ValidLexAllTokensTest) {
144173
145174// Invalid Lexing Tests
146175
176+ TEST_F (ParseHLSLRootSignatureTest, InvalidLexOverflowedNumberTest) {
177+ // This test will check that the lexing fails due to an integer overflow
178+ const llvm::StringLiteral Source = R"cc(
179+ 4294967296
180+ )cc" ;
181+
182+ TrivialModuleLoader ModLoader;
183+ auto PP = CreatePP (Source, ModLoader);
184+ auto TokLoc = SourceLocation ();
185+
186+ // Test correct diagnostic produced
187+ Consumer->SetExpected (diag::err_hlsl_number_literal_overflow);
188+
189+ hlsl::RootSignatureLexer Lexer (Source, TokLoc, *PP);
190+
191+ SmallVector<hlsl::RootSignatureToken> Tokens;
192+ ASSERT_TRUE (Lexer.Lex (Tokens));
193+ ASSERT_TRUE (Consumer->IsSatisfied ());
194+ }
195+
196+ TEST_F (ParseHLSLRootSignatureTest, InvalidLexEmptyNumberTest) {
197+ // This test will check that the lexing fails due to no integer being provided
198+ const llvm::StringLiteral Source = R"cc(
199+ -
200+ )cc" ;
201+
202+ TrivialModuleLoader ModLoader;
203+ auto PP = CreatePP (Source, ModLoader);
204+ auto TokLoc = SourceLocation ();
205+
206+ // Test correct diagnostic produced
207+ Consumer->SetExpected (diag::err_hlsl_invalid_number_literal);
208+
209+ hlsl::RootSignatureLexer Lexer (Source, TokLoc, *PP);
210+
211+ SmallVector<hlsl::RootSignatureToken> Tokens;
212+ ASSERT_TRUE (Lexer.Lex (Tokens));
213+ ASSERT_TRUE (Consumer->IsSatisfied ());
214+ }
215+
147216TEST_F (ParseHLSLRootSignatureTest, InvalidLexIdentifierTest) {
148217 // This test will check that the lexing fails due to no valid token
149218 const llvm::StringLiteral Source = R"cc(
0 commit comments