Skip to content

debug() and debugFlag are never exercised by the sample program #6

Description

@dmccoystephenson

src/testing.cpp defines a debug helper and a debugFlag that gates it, but neither is exercised by the sample program:

bool debugFlag = true;

/**
 * Log a debug message to the console.
 */
void debug(std::string message) {
    if (debugFlag) {
        std::cout << "[DEBUG] " << message << std::endl;
    }
}

int main() {
    std::string toPrint = "Hello World!";
    log(toPrint);
    return 0;
}

A grep over the file confirms that debug appears only in its own definition and doc comment, and that debugFlag is read only from inside debug. Running the built binary therefore demonstrates log and nothing else, so the debugFlag gate is never shown to work either way.

Since the sample program is the only demonstration this template offers that it builds and runs correctly, a helper that is shipped but never demonstrated is a gap: it is neither exercised nor removed.

Proposed resolution: either call debug from main so that running ./testing demonstrates both log levels, or delete debug and debugFlag if a minimal sample is preferred. Calling it is suggested, as the flag-gated pattern is the more useful thing for a template to show.

Note that this change alters program output, so whoever implements it should build and run the binary to record the new expected output.

This issue was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions