DISTRHO Plugin Framework
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.

89 lines
3.0KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2025 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include "tests.hpp"
  17. #include "dgl.cpp"
  18. // --------------------------------------------------------------------------------------------------------------------
  19. template <typename T>
  20. static int runTestsPerType()
  21. {
  22. using DGL_NAMESPACE::Point;
  23. // basic usage
  24. {
  25. Point<T> p;
  26. DISTRHO_ASSERT_EQUAL(p.getX(), 0, "point start X value is 0");
  27. DISTRHO_ASSERT_EQUAL(p.getY(), 0, "point start Y value is 0");
  28. DISTRHO_ASSERT_EQUAL(p.isZero(), true, "point start is zero");
  29. DISTRHO_ASSERT_EQUAL(p.isNotZero(), false, "point start is for sure zero");
  30. p.setX(5);
  31. DISTRHO_ASSERT_EQUAL(p.getX(), 5, "point X value changed to 5");
  32. DISTRHO_ASSERT_EQUAL(p.getY(), 0, "point start Y value remains 0");
  33. DISTRHO_ASSERT_EQUAL(p.isZero(), false, "point after custom X is not zero");
  34. DISTRHO_ASSERT_EQUAL(p.isNotZero(), true, "point after custom X is for sure not zero");
  35. p.setY(7);
  36. DISTRHO_ASSERT_EQUAL(p.getX(), 5, "point X value remains 5");
  37. DISTRHO_ASSERT_EQUAL(p.getY(), 7, "point Y value changed to 7");
  38. DISTRHO_ASSERT_EQUAL(p.isZero(), false, "point after custom X and Y is not zero");
  39. DISTRHO_ASSERT_EQUAL(p.isNotZero(), true, "point after custom X and Y is for sure not zero");
  40. // TODO everything else
  41. }
  42. return 0;
  43. }
  44. int main()
  45. {
  46. if (const int ret = runTestsPerType<double>())
  47. return ret;
  48. if (const int ret = runTestsPerType<float>())
  49. return ret;
  50. if (const int ret = runTestsPerType<int>())
  51. return ret;
  52. if (const int ret = runTestsPerType<uint>())
  53. return ret;
  54. if (const int ret = runTestsPerType<short>())
  55. return ret;
  56. if (const int ret = runTestsPerType<ushort>())
  57. return ret;
  58. if (const int ret = runTestsPerType<long>())
  59. return ret;
  60. if (const int ret = runTestsPerType<ulong>())
  61. return ret;
  62. if (const int ret = runTestsPerType<long long>())
  63. return ret;
  64. if (const int ret = runTestsPerType<unsigned long long>())
  65. return ret;
  66. return 0;
  67. }
  68. // --------------------------------------------------------------------------------------------------------------------