Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: Added integration tests for GBNF parser #6472

Merged
merged 6 commits into from
Apr 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixing whitespace errors and cleaning error message alert to be clearer.
  • Loading branch information
HanClinto committed Apr 4, 2024
commit b7264d6efd3ff4ace549e78fe9e9d4fc896387b7
10 changes: 6 additions & 4 deletions tests/test-grammar-integration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ expr ::= term ("+" term)*
term ::= numero
number ::= [0-9]+)""";

fprintf(stderr, "NOTE: Error message (\"error parsing grammar\") expected on following line during successful test:\n");

grammar_parser::parse_state parsed_grammar = grammar_parser::parse(grammar_str.c_str());

// Ensure we did NOT parsed correctly
assert(parsed_grammar.rules.empty());

fprintf(stderr, "^ If previous line displays an error, then this test passed.\n");
fprintf(stderr, "End of expected error message. Test successful.\n");
}

static void test_simple_grammar() {
Expand Down Expand Up @@ -80,7 +82,7 @@ number ::= [0-9]+)""";

assert(completed_grammar);

// Clean up allocated memory
// Clean up allocated memory
llama_grammar_free(grammar);
}

Expand Down Expand Up @@ -222,7 +224,7 @@ ws ::= [ \t\n\r]?)""";
grammar->stacks = original_stacks;
}

// Clean up allocated memory
// Clean up allocated memory
llama_grammar_free(grammar);
}

Expand All @@ -233,4 +235,4 @@ int main() {
test_failure_missing_reference();
// Add more test cases as needed
return 0;
}
}