Skip to content

Commit

Permalink
Add additional tests where lazy initialization is used
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmudd committed Nov 27, 2019
1 parent 1bb099f commit e667120
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 10 additions & 1 deletion jhdf/src/test/java/io/jhdf/btree/record/BTreeRecordTest.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* This file is part of jHDF. A pure Java library for accessing HDF5 files.
*
* http://jhdf.io
*
* Copyright 2019 James Mudd
*
* MIT License see 'LICENSE' file
*/
package io.jhdf.btree.record;

import io.jhdf.exceptions.HdfException;
Expand All @@ -24,4 +33,4 @@ void testUnsupportedRecordTypesThrow() {
void testUnreconizedRecordTypeThrows() {
assertThrows(HdfException.class, () -> BTreeRecord.readRecord(63, null, null));
}
}
}
8 changes: 8 additions & 0 deletions jhdf/src/test/java/io/jhdf/examples/TestAllFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,20 @@ private void verifyDataset(Dataset dataset, Group group) {
assertThat(dataset.getParent(), is(sameInstance(group)));
int[] dims = dataset.getDimensions();
assertThat(dims, is(notNullValue()));

// Call getAttributes twice to check lazy initialisation
assertThat(dataset.getAttributes(), is(notNullValue()));
assertThat(dataset.getAttributes(), is(notNullValue()));

assertThat(dataset.isGroup(), is(false));
assertThat(dataset.isLink(), is(false));
assertThat(dataset.getType(), is(NodeType.DATASET));
assertThat(dataset.getDataLayout(), is(notNullValue()));

// Call getData twice to check cases of lazy initialisation are working correctly
dataset.getData();
final Object data = dataset.getData();

if (dataset.isEmpty()) {
assertThat(data, is(nullValue()));
// Empty so should have 0 size
Expand Down

0 comments on commit e667120

Please sign in to comment.