77import io .github .dfa1 .vortex .core .array .LongArray ;
88import io .github .dfa1 .vortex .core .array .MaskedArray ;
99import io .github .dfa1 .vortex .proto .EncodingProtos ;
10- import net .jqwik .api .ForAll ;
11- import net .jqwik .api .Property ;
12- import net .jqwik .api .constraints .Size ;
1310import org .junit .jupiter .api .Nested ;
1411import org .junit .jupiter .api .Test ;
1512import org .junit .jupiter .params .ParameterizedTest ;
1613import org .junit .jupiter .params .provider .EnumSource ;
14+ import org .junit .jupiter .params .provider .MethodSource ;
1715import org .junit .jupiter .params .provider .ValueSource ;
1816
1917import java .lang .foreign .Arena ;
2018import java .lang .foreign .MemorySegment ;
2119import java .lang .foreign .ValueLayout ;
2220import java .nio .ByteBuffer ;
21+ import java .util .Random ;
22+ import java .util .stream .Stream ;
2323
2424import static org .assertj .core .api .Assertions .assertThat ;
2525import static org .assertj .core .api .Assertions .assertThatThrownBy ;
@@ -679,10 +679,28 @@ void dict_nUniqueExceedsMax_throwsVortexException() {
679679 @ Nested
680680 class Adversarial {
681681
682+ static Stream <byte []> chunkMetaBytesProvider () {
683+ Random rng = new Random (0xDEADBEEFL );
684+ return Stream .generate (() -> {
685+ byte [] b = new byte [1 + rng .nextInt (64 )];
686+ rng .nextBytes (b );
687+ return b ;
688+ }).limit (50 );
689+ }
690+
691+ static Stream <byte []> pageBytesProvider () {
692+ Random rng = new Random (0xCAFEBABEL );
693+ return Stream .generate (() -> {
694+ byte [] b = new byte [4 + rng .nextInt (125 )];
695+ rng .nextBytes (b );
696+ return b ;
697+ }).limit (50 );
698+ }
699+
682700 /// Random chunk-meta bytes — any exception must be a VortexException, not a JVM crash exception.
683- @ Property ( tries = 50 )
684- void randomChunkMetaBytes_neverThrowsJvmException (
685- @ ForAll @ Size ( min = 1 , max = 64 ) byte [] chunkMetaBytes ) {
701+ @ ParameterizedTest
702+ @ MethodSource ( "chunkMetaBytesProvider" )
703+ void randomChunkMetaBytes_neverThrowsJvmException ( byte [] chunkMetaBytes ) {
686704 // Given — valid pco header + 1 chunk with 1 page of 1 value; garbage chunk-meta bytes.
687705 var sut = new PcoEncoding ();
688706 DecodeContext ctx = ctxWith (
@@ -700,9 +718,9 @@ void randomChunkMetaBytes_neverThrowsJvmException(
700718 }
701719
702720 /// Random page bytes after a valid Classic-mode chunk meta — must not crash the JVM.
703- @ Property ( tries = 50 )
704- void randomPageBytes_classicMode_neverThrowsJvmException (
705- @ ForAll @ Size ( min = 4 , max = 128 ) byte [] pageBytes ) {
721+ @ ParameterizedTest
722+ @ MethodSource ( "pageBytesProvider" )
723+ void randomPageBytes_classicMode_neverThrowsJvmException ( byte [] pageBytes ) {
706724 // Given — Classic mode, delta=NoOp, ansSizeLog=0, nBins=0 chunk meta.
707725 var sut = new PcoEncoding ();
708726 // byte0: mode=0 (bits3:0), deltaVariant=0 (bits7:4) → 0x00
0 commit comments