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

Function testBinaryResource

Modules/CppMicroServices/test/usModuleResourceTest.cpp:195–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195void testBinaryResource(Module* module)
196{
197 ModuleResource res = module->GetResource("/icons/cppmicroservices.png");
198 checkResourceInfo(res, "/icons/", "cppmicroservices", "cppmicroservices", "png", "png", 2598, false);
199
200 ModuleResourceStream rs(res, std::ios_base::binary);
201 rs.seekg(0, std::ios_base::end);
202 std::streampos resLength = rs.tellg();
203 rs.seekg(0);
204
205 std::ifstream png(US_CORE_SOURCE_DIR "/test/modules/libRWithResources/resources/icons/cppmicroservices.png",
206 std::ifstream::in | std::ifstream::binary);
207
208 US_TEST_CONDITION_REQUIRED(png.is_open(), "Open reference file")
209
210 png.seekg(0, std::ios_base::end);
211 std::streampos pngLength = png.tellg();
212 png.seekg(0);
213 US_TEST_CONDITION(res.GetSize() == resLength, "Check resource size")
214 US_TEST_CONDITION_REQUIRED(resLength == pngLength, "Compare sizes")
215
216 char c1 = 0;
217 char c2 = 0;
218 bool isEqual = true;
219 int count = 0;
220 while (png.get(c1) && rs.get(c2))
221 {
222 ++count;
223 if (c1 != c2)
224 {
225 isEqual = false;
226 break;
227 }
228 }
229
230 US_TEST_CONDITION_REQUIRED(count == pngLength, "Check if everything was read");
231 US_TEST_CONDITION_REQUIRED(isEqual, "Equal binary contents");
232 US_TEST_CONDITION(png.eof(), "EOF check");
233}
234
235void testCompressedResource(Module* module)
236{

Callers 1

usModuleResourceTestFunction · 0.85

Calls 3

checkResourceInfoFunction · 0.85
GetResourceMethod · 0.80
GetSizeMethod · 0.45

Tested by

no test coverage detected