-
-
Notifications
You must be signed in to change notification settings - Fork 35
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 #340 from raedma/master
+ Fix and test for #338
- Loading branch information
Showing
3 changed files
with
62 additions
and
2 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
61 changes: 61 additions & 0 deletions
61
jhdf/src/test/java/io/jhdf/attribute/CompoundScalarAttributeTest.java
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,61 @@ | ||
/* | ||
* This file is part of jHDF. A pure Java library for accessing HDF5 files. | ||
* | ||
* http://jhdf.io | ||
* | ||
* Copyright (c) 2022 James Mudd | ||
* | ||
* MIT License see 'LICENSE' file | ||
*/ | ||
package io.jhdf.attribute; | ||
|
||
import io.jhdf.HdfFile; | ||
import static io.jhdf.TestUtils.loadTestHdfFile; | ||
import io.jhdf.api.Attribute; | ||
import io.jhdf.api.Node; | ||
import java.util.Map; | ||
import org.junit.jupiter.api.AfterAll; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class CompoundScalarAttributeTest { | ||
|
||
private static final String HDF5_TEST_FILE_NAME = "test_compound_scalar_attribute.hdf5"; | ||
|
||
private static HdfFile hdfFile; | ||
|
||
@BeforeAll | ||
static void setup() throws Exception { | ||
hdfFile = loadTestHdfFile(HDF5_TEST_FILE_NAME); | ||
} | ||
|
||
@AfterAll | ||
static void tearDown() { | ||
hdfFile.close(); | ||
} | ||
|
||
@Test | ||
void testReadAttribute() { | ||
|
||
Node node = hdfFile.getByPath("GROUP"); | ||
Attribute attribute = node.getAttribute("VERSION"); | ||
|
||
Object data = attribute.getData(); | ||
|
||
Map<String,int[]> dataImpl = (Map<String,int[]>)data; | ||
|
||
String key = "myMajor"; | ||
assertTrue(dataImpl.containsKey(key)); | ||
assertEquals(1,dataImpl.get(key)[0]); | ||
|
||
key = "myMinor"; | ||
assertTrue(dataImpl.containsKey(key)); | ||
assertEquals(0,dataImpl.get(key)[0]); | ||
|
||
key = "myPatch"; | ||
assertTrue(dataImpl.containsKey(key)); | ||
assertEquals(0,dataImpl.get(key)[0]); | ||
} | ||
} |
Binary file not shown.