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
- Host: GitHub
- URL: https://github.com/willem3141/knighttest
- Owner: Willem3141
- License: mit
- Created: 2015-01-19T19:09:32.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-08-13T22:18:48.000Z (almost 6 years ago)
- Last Synced: 2025-03-24T11:19:02.551Z (2 months ago)
- Language: Assembly
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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. |