| 23 | using namespace us; |
| 24 | |
| 25 | int usNullEventTest(int /*argc*/, char* /*argv*/[]) |
| 26 | { |
| 27 | US_TEST_BEGIN("NullEventTest"); |
| 28 | |
| 29 | // Regression: default-constructed ModuleEvent previously crashed in |
| 30 | // GetModule()/GetType(). GetModule() now returns nullptr, GetType() throws. |
| 31 | { |
| 32 | ModuleEvent evt; |
| 33 | US_TEST_CONDITION(evt.IsNull(), "default ModuleEvent is null") |
| 34 | US_TEST_CONDITION(evt.GetModule() == nullptr, |
| 35 | "default ModuleEvent::GetModule() returns nullptr") |
| 36 | US_TEST_FOR_EXCEPTION(std::logic_error, evt.GetType()) |
| 37 | } |
| 38 | |
| 39 | // Regression: default-constructed ServiceEvent previously crashed in |
| 40 | // GetServiceReference()/GetType(). GetServiceReference() now returns an |
| 41 | // invalid reference, GetType() throws. |
| 42 | { |
| 43 | ServiceEvent evt; |
| 44 | US_TEST_CONDITION(evt.IsNull(), "default ServiceEvent is null") |
| 45 | ServiceReferenceU ref = evt.GetServiceReference(); |
| 46 | US_TEST_CONDITION(!ref, |
| 47 | "default ServiceEvent::GetServiceReference() returns invalid ref") |
| 48 | US_TEST_FOR_EXCEPTION(std::logic_error, evt.GetType()) |
| 49 | } |
| 50 | |
| 51 | // Regression: operator<<(ostream, Module*) previously dereferenced a null |
| 52 | // pointer. It now writes "null". |
| 53 | { |
| 54 | std::ostringstream os; |
| 55 | os << static_cast<Module*>(nullptr); |
| 56 | US_TEST_CONDITION(os.str() == "null", |
| 57 | "operator<< on null Module* writes \"null\"") |
| 58 | } |
| 59 | |
| 60 | US_TEST_END() |
| 61 | } |
nothing calls this directly
no test coverage detected