29 #include <boost/test/minimal.hpp> 33 #include "streamclone.hpp" 37 std::string g_testfile;
39 int test_main (
int argc,
char * argv[])
43 const char * srcdir = getenv(
"srcdir");
45 BOOST_ASSERT(srcdir != NULL);
46 g_testfile = std::string(srcdir);
47 g_testfile +=
"/io/testfile.tmp";
52 auto file = IO::Stream::Ptr(
new IO::File(g_testfile.c_str()));
54 int ret = file->open();
55 BOOST_CHECK(ret == 0);
57 size_t r = file->read(buf1, 6);
60 BOOST_CHECK(memcmp(buf1,
"abcdef", 6) == 0);
62 off_t file_size = file->filesize();
63 BOOST_CHECK(file_size == 63);
65 const off_t clone_offset = 2;
70 BOOST_CHECK(ret == 0);
72 BOOST_CHECK(clone->filesize() == (file_size - clone_offset));
75 r = clone->read(buf2, 4);
78 BOOST_CHECK(strncmp(buf1 + clone_offset, buf2, 4) == 0);
80 uint8_t c = file->readByte();
82 BOOST_CHECK(c ==
'g');
86 int new_pos = clone->seek(0, SEEK_CUR);
87 BOOST_CHECK(new_pos == 5);
89 new_pos = clone->seek(1, SEEK_CUR);
90 BOOST_CHECK(new_pos == 6);
92 new_pos = clone->seek(2, SEEK_SET);
93 BOOST_CHECK(new_pos == 2);
96 BOOST_CHECK(c ==
'e');
98 new_pos = clone->seek(0, SEEK_CUR);
99 BOOST_CHECK(new_pos == 3);
101 c = file->readByte();
102 BOOST_CHECK(c ==
'f');
104 new_pos = clone->seek(-2, SEEK_END);
105 BOOST_CHECK(new_pos == 59);
107 c = file->readByte();
108 BOOST_CHECK(c ==
'Z');
CIFF is the container for CRW files. It is an attempt from Canon to make this a standard. I guess it failed.
cloned stream. Allow reading from a different offset