Skip to content

Commit

Permalink
Add tests for new functions added
Browse files Browse the repository at this point in the history
Signed-off-by: Kimball Thurston <[email protected]>
  • Loading branch information
kdt3rd committed Apr 20, 2024
1 parent 25090e4 commit c0aec27
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/test/OpenEXRCoreTest/read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,36 @@ testReadMeta (const std::string& tempdir)
exr_context_initializer_t cinit = EXR_DEFAULT_CONTEXT_INITIALIZER;
cinit.error_handler_fn = &err_cb;
exr_attribute_t* newattr;
uint32_t verflags;
uint64_t cto;

EXRCORE_TEST_RVAL (exr_test_file_header (fn.c_str (), &cinit));
EXRCORE_TEST_RVAL (exr_start_read (&f, fn.c_str (), &cinit));
EXRCORE_TEST_RVAL_FAIL (
EXR_ERR_MISSING_CONTEXT_ARG,
exr_get_file_version_and_flags (NULL, NULL));
EXRCORE_TEST_RVAL_FAIL (
EXR_ERR_INVALID_ARGUMENT,
exr_get_file_version_and_flags (f, NULL));
EXRCORE_TEST_RVAL (
exr_get_file_version_and_flags (f, &verflags));
EXRCORE_TEST (verflags == 2);

EXRCORE_TEST_RVAL_FAIL (
EXR_ERR_MISSING_CONTEXT_ARG,
exr_get_chunk_table_offset (NULL, 0, NULL));
EXRCORE_TEST_RVAL_FAIL (
EXR_ERR_ARGUMENT_OUT_OF_RANGE,
exr_get_chunk_table_offset (f, -1, NULL));
EXRCORE_TEST_RVAL_FAIL (
EXR_ERR_ARGUMENT_OUT_OF_RANGE,
exr_get_chunk_table_offset (f, 2, NULL));
EXRCORE_TEST_RVAL_FAIL (
EXR_ERR_INVALID_ARGUMENT,
exr_get_chunk_table_offset (f, 0, NULL));
EXRCORE_TEST_RVAL (
exr_get_chunk_table_offset (f, 0, &cto));
EXRCORE_TEST (cto == 331);

EXRCORE_TEST_RVAL_FAIL (
EXR_ERR_NOT_OPEN_WRITE,
Expand Down
27 changes: 27 additions & 0 deletions src/test/OpenEXRCoreTest/write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ testStartWriteDeepScan (const std::string& tempdir)
EXRCORE_TEST_RVAL (exr_get_storage (outf, partidx, &storage));
EXRCORE_TEST (storage == EXR_STORAGE_DEEP_SCANLINE);

uint32_t verflags;
EXRCORE_TEST_RVAL (
exr_get_file_version_and_flags (outf, &verflags));
EXRCORE_TEST (verflags == (2 | 0x00000800));

EXRCORE_TEST_RVAL (exr_finish (&outf));
remove (outfn.c_str ());
}
Expand Down Expand Up @@ -248,6 +253,11 @@ testStartWriteDeepTile (const std::string& tempdir)
EXRCORE_TEST_RVAL (exr_get_storage (outf, partidx, &storage));
EXRCORE_TEST (storage == EXR_STORAGE_DEEP_TILED);

uint32_t verflags;
EXRCORE_TEST_RVAL (
exr_get_file_version_and_flags (outf, &verflags));
EXRCORE_TEST (verflags == (2 | 0x00000800));

EXRCORE_TEST_RVAL (exr_finish (&outf));
remove (outfn.c_str ());
}
Expand All @@ -258,6 +268,7 @@ testWriteBaseHeader (const std::string& tempdir)
exr_context_t outf;
std::string outfn = tempdir + "testattr.exr";
int partidx;
uint32_t verflags;

exr_context_initializer_t cinit = EXR_DEFAULT_CONTEXT_INITIALIZER;
cinit.error_handler_fn = &err_cb;
Expand Down Expand Up @@ -464,6 +475,14 @@ testWriteBaseHeader (const std::string& tempdir)
1));

EXRCORE_TEST_RVAL (exr_write_header (outf));
EXRCORE_TEST_RVAL (
exr_get_file_version_and_flags (outf, &verflags));
EXRCORE_TEST (verflags == 2);

uint64_t cto;
EXRCORE_TEST_RVAL (
exr_get_chunk_table_offset (outf, 0, &cto));
EXRCORE_TEST (cto == 364);

EXRCORE_TEST_RVAL (exr_finish (&outf));
remove (outfn.c_str ());
Expand Down Expand Up @@ -533,6 +552,9 @@ testWriteBaseHeader (const std::string& tempdir)
EXRCORE_TEST (txsize == 32 && tysize == 32);

EXRCORE_TEST_RVAL (exr_write_header (outf));
EXRCORE_TEST_RVAL (
exr_get_file_version_and_flags (outf, &verflags));
EXRCORE_TEST (verflags == (2 | 0x00000200));

EXRCORE_TEST_RVAL (exr_finish (&outf));
remove (outfn.c_str ());
Expand Down Expand Up @@ -1366,6 +1388,11 @@ testWriteMultiPart (const std::string& tempdir)
EXRCORE_TEST_RVAL (exr_get_storage (outf, 1, &storage));
EXRCORE_TEST (storage == EXR_STORAGE_TILED);

uint32_t verflags;
EXRCORE_TEST_RVAL (
exr_get_file_version_and_flags (outf, &verflags));
EXRCORE_TEST (verflags == (2 | 0x00001000));

EXRCORE_TEST_RVAL (exr_finish (&outf));
remove (outfn.c_str ());
}

0 comments on commit c0aec27

Please sign in to comment.