|
| 1 | +/* |
| 2 | + This file is part of Corrade. |
| 3 | +
|
| 4 | + Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, |
| 5 | + 2017, 2018, 2019 Vladimír Vondruš <[email protected]> |
| 6 | +
|
| 7 | + Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | + copy of this software and associated documentation files (the "Software"), |
| 9 | + to deal in the Software without restriction, including without limitation |
| 10 | + the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 | + and/or sell copies of the Software, and to permit persons to whom the |
| 12 | + Software is furnished to do so, subject to the following conditions: |
| 13 | +
|
| 14 | + The above copyright notice and this permission notice shall be included |
| 15 | + in all copies or substantial portions of the Software. |
| 16 | +
|
| 17 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 | + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 22 | + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 23 | + DEALINGS IN THE SOFTWARE. |
| 24 | +*/ |
| 25 | + |
| 26 | +#include "Corrade/Interconnect/Test/EmitterLibrary.h" |
| 27 | +#include "Corrade/TestSuite/Tester.h" |
| 28 | + |
| 29 | +namespace Corrade { namespace Interconnect { namespace Test { namespace { |
| 30 | + |
| 31 | +struct LibraryTest: TestSuite::Tester { |
| 32 | + explicit LibraryTest(); |
| 33 | + |
| 34 | + void test(); |
| 35 | +}; |
| 36 | + |
| 37 | +LibraryTest::LibraryTest() { |
| 38 | + addTests({&LibraryTest::test}); |
| 39 | +} |
| 40 | + |
| 41 | +void LibraryTest::test() { |
| 42 | + EmitterLibrary e; |
| 43 | + |
| 44 | + int fired = 1; |
| 45 | + connect(e, &EmitterLibrary::fireInline, [&fired]() { fired *= 2; }); |
| 46 | + connect(e, &EmitterLibrary::fireNonInline, [&fired]() { fired *= 3; }); |
| 47 | + |
| 48 | + e.fireNonInline(); |
| 49 | + CORRADE_COMPARE(fired, 3); |
| 50 | + |
| 51 | + e.fireInline(); |
| 52 | + CORRADE_COMPARE(fired, 6); |
| 53 | + |
| 54 | + e.fireNonInlineThroughAFunction(); |
| 55 | + CORRADE_COMPARE(fired, 18); |
| 56 | + |
| 57 | + { |
| 58 | + #ifdef __MINGW32__ |
| 59 | + CORRADE_EXPECT_FAIL("Inline member functions are duplicated inside and outside of the DLL when under MinGW."); |
| 60 | + #endif |
| 61 | + e.fireInlineThroughAFunction(); |
| 62 | + CORRADE_COMPARE(fired, 36); |
| 63 | + } |
| 64 | +} |
| 65 | + |
| 66 | +}}}} |
| 67 | + |
| 68 | +CORRADE_TEST_MAIN(Corrade::Interconnect::Test::LibraryTest) |
0 commit comments