This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
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 #1519 from finos/1517-random-upperbound-functionality
1517 random upperbound functionality
- Loading branch information
Showing
7 changed files
with
86 additions
and
65 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
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
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
...com/scottlogic/deg/generator/generation/fieldvaluesources/LinearFieldValueSourceTest.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 com.scottlogic.deg.generator.generation.fieldvaluesources; | ||
|
||
import com.scottlogic.deg.common.profile.NumericGranularity; | ||
import com.scottlogic.deg.generator.restrictions.linear.LinearRestrictions; | ||
import com.scottlogic.deg.generator.utils.JavaUtilRandomNumberGenerator; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.Collections; | ||
import java.util.stream.Stream; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class LinearFieldValueSourceTest { | ||
|
||
@Test | ||
public void testGenerateRandomValues() { | ||
LinearRestrictions<BigDecimal> restrictions = new LinearRestrictions<>( | ||
BigDecimal.ZERO, | ||
BigDecimal.valueOf(4), | ||
new NumericGranularity(0)); | ||
LinearFieldValueSource<BigDecimal> source = new LinearFieldValueSource<>(restrictions, Collections.emptySet()); | ||
|
||
Stream<BigDecimal> results = source.generateRandomValues(new JavaUtilRandomNumberGenerator()); | ||
|
||
assertTrue(results.limit(100).allMatch(x -> x.intValue() >= 0 & x.intValue() < 5)); | ||
} | ||
|
||
} |
Oops, something went wrong.