Skip to content

Add simpler method for test generation#266

Open
zbreit wants to merge 4 commits into
blopker:mainfrom
zbreit:feature/simplify-c-tests
Open

Add simpler method for test generation#266
zbreit wants to merge 4 commits into
blopker:mainfrom
zbreit:feature/simplify-c-tests

Conversation

@zbreit
Copy link
Copy Markdown
Contributor

@zbreit zbreit commented May 10, 2026

While generating test code for C and C++, I found that manually specifying WordLocations was quite tedious. It made it challenging to add new test cases when testing new language features.

To simplify this process, this commit adds the get_marked_misspellings() function, which takes in an input string where all expected misspellings are marked using start/end delimiters. The function returns a struct containing:

  1. The input string with the delimiters removed.
  2. All of the marked misspellings.

You can use this function to quickly test lots of functionality using simple-to-create input files.

As an example, I converted the C-language tests to use this new functionality. As a result of the testing, I identified and fixed a bug related to enum, struct, and union specifiers. Previously, codebook would flag Structt, Enumm and Unionn in the following code snippet:

   struct Structt a;
   enum Enumm a;
   union Unionn a;

zbreit added 4 commits May 10, 2026 15:24
While generating test code for C and C++, I found that manually
specifying WordLocations was quite tedious. It made it challenging to
add new test cases when testing new language features.

To simplify this process, this commit adds the
`get_marked_misspellings()` function, which takes in an input string
where all expected misspellings are marked using start/end delimiters.
The function returns a struct containing:
1. The input string with the delimiters removed.
2. All of the marked misspellings.

You can use this function to quickly test lots of functionality using
simple-to-create input files.
Word locations are not deterministically ordered, so we need to sort
them before comparing the sequences for equality.
@zbreit
Copy link
Copy Markdown
Contributor Author

zbreit commented May 10, 2026

Wasn't sure what you thought of this approach, but I think it makes writing tests a bit easier. Let me know if you have any suggestions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant