1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
// Copyright 2009 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#include "../catch.hpp"
#include "rkcommon/utility/Observer.h"
using namespace rkcommon::utility;
SCENARIO("Observable/Observer interfaces", "[Observers]")
{
GIVEN("A single observable and two observers")
{
Observable at;
Observer look1(at);
Observer look2(at);
THEN("Neither observer has been notified after construction")
{
REQUIRE(!look1.wasNotified());
REQUIRE(!look2.wasNotified());
}
WHEN("The observable notifies")
{
at.notifyObservers();
THEN("Both observers independently are notified exactly once")
{
REQUIRE(look1.wasNotified());
REQUIRE(look2.wasNotified());
REQUIRE(!look1.wasNotified());
REQUIRE(!look2.wasNotified());
}
}
}
}
|