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.

75 lines
1.7KB

  1. /*
  2. * Carla Exception Tests
  3. * Copyright (C) 2013-2014 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #include "CarlaDefines.h"
  18. #include "CarlaUtils.hpp"
  19. // -----------------------------------------------------------------------
  20. struct Struct1 {
  21. Struct1() noexcept {}
  22. ~Struct1() noexcept {}
  23. void throwHere()
  24. {
  25. throw 1;
  26. }
  27. };
  28. struct Struct2 {
  29. Struct2() { throw 2; }
  30. ~Struct2() noexcept {}
  31. };
  32. // -----------------------------------------------------------------------
  33. int main()
  34. {
  35. carla_safe_assert("test here", __FILE__, __LINE__);
  36. Struct1 a;
  37. Struct1* b;
  38. Struct2* c = nullptr;
  39. try {
  40. a.throwHere();
  41. } CARLA_SAFE_EXCEPTION("Struct1 a throw");
  42. try {
  43. b = new Struct1;
  44. } CARLA_SAFE_EXCEPTION("Struct1 b throw constructor");
  45. assert(b != nullptr);
  46. try {
  47. b->throwHere();
  48. } CARLA_SAFE_EXCEPTION("Struct1 b throw runtime");
  49. delete b;
  50. b = nullptr;
  51. try {
  52. c = new Struct2;
  53. } CARLA_SAFE_EXCEPTION("Struct2 c throw");
  54. assert(c == nullptr);
  55. return 0;
  56. }
  57. // -----------------------------------------------------------------------