Test Observer Source

Functions

void resetOutputStream()
TEST(ObserverPatternTest, AttachAndNotifySingleObserver)

Test attaching and notifying a single observer.

TEST(ObserverPatternTest, AttachAndNotifyMultipleObservers)

Test attaching multiple observers and verifying notifications.

TEST(ObserverPatternTest, DetachObserver)

Test detaching an observer and ensuring it no longer receives updates.

TEST(ObserverPatternTest, StateSynchronization)

Test state synchronization between subject and observers.

TEST(ObserverPatternTest, NotifyWithNoObservers)

Test notifying observers without attaching any observers.

Variables

std::ostringstream outputStream
class TestObserver : public observer_pattern::ConcreteObserver

A TestObserver that overrides update to write to the outputStream.

Public Functions

inline TestObserver(const std::string &name, std::shared_ptr<Subject> subject)
inline virtual void update() override

Updates the observer when notified by the subject.

Inner Classes