From 6965771d50dc1d8b1b1fb9069a7b4e5566b2b25a Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Sat, 13 Jan 2024 12:51:47 +0800 Subject: [PATCH] libnixf: check diagnostic range for parsing string --- libnixf/lib/Parse/test/Parser.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libnixf/lib/Parse/test/Parser.cpp b/libnixf/lib/Parse/test/Parser.cpp index b35ec062b..88947d381 100644 --- a/libnixf/lib/Parse/test/Parser.cpp +++ b/libnixf/lib/Parse/test/Parser.cpp @@ -80,6 +80,8 @@ TEST(Parser, StringMissingDQuote) { // Check the diagnostic. ASSERT_EQ(Diags.diags().size(), 1); auto &D = Diags.diags()[0]; + ASSERT_EQ(D->range().Begin, Src.begin() + 4); + ASSERT_EQ(D->range().End, Src.begin() + 4); ASSERT_EQ(D->kind(), Diagnostic::DK_Expected); ASSERT_EQ(D->args().size(), 1); ASSERT_EQ(D->args()[0], "\" to close string literal"); @@ -87,6 +89,8 @@ TEST(Parser, StringMissingDQuote) { // Check the note. ASSERT_EQ(D->notes().size(), 1); auto &N = D->notes()[0]; + ASSERT_EQ(N->range().Begin, Src.begin() + 0); + ASSERT_EQ(N->range().End, Src.begin() + 0); ASSERT_EQ(N->kind(), Note::NK_ToMachThis); ASSERT_EQ(N->args().size(), 1); ASSERT_EQ(N->args()[0], "\"");