An open API service indexing awesome lists of open source software.

https://github.com/willem3141/knighttest

Quick-and-dirty unit test runner for KnightOS
https://github.com/willem3141/knighttest

Last synced: 2 months ago
JSON representation

Quick-and-dirty unit test runner for KnightOS

Awesome Lists containing this project

README

        

# knighttest
A quick-and-dirty unit test runner for KnightOS. This still is heavy work in progress.

## Writing tests
To add tests, edit the file `tests.asm`. Create a function that performs the test, like this:

````
testSomething:
; perform the test

; if passed:
kjp(pass)
; if failed:
kjp(fail)
````

Then in the test table at the top of the file, insert the name of your test, and increment the number:

````
tests:
.db 2 ; number of tests ; <- incremented
.dw testTrivial
.dw testSomething ; <- added
````

Now recompile the test runner and run it.

## Debugging
knighttest supports a very rudimentary way of debugging. If a test fails, you can look what is going on by doing this:

````
kjp(printDebugAndHalt)
````

Now, the values of the `d`, `e`, `h` and `l` registers will be printed to the screen and the execution will halt (`jr $`).

## Macros
The test runner provides several macros that can be used to write tests more easily.

| Macro | Description |
| --------------------------- | ----------------------------------------------- |
| `assertAEqualTo(expected)` | Fails if `a` doesn't match the expected value. |
| `assertBEqualTo(expected)` | Fails if `b` doesn't match the expected value. |
| `assertCEqualTo(expected)` | Fails if `c` doesn't match the expected value. |
| `assertDEqualTo(expected)` | Fails if `d` doesn't match the expected value. |
| `assertEEqualTo(expected)` | Fails if `e` doesn't match the expected value. |
| `assertHEqualTo(expected)` | Fails if `h` doesn't match the expected value. |
| `assertLEqualTo(expected)` | Fails if `l` doesn't match the expected value. |
| `assertBCEqualTo(expected)` | Fails if `bc` doesn't match the expected value. |
| `assertDEEqualTo(expected)` | Fails if `de` doesn't match the expected value. |
| `assertHLEqualTo(expected)` | Fails if `hl` doesn't match the expected value. |
| `assertIXEqualTo(expected)` | Fails if `ix` doesn't match the expected value. |