Commit d0f3adf8 authored by Paal Kvamme's avatar Paal Kvamme
Browse files

More tests.

parent a4c4513b
...@@ -1658,6 +1658,79 @@ test_reopen_keepopen() ...@@ -1658,6 +1658,79 @@ test_reopen_keepopen()
// keepopen needs the exact same bulk I/O. Maybe not important. // keepopen needs the exact same bulk I/O. Maybe not important.
} }
* Similar to test_reopen_keepopen() but here the focus is on reading
* low resolution data while the file is still open for write.
* That is probably the only reason the application would call
* finalize and continue reading.
* Ideally test both the case with a single open/create and the case
* where the file is created, written, closed, reopened, written more,
* and than read lodres data. Currently do just the simple one.
* TODO-Future-@@@: The library might change to detect that the
* application is asking for stale data and recompute and store
* the data transparently to the applicaton. If this gets implemented
* then that feature would also be tested here.
* Minor: Also test that with two calls to finalize in a row there
* should be no bulk data I/O at all in the second finalize.
static void
LocalFileAutoDelete lad("reopen_rwlod.zgy");
typedef OpenZGY::IZgyWriter::size3i_t size3i_t;
using namespace OpenZGY;
SilentProgress p;
std::shared_ptr<IZgyWriter> writer =
.size(66, 100, 100)
.bricksize(8, 32, 64)
std::vector<float> data80(10*32*100, 80);
writer->write(size3i_t{0,32,0}, size3i_t{10,32,100},;
TEST_EQUAL(writer->nlods(), 1); // Not yet finalized.
std::ref(p), FinalizeAction::BuildFull);
writer = IZgyWriter::reopen
const float ten{10};
writer->write(size3i_t{0,32,1}, size3i_t{1,1,1}, &ten);
std::ref(p), FinalizeAction::BuildIncremental);
std::ref(p), FinalizeAction::BuildIncremental);
TEST_EQUAL(writer->nlods(), 5);
// Check that the low resolution sample reflects the change done
// after the first finalize. The API currently won't allow this.
// read() and readconst() don't have a "lod" parameters.
// That can easily be added but due to all the caveats, such
// as taking care of periodic finalize, it is better to keep
// the feature hidden until it is likely that it will be used.
#if 0 // TODO-@@@: Allow reading lowres data from file open for write.
float check{-1};
writer->read(size3i_t{0,32/2,0}, size3i_t{1,1,1}, &check, 1);
TEST_EQUAL(check, float(71.25));
/** /**
* Opening an empty file created by the old ZGY accessor has some * Opening an empty file created by the old ZGY accessor has some
* challenges with respect to alignment. * challenges with respect to alignment.
...@@ -1767,6 +1840,7 @@ public: ...@@ -1767,6 +1840,7 @@ public:
register_test("reopen.reopen", test_reopen); register_test("reopen.reopen", test_reopen);
register_test("reopen.incr", test_reopen_incr); register_test("reopen.incr", test_reopen_incr);
register_test("reopen.keepopen", test_reopen_keepopen); register_test("reopen.keepopen", test_reopen_keepopen);
register_test("reopen.rwlod", test_reopen_rwlod);
register_test("reopen.zgypublic", test_reopen_zgypublic); register_test("reopen.zgypublic", test_reopen_zgypublic);
register_test("reopen.track_changes", test_reopen_track_changes); register_test("reopen.track_changes", test_reopen_track_changes);
#ifdef HAVE_SD #ifdef HAVE_SD
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment