Browse Source

Tidied up ListenerList tests

tags/2021-05-28
tpoole 8 years ago
parent
commit
2f00cb1b75
1 changed files with 4 additions and 20 deletions
  1. +4
    -20
      modules/juce_core/containers/juce_ListenerList.cpp

+ 4
- 20
modules/juce_core/containers/juce_ListenerList.cpp View File

@@ -75,23 +75,15 @@ class ListenerListTests : public UnitTest
public: public:
ListenerListTests() : UnitTest ("ListenerList") {} ListenerListTests() : UnitTest ("ListenerList") {}
template <typename T>
void callHelper (std::vector<int>& expectedCounterValues, T v)
template <typename... Args>
void callHelper (std::vector<int>& expectedCounterValues)
{ {
counter = 0;
listeners.call (&ListenerBase::f, v);
expect (counter == expectedCounterValues[1]);
counter = 0; counter = 0;
listeners.call (&ListenerBase::f); listeners.call (&ListenerBase::f);
expect (counter == expectedCounterValues[0]); expect (counter == expectedCounterValues[0]);
ListenerList<ListenerBase>::DummyBailOutChecker boc; ListenerList<ListenerBase>::DummyBailOutChecker boc;
counter = 0;
listeners.callChecked (boc, &ListenerBase::f, v);
expect (counter == expectedCounterValues[1]);
counter = 0; counter = 0;
listeners.callChecked (boc, &ListenerBase::f); listeners.callChecked (boc, &ListenerBase::f);
expect (counter == expectedCounterValues[0]); expect (counter == expectedCounterValues[0]);
@@ -114,24 +106,16 @@ public:
callHelper (expectedCounterValues, args...); callHelper (expectedCounterValues, args...);
} }
template <typename T>
template <typename... Args>
void callExcludingHelper (ListenerBase& listenerToExclude, void callExcludingHelper (ListenerBase& listenerToExclude,
std::vector<int>& expectedCounterValues, T v)
std::vector<int>& expectedCounterValues)
{ {
counter = 0;
listeners.callExcluding (listenerToExclude, &ListenerBase::f, v);
expect (counter == expectedCounterValues[1]);
counter = 0; counter = 0;
listeners.callExcluding (listenerToExclude, &ListenerBase::f); listeners.callExcluding (listenerToExclude, &ListenerBase::f);
expect (counter == expectedCounterValues[0]); expect (counter == expectedCounterValues[0]);
ListenerList<ListenerBase>::DummyBailOutChecker boc; ListenerList<ListenerBase>::DummyBailOutChecker boc;
counter = 0;
listeners.callCheckedExcluding (listenerToExclude, boc, &ListenerBase::f, v);
expect (counter == expectedCounterValues[1]);
counter = 0; counter = 0;
listeners.callCheckedExcluding (listenerToExclude, boc, &ListenerBase::f); listeners.callCheckedExcluding (listenerToExclude, boc, &ListenerBase::f);
expect (counter == expectedCounterValues[0]); expect (counter == expectedCounterValues[0]);


Loading…
Cancel
Save