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.

91 lines
3.0KB

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