mirror of
https://github.com/hyprwm/hyprlang.git
synced 2024-12-22 09:59:48 +01:00
Add multiline tests
This commit is contained in:
parent
c5d9805379
commit
a11240549a
2 changed files with 31 additions and 0 deletions
20
tests/config/multiline-errors.conf
Normal file
20
tests/config/multiline-errors.conf
Normal file
|
@ -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! \
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue