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

Function usModuleManifestTest

Modules/CppMicroServices/test/usModuleManifestTest.cpp:36–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34} // end unnamed namespace
35
36int usModuleManifestTest(int /*argc*/, char* /*argv*/[])
37{
38 US_TEST_BEGIN("ModuleManifestTest");
39
40 SharedLibrary target(LIB_PATH, "TestModuleM");
41
42 try
43 {
44 target.Load();
45 }
46 catch (const std::exception& e)
47 {
48 US_TEST_FAILED_MSG( << "Failed to load module, got exception: "
49 << e.what() << " + in frameSL02a:FAIL" );
50 }
51
52 Module* moduleM = ModuleRegistry::GetModule("TestModuleM");
53 US_TEST_CONDITION_REQUIRED(moduleM != nullptr, "Test for existing module TestModuleM")
54
55 US_TEST_CONDITION(moduleM->GetProperty(Module::PROP_NAME()).ToString() == "TestModuleM", "Module name")
56 US_TEST_CONDITION(moduleM->GetName() == "TestModuleM", "Module name 2")
57 US_TEST_CONDITION(moduleM->GetProperty(Module::PROP_DESCRIPTION()).ToString() == "My Module description", "Module description")
58 US_TEST_CONDITION(moduleM->GetLocation() == moduleM->GetProperty(Module::PROP_LOCATION()).ToString(), "Module location")
59 US_TEST_CONDITION(moduleM->GetProperty(Module::PROP_VERSION()).ToString() == "1.0.0", "Module version")
60 US_TEST_CONDITION(moduleM->GetVersion() == ModuleVersion(1,0,0), "Module version 2")
61
62 Any anyVector = moduleM->GetProperty("vector");
63 US_TEST_CONDITION_REQUIRED(anyVector.Type() == typeid(std::vector<Any>), "vector type")
64 std::vector<Any>& vec = ref_any_cast<std::vector<Any> >(anyVector);
65 US_TEST_CONDITION_REQUIRED(vec.size() == 3, "vector size")
66 US_TEST_CONDITION_REQUIRED(vec[0].Type() == typeid(std::string), "vector 0 type")
67 US_TEST_CONDITION_REQUIRED(vec[0].ToString() == "first", "vector 0 value")
68 US_TEST_CONDITION_REQUIRED(vec[1].Type() == typeid(int), "vector 1 type")
69 US_TEST_CONDITION_REQUIRED(any_cast<int>(vec[1]) == 2, "vector 1 value")
70
71 Any anyMap = moduleM->GetProperty("map");
72 US_TEST_CONDITION_REQUIRED(anyMap.Type() == typeid(std::map<std::string,Any>), "map type")
73 std::map<std::string, Any>& m = ref_any_cast<std::map<std::string, Any> >(anyMap);
74 US_TEST_CONDITION_REQUIRED(m.size() == 3, "map size")
75 US_TEST_CONDITION_REQUIRED(m["string"].Type() == typeid(std::string), "map 0 type")
76 US_TEST_CONDITION_REQUIRED(m["string"].ToString() == "hi", "map 0 value")
77 US_TEST_CONDITION_REQUIRED(m["number"].Type() == typeid(int), "map 1 type")
78 US_TEST_CONDITION_REQUIRED(any_cast<int>(m["number"]) == 4, "map 1 value")
79 US_TEST_CONDITION_REQUIRED(m["list"].Type() == typeid(std::vector<Any>), "map 2 type")
80 US_TEST_CONDITION_REQUIRED(any_cast<std::vector<Any> >(m["list"]).size() == 2, "map 2 value size")
81
82 target.Unload();
83
84 US_TEST_END()
85}

Callers

nothing calls this directly

Calls 10

whatMethod · 0.80
GetVersionMethod · 0.80
LoadMethod · 0.45
ToStringMethod · 0.45
GetPropertyMethod · 0.45
GetNameMethod · 0.45
GetLocationMethod · 0.45
TypeMethod · 0.45
sizeMethod · 0.45
UnloadMethod · 0.45

Tested by

no test coverage detected