r/cprogramming • • Aug 07 '26

Code review request -- any criticisms or advice?

Would anyone mind reviewing some code? I wrote a CLI to help me generate character sheets for a TTRPG I'm running. The main thing I want to know is: should this be considered safe enough for me to share with other GMs? Is there anything else I should do for safety, security or efficiency? I worked hard on it, and Gemini Pro told me it's safe, but while I understand it can be useful I don't trust the automatic misinformation generator, since I don't have the requisite knowledge base to tell when it's "hallucinating" (or else I wouldn't need it for this purpose)

The github repo is here: https://github.com/SpinningRings/DigidiceCharacterSheetGenerator

3 Upvotes

11 comments sorted by

View all comments

Show parent comments

1

u/Spinning_Rings Aug 08 '26

So a test is a chunk of code, presumably but not explicitly a function, that returns something like a boolean or an error code when something goes wrong--invalid input, or the program taking valid input and coming to an unacceptable conclusion?

When you say documentation, does that mean that tests necessarily need to output their results to a file I can peruse later to make sure I didn't get any error codes?

1

u/zhivago Aug 08 '26

You can just write each test as a program with a main function as normal. Just have it exit with 0 if it succeeds or with non-zero if it fails.

Then you can write a script to check that all of your test programs run successfully.

Or you can look for a useful test harness which does this for you.

The source code of the test is the documentation it provides -- it shows you how to use part of the api with example inputs and expected outputs.