| 1 |
|
package guru.mikelue.foxglove.instancio; |
| 2 |
|
|
| 3 |
|
import java.util.concurrent.TimeUnit; |
| 4 |
|
|
| 5 |
|
import org.junit.jupiter.api.AfterEach; |
| 6 |
|
import org.junit.jupiter.api.BeforeEach; |
| 7 |
|
import org.junit.jupiter.api.RepeatedTest; |
| 8 |
|
import org.junit.jupiter.api.Test; |
| 9 |
|
|
| 10 |
|
import guru.mikelue.misc.testlib.AbstractTestBase; |
| 11 |
|
|
| 12 |
|
import static org.assertj.core.api.Assertions.assertThat; |
| 13 |
|
import static org.awaitility.Awaitility.await; |
| 14 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 7 |
Complexity Density: 0.47 |
|
| 15 |
|
public class ByteArraySpecTest extends AbstractTestBase { |
| 16 |
|
private final static int REPEAT_COUNT = 8; |
| 17 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 18 |
18 |
public ByteArraySpecTest() {}... |
| 19 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 20 |
18 |
@BeforeEach... |
| 21 |
|
void setup() {} |
| 22 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 23 |
18 |
@AfterEach... |
| 24 |
|
void tearDown() {} |
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 29 |
8 |
@RepeatedTest(REPEAT_COUNT)... |
| 30 |
|
void fixedLength() |
| 31 |
|
{ |
| 32 |
8 |
final int arrayLength = gen().ints().range(16, 32).get(); |
| 33 |
|
|
| 34 |
8 |
var testedSpec = new ByteArraySpec() |
| 35 |
|
.length(arrayLength); |
| 36 |
|
|
| 37 |
8 |
byte[] testedResult = testedSpec.get(); |
| 38 |
|
|
| 39 |
8 |
assertThat(testedResult) |
| 40 |
|
.isNotNull() |
| 41 |
|
.hasSize(arrayLength) |
| 42 |
|
.doesNotContain((byte)0x00); |
| 43 |
|
} |
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 48 |
8 |
@RepeatedTest(REPEAT_COUNT)... |
| 49 |
|
void randomLength() |
| 50 |
|
{ |
| 51 |
8 |
final int minLength = 16; |
| 52 |
8 |
final int maxLength = 32; |
| 53 |
|
|
| 54 |
8 |
var testedSpec = new ByteArraySpec() |
| 55 |
|
.minLength(minLength).maxLength(maxLength); |
| 56 |
|
|
| 57 |
8 |
byte[] testedResult = testedSpec.get(); |
| 58 |
|
|
| 59 |
8 |
assertThat(testedResult) |
| 60 |
|
.isNotNull() |
| 61 |
|
.hasSizeBetween(minLength, maxLength) |
| 62 |
|
.doesNotContain((byte)0x00); |
| 63 |
|
} |
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
| 68 |
1 |
@Test... |
| 69 |
|
void nullable() |
| 70 |
|
{ |
| 71 |
1 |
var testedSpec = new ByteArraySpec() |
| 72 |
|
.nullable(); |
| 73 |
|
|
| 74 |
1 |
await() |
| 75 |
|
.atMost(5, TimeUnit.SECONDS) |
| 76 |
|
.untilAsserted(() -> { |
| 77 |
5 |
assertThat(testedSpec.get()).isNull(); |
| 78 |
|
}); |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
| 84 |
1 |
@Test... |
| 85 |
|
void zeroElements() |
| 86 |
|
{ |
| 87 |
1 |
var testedSpec = new ByteArraySpec() |
| 88 |
|
.length(512) |
| 89 |
|
.zeroElements(); |
| 90 |
|
|
| 91 |
1 |
await() |
| 92 |
|
.atMost(5, TimeUnit.SECONDS) |
| 93 |
|
.untilAsserted(() -> { |
| 94 |
1 |
assertThat(testedSpec.get()) |
| 95 |
|
.isNotNull() |
| 96 |
|
.contains((byte)0x00); |
| 97 |
|
}); |
| 98 |
|
} |
| 99 |
|
} |