-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62e82a8
commit 3b5c94b
Showing
3 changed files
with
182 additions
and
19 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
13 changes: 13 additions & 0 deletions
13
structs4java-maven-plugin-test/src/main/structs/null-safety.structs
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,13 @@ | ||
package org.structs4java.example.tests.nullsafety; | ||
|
||
struct StructWithByteBuffer { | ||
uint8_t buffer[10]; | ||
} | ||
|
||
struct StructWithInt32Array { | ||
int32_t array[10]; | ||
} | ||
|
||
struct StructWithStructArray { | ||
StructWithInt32Array array[10]; | ||
} |
55 changes: 55 additions & 0 deletions
55
...s4java-maven-plugin-test/src/test/java/org/structs4java/example/tests/NullSafetyTest.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,55 @@ | ||
package org.structs4java.example.tests; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
|
||
import java.io.IOException; | ||
import java.nio.ByteBuffer; | ||
|
||
import org.structs4java.example.tests.nullsafety.StructWithByteBuffer; | ||
import org.structs4java.example.tests.nullsafety.StructWithInt32Array; | ||
import org.structs4java.example.tests.nullsafety.StructWithStructArray; | ||
|
||
public class NullSafetyTest { | ||
|
||
@Test | ||
public void testWritingDefaultStructWithByteBuffer() throws IOException { | ||
ByteBuffer buffer = ByteBuffer.allocate(10); | ||
StructWithByteBuffer struct = new StructWithByteBuffer(); | ||
struct.write(buffer); | ||
} | ||
|
||
@Test | ||
public void testWritingDefaultStructWithInt32Array() throws IOException { | ||
ByteBuffer buffer = ByteBuffer.allocate(40); | ||
StructWithInt32Array struct = new StructWithInt32Array(); | ||
struct.write(buffer); | ||
} | ||
|
||
@Test | ||
public void testWritingDefaultStructWithStructArray() throws IOException { | ||
ByteBuffer buffer = ByteBuffer.allocate(400); | ||
StructWithStructArray struct = new StructWithStructArray(); | ||
struct.write(buffer); | ||
} | ||
|
||
@Test | ||
public void testDefaultStructWithInt32ArrayReturnsNotNull() { | ||
StructWithInt32Array struct = new StructWithInt32Array(); | ||
assertNotNull(struct.getArray()); | ||
} | ||
|
||
@Test | ||
public void testDefaultStructWithStructArrayReturnsNotNull() { | ||
StructWithStructArray struct = new StructWithStructArray(); | ||
assertNotNull(struct.getArray()); | ||
} | ||
|
||
@Test | ||
public void testDefaultStructWithByteBufferReturnsNotNull() { | ||
StructWithByteBuffer struct = new StructWithByteBuffer(); | ||
assertNotNull(struct.getBuffer()); | ||
} | ||
|
||
} |