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.

93 lines
3.1KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2024 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. #define DPF_TEST_POINT_CPP
  18. #include "dgl/src/Application.cpp"
  19. #include "dgl/src/ApplicationPrivateData.cpp"
  20. #include "dgl/src/Geometry.cpp"
  21. // --------------------------------------------------------------------------------------------------------------------
  22. template <typename T>
  23. static int runTestsPerType()
  24. {
  25. using DGL_NAMESPACE::Point;
  26. // basic usage
  27. {
  28. Point<T> p;
  29. DISTRHO_ASSERT_EQUAL(p.getX(), 0, "point start X value is 0");
  30. DISTRHO_ASSERT_EQUAL(p.getY(), 0, "point start Y value is 0");
  31. DISTRHO_ASSERT_EQUAL(p.isZero(), true, "point start is zero");
  32. DISTRHO_ASSERT_EQUAL(p.isNotZero(), false, "point start is for sure zero");
  33. p.setX(5);
  34. DISTRHO_ASSERT_EQUAL(p.getX(), 5, "point X value changed to 5");
  35. DISTRHO_ASSERT_EQUAL(p.getY(), 0, "point start Y value remains 0");
  36. DISTRHO_ASSERT_EQUAL(p.isZero(), false, "point after custom X is not zero");
  37. DISTRHO_ASSERT_EQUAL(p.isNotZero(), true, "point after custom X is for sure not zero");
  38. p.setY(7);
  39. DISTRHO_ASSERT_EQUAL(p.getX(), 5, "point X value remains 5");
  40. DISTRHO_ASSERT_EQUAL(p.getY(), 7, "point Y value changed to 7");
  41. DISTRHO_ASSERT_EQUAL(p.isZero(), false, "point after custom X and Y is not zero");
  42. DISTRHO_ASSERT_EQUAL(p.isNotZero(), true, "point after custom X and Y is for sure not zero");
  43. // TODO everything else
  44. }
  45. return 0;
  46. }
  47. int main()
  48. {
  49. if (const int ret = runTestsPerType<double>())
  50. return ret;
  51. if (const int ret = runTestsPerType<float>())
  52. return ret;
  53. if (const int ret = runTestsPerType<int>())
  54. return ret;
  55. if (const int ret = runTestsPerType<uint>())
  56. return ret;
  57. if (const int ret = runTestsPerType<short>())
  58. return ret;
  59. if (const int ret = runTestsPerType<ushort>())
  60. return ret;
  61. if (const int ret = runTestsPerType<long>())
  62. return ret;
  63. if (const int ret = runTestsPerType<ulong>())
  64. return ret;
  65. if (const int ret = runTestsPerType<long long>())
  66. return ret;
  67. if (const int ret = runTestsPerType<unsigned long long>())
  68. return ret;
  69. return 0;
  70. }
  71. // --------------------------------------------------------------------------------------------------------------------