use of java.util.stream.DoubleStream in project assertj-core by joel-costigliola.
the class Assertions_assertThat_with_DoubleStream_Test method isNotSameAs_should_check_the_original_stream_without_consuming_it.
@Test
void isNotSameAs_should_check_the_original_stream_without_consuming_it() {
DoubleStream stream = mock(DoubleStream.class);
try {
assertThat(stream).isNotSameAs(stream);
} catch (AssertionError e) {
verifyNoInteractions(stream);
return;
}
Assertions.fail("Expected assertionError, because assert notSame on same stream.");
}
use of java.util.stream.DoubleStream in project latexdraw by arnobl.
the class DoubleSupplier method getValueSources.
@Override
public List<PotentialAssignment> getValueSources(final ParameterSignature sig) {
final DoubleData doubledata = sig.getAnnotation(DoubleData.class);
DoubleStream stream = Arrays.stream(doubledata.vals());
if (doubledata.angle()) {
stream = DoubleStream.of(0d, Math.PI / 2d, Math.PI, 3d * Math.PI / 2d, 2d * Math.PI, -Math.PI / 2d, -Math.PI, -3d * Math.PI / 2d, -2d * Math.PI, 1.234, -1.234, 3d * Math.PI, -3d * Math.PI);
}
if (doubledata.bads()) {
stream = DoubleStream.concat(stream, DoubleStream.of(Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY));
}
return stream.mapToObj(i -> PotentialAssignment.forValue("", i)).collect(Collectors.toList());
}
use of java.util.stream.DoubleStream in project sis by apache.
the class DoubleStreamWrapper method delegate.
/**
* Same as {@link #source()} but marks this stream is inactive.
* All subsequent operations must be done on the returned stream.
* This is used for {@code map(…)} and {@code flatMap(…)} operations.
*
* @return the stream containing actual data.
* @throws IllegalStateException if this stream is no longer the active stream on which to apply operations.
*/
final DoubleStream delegate() {
final DoubleStream s = source();
source = null;
return s;
}
use of java.util.stream.DoubleStream in project jdk8u_jdk by JetBrains.
the class ConcatTest method assertDoubleConcat.
private void assertDoubleConcat(Stream<Integer> s1, Stream<Integer> s2, boolean parallel, boolean ordered) {
DoubleStream result = DoubleStream.concat(s1.mapToDouble(Integer::doubleValue), s2.mapToDouble(Integer::doubleValue));
assertEquals(result.isParallel(), parallel);
assertConcatContent(result.spliterator(), ordered, expected.stream().mapToDouble(Integer::doubleValue).spliterator());
}
use of java.util.stream.DoubleStream in project Synthese_2BIN by TheYoungSensei.
the class Exercice4Nombres method main.
public static void main(String[] args) {
double[] tabDouble = new Random().doubles(10, 0, 100).toArray();
DoubleStream sDouble = new Random().doubles(1000);
System.out.println(DoubleStream.of(tabDouble).map(Math::sqrt).sum());
randomNums(10).limit(5).forEach(System.out::println);
randomNumsD(10).limit(5).forEach(System.out::println);
List<Double> randomNums1D = randomNumsD(10).limit(10).collect(Collectors.toList());
System.out.println("List of random nums: " + randomNums1D);
List<Double> randomNums1 = randomNums(10).limit(10).boxed().collect(Collectors.toList());
System.out.println("List of random nums: " + randomNums1);
double[] randomNums2 = randomNums(10).limit(20).toArray();
System.out.println("Array of random nums: " + Arrays.asList(randomNums2));
Double[] randomNumsD = randomNumsD(10).limit(20).toArray(Double[]::new);
}
Aggregations