diff --git a/tests/config/multiline-errors.conf b/tests/config/multiline-errors.conf new file mode 100644 index 0000000..9ea2c28 --- /dev/null +++ b/tests/config/multiline-errors.conf @@ -0,0 +1,20 @@ +# Careful when modifying this file. Line numbers are part of the test. + +multiline = \ + one \ + two \ + three + +# Line numbers reported in errors should match the actual line numbers of the source file +# even after multi-line configs. Any errors reported should use the line number of the +# first line of any multi-line config. + +this \ + should \ + cause \ + error \ + on \ + line \ + 12 + +# A config file cannot end with a bashslash because we are expecting another line! Even in a comment! \ diff --git a/tests/parse/main.cpp b/tests/parse/main.cpp index 0fc05c9..521376d 100755 --- a/tests/parse/main.cpp +++ b/tests/parse/main.cpp @@ -302,6 +302,17 @@ int main(int argc, char** argv, char** envp) { EXPECT(ERRORS2.error, true); const auto ERRORSTR2 = std::string{ERRORS2.getError()}; EXPECT(std::count(ERRORSTR2.begin(), ERRORSTR2.end(), '\n'), 9 - 1); + + Hyprlang::CConfig multilineErrorConfig("./config/multiline-errors.conf", {.verifyOnly = true, .throwAllErrors = true}); + multilineErrorConfig.commence(); + const auto ERRORS3 = multilineErrorConfig.parse(); + EXPECT(ERRORS3.error, true); + const auto ERRORSTR3 = std::string{ERRORS3.getError()}; + + // Error on line 12 + EXPECT(ERRORSTR3.contains("12"), true); + // Backslash at end of file + EXPECT(ERRORSTR3.contains("backslash"), true); } catch (const char* e) { std::cout << Colors::RED << "Error: " << Colors::RESET << e << "\n"; return 1;