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.

75 lines
2.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, "trigger update");
  34. test(test_trigger_reset, "trigger reset");
  35. test(test_clock_exception, "clock exception");
  36. test(test_clock_update, "clock update");
  37. test(test_primeclock_exception, "primeclock exception");
  38. test(test_primeclock_primes, "primeclock primes");
  39. test(test_primeclock_update, "primeclock update");
  40. test(test_bjorklund_exception, "bjorklund exception");
  41. test(test_bjorklund_update_exception, "bjorklund update exception");
  42. test(test_bjorklund_update, "bjorklund update");
  43. test(test_bjorklund_reset, "bjorklund reset");
  44. test(test_distributedclock_master, "distributed clock master");
  45. test(test_distributedclock_servant, "distributed clock servant");
  46. test(test_fibonacciclock_exception, "fibonacciclock exception");
  47. test(test_fibonacciclock_fibonaccis, "fibonacciclock fibonaccis");
  48. test(test_fibonacciclock_update, "fibonacciclock update");
  49. test(test_event_emitter, "event emitter");
  50. test(test_event_emitter_on, "event emitter on");
  51. test(test_event_emitter_clear, "event emitter clear");
  52. test(test_event_emitter_listener, "event emitter listeners");
  53. test(test_cv_event, "cv event");
  54. test(test_cv_event_update, "cv event update");
  55. test(test_cv_event_resets, "cv event resets");
  56. cout << endl << "PASSED: " << test_passed << endl << "FAILED: " << test_failed << endl;
  57. return (test_failed > 0 ? 1 : 0);
  58. }