MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / LoadTestFile

Function LoadTestFile

tests/cpu/UnitTestUtils.h:48–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46
47template <class LocalFileFormat, class LocalCachedFile>
48OCIO_SHARED_PTR<LocalCachedFile> LoadTestFile(
49 const std::string & fileName, std::ios_base::openmode mode)
50{
51 const std::string filePath(GetTestFilesDir() + "/" + fileName);
52
53 // Open the filePath
54 std::ifstream filestream;
55 Platform::OpenInputFileStream(filestream, filePath.c_str(), mode);
56
57 if (!filestream.is_open())
58 {
59 throw Exception("Error opening test file.");
60 }
61
62 std::string root, extension, name;
63 pystring::os::path::splitext(root, extension, filePath);
64
65 // Read file
66 LocalFileFormat tester;
67 OCIO_SHARED_PTR<CachedFile> cachedFile = tester.read(filestream, filePath, INTERP_DEFAULT);
68
69 filestream.close();
70
71 return DynamicPtrCast<LocalCachedFile>(cachedFile);
72}
73
74// Relative comparison: check if the difference between value and expected
75// relative to (divided by) expected does not exceed the eps. A minimum

Callers

nothing calls this directly

Calls 3

OpenInputFileStreamFunction · 0.85
readMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected