VST3: fetch midi mappings all at once, use it for note/sound-off
[carla.git] / source / tests.old / Exceptions.cpp
blob965c0b97066f6d349c1784ce1ef5e889976f1d89
1 /*
2 * Carla Exception Tests
3 * Copyright (C) 2013-2014 Filipe Coelho <falktx@falktx.com>
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.
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.
15 * For a full copy of the GNU General Public License see the doc/GPL.txt file.
18 #include "CarlaDefines.h"
19 #include "CarlaJuceUtils.hpp"
21 // -----------------------------------------------------------------------
23 struct Struct1 {
24 Struct1() noexcept : leakDetector_Struct1() {}
25 ~Struct1() noexcept {}
27 void throwHere()
29 throw 1;
32 CARLA_LEAK_DETECTOR(Struct1)
35 struct Struct2 {
36 Struct2() : leakDetector_Struct2() { throw 2; }
37 ~Struct2() noexcept {}
39 CARLA_LEAK_DETECTOR(Struct2)
42 // -----------------------------------------------------------------------
44 int main()
46 carla_safe_assert("test here", __FILE__, __LINE__);
48 Struct1 a1;
49 Struct1* b1;
50 Struct2* c2 = nullptr;
52 try {
53 a1.throwHere();
54 } CARLA_SAFE_EXCEPTION("Struct1 a throw");
56 try {
57 b1 = new Struct1;
58 } CARLA_SAFE_EXCEPTION("NOT POSSIBLE! Struct1 b throw constructor");
60 assert(b1 != nullptr);
62 try {
63 b1->throwHere();
64 } CARLA_SAFE_EXCEPTION("Struct1 b throw runtime");
66 delete b1;
67 b1 = nullptr;
69 try {
70 c2 = new Struct2;
71 } CARLA_SAFE_EXCEPTION("Struct2 c throw");
73 assert(c2 == nullptr);
75 return 0;
78 // -----------------------------------------------------------------------