-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generative testing for CAD3 coded values
- Loading branch information
Showing
5 changed files
with
37 additions
and
7 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
29 changes: 29 additions & 0 deletions
29
convex-core/src/test/java/convex/test/generators/CodedValueGen.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,29 @@ | ||
package convex.test.generators; | ||
|
||
import com.pholser.junit.quickcheck.generator.GenerationStatus; | ||
import com.pholser.junit.quickcheck.random.SourceOfRandomness; | ||
|
||
import convex.core.data.ACell; | ||
import convex.core.data.CodedValue; | ||
import convex.core.data.Tag; | ||
|
||
/** | ||
* Generator for CAD3 dense records | ||
* | ||
*/ | ||
public class CodedValueGen extends AGenerator<CodedValue> { | ||
public CodedValueGen() { | ||
super(CodedValue.class); | ||
} | ||
|
||
@Override | ||
public CodedValue generate(SourceOfRandomness r, GenerationStatus status) { | ||
|
||
byte type = (byte)(r.nextInt(16)+Tag.CODE_BASE); | ||
|
||
ACell code=r.nextBoolean()?Gen.BYTE_FLAG.generate(r, status):Gen.VALUE.generate(r, status); | ||
ACell value=Gen.VALUE.generate(r, status); | ||
|
||
return CodedValue.create(type, code, value); | ||
} | ||
} |
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