Audio plugin host https://kx.studio/carla
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.

76 lines
2.6KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. ControllerTest.h - CxxTest for Params/Controller
  4. Copyright (C) 2009-2011 Mark McCurry
  5. Author: Mark McCurry
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of version 2 of the GNU General Public License
  8. as published by the Free Software Foundation.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License (version 2 or later) for more details.
  13. You should have received a copy of the GNU General Public License (version 2)
  14. along with this program; if not, write to the Free Software Foundation,
  15. Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. */
  17. #include <cxxtest/TestSuite.h>
  18. #include <iostream>
  19. #include "../Params/Controller.h"
  20. #include "../globals.h"
  21. SYNTH_T *synth;
  22. class ControllerTest:public CxxTest::TestSuite
  23. {
  24. public:
  25. void setUp() {
  26. synth = new SYNTH_T;
  27. testCtl = new Controller();
  28. }
  29. void tearDown() {
  30. delete testCtl;
  31. delete synth;
  32. }
  33. void testPortamentoRange() {
  34. //Initialize portamento
  35. testCtl->setportamento(127);
  36. testCtl->portamento.time = 127;
  37. testCtl->initportamento(40.0f, 400.0f, false);
  38. //Bounds Check
  39. while(testCtl->portamento.used) {
  40. TS_ASSERT((0.0f <= testCtl->portamento.x)
  41. && (testCtl->portamento.x <= 1.0f));
  42. TS_ASSERT((0.1f <= testCtl->portamento.freqrap)
  43. && (testCtl->portamento.freqrap <= 1.0f));
  44. testCtl->updateportamento();
  45. }
  46. TS_ASSERT((0.0f <= testCtl->portamento.x)
  47. && (testCtl->portamento.x <= 1.0f));
  48. TS_ASSERT((0.1f <= testCtl->portamento.freqrap)
  49. && (testCtl->portamento.freqrap <= 1.0f));
  50. }
  51. void testPortamentoValue() {
  52. testCtl->setportamento(127);
  53. testCtl->portamento.time = 127;
  54. testCtl->initportamento(40.0f, 400.0f, false);
  55. int i;
  56. for(i = 0; i < 10; ++i)
  57. testCtl->updateportamento();
  58. //Assert that the numbers are the same as they were at release
  59. TS_ASSERT_DELTA(testCtl->portamento.x, 0.0290249f, 0.000001f)
  60. TS_ASSERT_DELTA(testCtl->portamento.freqrap, 0.126122f, 0.000001f)
  61. }
  62. private:
  63. Controller *testCtl;
  64. };