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.

67 lines
1.4KB

  1. #include "testrunner.hpp"
  2. #include "../src/Bjorklund.hpp"
  3. using namespace SynthDevKit;
  4. uint8_t test_bjorklund_exception ( ) {
  5. bool has_exception = 0;
  6. Bjorklund *b = {0};
  7. try {
  8. b = new Bjorklund(MAX_SLOTS + 1);
  9. } catch (int err) {
  10. has_exception = true;
  11. }
  12. check(!b, "clock is null");
  13. check(has_exception, "exception is thrown");
  14. done();
  15. }
  16. uint8_t test_bjorklund_update_exception ( ) {
  17. bool has_exception = 0;
  18. Bjorklund *b;
  19. b = new Bjorklund(MAX_SLOTS);
  20. try {
  21. b->update(3, MAX_SLOTS + 1);
  22. } catch (int err) {
  23. has_exception = true;
  24. }
  25. check(has_exception, "exception is thrown");
  26. done();
  27. }
  28. uint8_t test_bjorklund_update ( ) {
  29. Bjorklund *b = new Bjorklund(13);
  30. b->update(5, 8);
  31. check(b->stepValue() == 1, "first value is 1");
  32. check(b->stepValue() == 0, "second value is 0");
  33. check(b->stepValue() == 1, "third value is 1");
  34. check(b->stepValue() == 1, "fourth value is 1");
  35. check(b->stepValue() == 0, "fifth value is 0");
  36. check(b->stepValue() == 1, "sixth value is 1");
  37. check(b->stepValue() == 1, "seventh value is 1");
  38. check(b->stepValue() == 0, "eighth value is 0");
  39. done();
  40. }
  41. uint8_t test_bjorklund_reset ( ) {
  42. Bjorklund *b = new Bjorklund(13);
  43. b->update(5, 8);
  44. check(b->stepValue() == 1, "first value is 1");
  45. b->reset();
  46. check(b->stepValue() == 1, "first value after reset is 1");
  47. done();
  48. }