-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #578 from jamesmudd/impl-extra-writeable-methods
Add implementation for more writtable dataset methods
- Loading branch information
Showing
18 changed files
with
122 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* This file is part of jHDF. A pure Java library for accessing HDF5 files. | ||
* | ||
* http://jhdf.io | ||
* | ||
* Copyright (c) 2024 James Mudd | ||
* | ||
* MIT License see 'LICENSE' file | ||
*/ | ||
package io.jhdf; | ||
|
||
import io.jhdf.api.NodeType; | ||
import io.jhdf.exceptions.HdfException; | ||
import io.jhdf.object.message.DataLayout; | ||
import org.apache.commons.lang3.ArrayUtils; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
class WritableDatasetImplTest { | ||
|
||
@Test | ||
void testGettingSize() { | ||
int[] data = new int[] {1,2,3}; | ||
WritableDatasetImpl writableDataset = new WritableDatasetImpl(data, "ints", null); | ||
assertThat(writableDataset.getSize()).isEqualTo(3); | ||
assertThat(writableDataset.getSizeInBytes()).isEqualTo(3 * 4); | ||
assertThat(writableDataset.getStorageInBytes()).isEqualTo(3 * 4); | ||
} | ||
@Test | ||
void testGettingData() { | ||
int[][] data = new int[][] {{1,2,3}, {4,5,6}}; | ||
WritableDatasetImpl writableDataset = new WritableDatasetImpl(data, "ints", null); | ||
assertThat(writableDataset.getData()).isEqualTo(new int[][] {{1,2,3}, {4,5,6}}); | ||
assertThat(writableDataset.getDataFlat()).isEqualTo(ArrayUtils.toObject(new int[] {1,2,3, 4,5,6})); | ||
assertThat(writableDataset.getDimensions()).isEqualTo(new int[]{2,3}); | ||
assertThat(writableDataset.getMaxSize()).isEqualTo(new long[]{2,3}); | ||
assertThat(writableDataset.getJavaType()).isEqualTo(int.class); | ||
assertThat(writableDataset.getDataLayout()).isEqualTo(DataLayout.CONTIGUOUS); | ||
assertThrows(HdfException.class, () -> | ||
writableDataset.getData(new long[] {1, 2}, new int[] {1, 2})); | ||
assertThat(writableDataset.getFillValue()).isNull(); | ||
assertThat(writableDataset.getFilters()).isEmpty(); | ||
assertThat(writableDataset.getDataType()).isNotNull(); | ||
} | ||
|
||
@Test | ||
void testGettingFlags() { | ||
int[][] data = new int[][] {{1,2,3}, {4,5,6}}; | ||
WritableDatasetImpl writableDataset = new WritableDatasetImpl(data, "ints", null); | ||
assertThat(writableDataset.isScalar()).isFalse(); | ||
assertThat(writableDataset.isEmpty()).isFalse(); | ||
assertThat(writableDataset.isLink()).isFalse(); | ||
assertThat(writableDataset.isGroup()).isFalse(); | ||
assertThat(writableDataset.isVariableLength()).isFalse(); | ||
assertThat(writableDataset.isCompound()).isFalse(); | ||
assertThat(writableDataset.isAttributeCreationOrderTracked()).isFalse(); | ||
assertThat(writableDataset.getType()).isEqualTo(NodeType.DATASET); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.