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

Function testCompressedResource

Modules/CppMicroServices/test/usModuleResourceTest.cpp:235–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233}
234
235void testCompressedResource(Module* module)
236{
237 ModuleResource res = module->GetResource("/icons/compressable.bmp");
238 checkResourceInfo(res, "/icons/", "compressable", "compressable", "bmp", "bmp", 300122, false);
239
240 ModuleResourceStream rs(res, std::ios_base::binary);
241 rs.seekg(0, std::ios_base::end);
242 std::streampos resLength = rs.tellg();
243 rs.seekg(0);
244
245 std::ifstream bmp(US_CORE_SOURCE_DIR "/test/modules/libRWithResources/resources/icons/compressable.bmp",
246 std::ifstream::in | std::ifstream::binary);
247
248 US_TEST_CONDITION_REQUIRED(bmp.is_open(), "Open reference file")
249
250 bmp.seekg(0, std::ios_base::end);
251 std::streampos bmpLength = bmp.tellg();
252 bmp.seekg(0);
253 US_TEST_CONDITION(300122 == resLength, "Check resource size")
254 US_TEST_CONDITION_REQUIRED(resLength == bmpLength, "Compare sizes")
255
256 char c1 = 0;
257 char c2 = 0;
258 bool isEqual = true;
259 int count = 0;
260 while (bmp.get(c1) && rs.get(c2))
261 {
262 ++count;
263 if (c1 != c2)
264 {
265 isEqual = false;
266 break;
267 }
268 }
269
270 US_TEST_CONDITION_REQUIRED(count == bmpLength, "Check if everything was read");
271 US_TEST_CONDITION_REQUIRED(isEqual, "Equal binary contents");
272 US_TEST_CONDITION(bmp.eof(), "EOF check");
273}
274
275struct ResourceComparator {
276 bool operator()(const ModuleResource& mr1, const ModuleResource& mr2) const

Callers 1

usModuleResourceTestFunction · 0.85

Calls 2

checkResourceInfoFunction · 0.85
GetResourceMethod · 0.80

Tested by

no test coverage detected