MCPcopy Create free account
hub / github.com/MITK/MITK / testResourceOperators

Function testResourceOperators

Modules/CppMicroServices/test/usModuleResourceTest.cpp:348–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

346}
347
348void testResourceOperators(Module* module)
349{
350 ModuleResource invalid = module->GetResource("invalid");
351 ModuleResource foo = module->GetResource("foo.txt");
352 US_TEST_CONDITION_REQUIRED(foo.IsValid() && foo, "Check valid resource")
353 ModuleResource foo2(foo);
354 US_TEST_CONDITION(foo == foo, "Check equality operator")
355 US_TEST_CONDITION(foo == foo2, "Check copy constructor and equality operator")
356 US_TEST_CONDITION(foo != invalid, "Check inequality with invalid resource")
357
358 ModuleResource xml = module->GetResource("/test.xml");
359 US_TEST_CONDITION_REQUIRED(xml.IsValid() && xml, "Check valid resource")
360 US_TEST_CONDITION(foo != xml, "Check inequality")
361 US_TEST_CONDITION(foo < xml, "Check operator<")
362
363 // check operator< by using a set
364 std::set<ModuleResource> resources;
365 resources.insert(foo);
366 resources.insert(foo);
367 resources.insert(xml);
368 US_TEST_CONDITION(resources.size() == 2, "Check operator< with set")
369
370 // check hash function specialization
371 std::unordered_set<ModuleResource> resources2;
372 resources2.insert(foo);
373 resources2.insert(foo);
374 resources2.insert(xml);
375 US_TEST_CONDITION(resources2.size() == 2, "Check operator< with unordered set")
376
377 // check operator<<
378 std::ostringstream oss;
379 oss << foo;
380 US_TEST_CONDITION(oss.str() == foo.GetResourcePath(), "Check operator<<")
381}
382
383void testResourceFromExecutable(Module* module)
384{

Callers 1

usModuleResourceTestFunction · 0.70

Calls 4

GetResourceMethod · 0.80
GetResourcePathMethod · 0.80
IsValidMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected