# Add Test

> Add a new test assertion to the mojibake test suite Use when this capability is needed.

- Skill: `tomevault-io/add-test` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/add-test`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/add-test/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/add-test

---


# Add Test Skill

This skill helps you add a new test assertion to the mojibake library test suite.

## Test Structure

- Tests are located in the `tests/` directory
- Each test file mirrors a source file: `src/file.c` -> `tests/file.c`
- Tests use the ATT_ASSERT macro: `ATT_ASSERT(value_to_test, expected_value, comment_string)`
- Each test file has a function `void *test_<name>(void *arg)` that contains the assertions

## Instructions

When this skill is invoked, follow these steps:

1. **Identify the source file**:
   - Ask the user which source file they want to add a test for (e.g., "version", "codepoint", "breaking")
   - If the user provides a full path like `src/version.c`, extract just the base name

2. **Locate or create the test file**:
   - Check if `tests/<basename>.c` exists
   - If it doesn't exist, you'll need to:
     - Create the new test file with the standard header
     - Add a test function `void *test_<basename>(void *arg)`
     - Add the function declaration to `tests/test.h`
     - Register the test in the main test runner

3. **Get test details**:
   - Ask the user for:
     - The function or value to test (e.g., `mjb_version()`)
     - The expected value (e.g., `MJB_VERSION` or a literal value)
     - A descriptive comment (e.g., "Valid version")

4. **Add the assertion**:
   - Open the test file
   - Find the test function `void *test_<basename>(void *arg)`
   - Add the new ATT_ASSERT line before the `return NULL;` statement
   - Format: `ATT_ASSERT(value_to_test, expected_value, "comment");`

5. **Verify**:
   - Show the user the added assertion
   - Suggest running only the specific test file: `ARGS="--filter=<basename>" make test`
   - Example: `ARGS="--filter=version" make test`
   - If the test fails, run it again with `-vv` flag for verbose output to see what went wrong:
     `ARGS="--filter=<basename> -vv" make test`

## Example

For adding a test to `src/version.c`:

```c
void *test_version(void *arg) {
    ATT_ASSERT(mjb_version(), (const char*)MJB_VERSION, "Valid version");
    ATT_ASSERT(mjb_version_number(), MJB_VERSION_NUMBER, "Valid version number");
    // New assertion would be added here

    return NULL;
}
```

Run only this test with:
```bash
ARGS="--filter=version" make test
```

## Notes

- Maintain consistent indentation (4 spaces)
- Keep comments descriptive but concise
- Cast values appropriately (e.g., `(const char*)` for string comparisons)
- Place assertions in logical order (related tests together)

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/zaerl) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-13 -->

