You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.1KB

  1. #include <iostream>
  2. #include <string.h>
  3. #include "testrunner.hpp"
  4. using namespace std;
  5. uint8_t spec = 0;
  6. uint16_t test_passed = 0;
  7. uint16_t test_failed = 0;
  8. void _test_pass (const char *message) {
  9. if (spec) {
  10. cout << " ✓ " << message << endl;
  11. } else {
  12. cout << ".";
  13. }
  14. }
  15. void _test_fail (const char *message, const char *file, uint16_t line) {
  16. if (spec) {
  17. cout << " 𝙭 " << message << " (" << file << ":" << line << ")" << endl;
  18. } else {
  19. cout << "𝙭";
  20. }
  21. }
  22. void _test_start (const char *name) {
  23. if (spec) {
  24. cout << endl << name << endl;
  25. }
  26. }
  27. int main (int argc, char **argv) {
  28. if (argc > 1) {
  29. if ((strcmp(argv[1], "--spec") == 0) || (strcmp(argv[1], "-s") == 0)) {
  30. spec = 1;
  31. }
  32. }
  33. test(test_trigger_update, "test trigger update");
  34. test(test_trigger_reset, "test trigger reset");
  35. test(test_clock_exception, "test clock exception");
  36. test(test_clock_update, "test clock update");
  37. cout << endl << "PASSED: " << test_passed << endl << "FAILED: " << test_failed << endl;
  38. return (test_failed > 0 ? 1 : 0);
  39. }