diff --git a/src/test/java/gov/usgs/earthquake/nshmp/data/SequencesTests.java b/src/test/java/gov/usgs/earthquake/nshmp/data/SequencesTests.java index 5f2c3721ca720d39909b9b03e0db2063417f270c..975d9755af4a9a805526bb360db339a85b10b6d3 100644 --- a/src/test/java/gov/usgs/earthquake/nshmp/data/SequencesTests.java +++ b/src/test/java/gov/usgs/earthquake/nshmp/data/SequencesTests.java @@ -14,32 +14,38 @@ import com.google.common.collect.ImmutableList; class SequencesTests { - private static final double[] xs1 = new double[] { 0, 1, 2, 3 }; - private static final double[] xs2 = new double[] { 1, 2, 3, 4 }; - private static final double[] xs3 = new double[] { 5, 6, 7 }; - - private static final double[] ys1 = new double[] { 10, 9, 8, 7 }; - private static final double[] ys2 = new double[] { 5, 4, 3, 2 }; - private static final double[] ys3 = new double[] { 10, 9, 8 }; - - private static final XySequence xyBase = XySequence.create(xs1, ys1); - private static final XySequence xySameXs = XySequence.create(xs1, ys2); - private static final XySequence xyDifferentXs = XySequence.create(xs2, ys2); - private static final XySequence xyShorter = XySequence.create(xs3, ys3); + private static final XySequence xyBase; + private static final XySequence xySameXs; + private static final XySequence xyDifferentXs; + private static final XySequence xyShorter; private static final List<XySequence> emptyCollection; private static final List<XySequence> singleSequence; - private static final XySequence expectedSingleSequenceResults; private static final List<XySequence> identicalSequences; - private static final XySequence expectedIdenticalSequences; private static final List<XySequence> sameXs; - private static final XySequence expectedSameXs; private static final List<XySequence> differentXs; - private static final XySequence expectedDifferentXs; private static final List<XySequence> withShorterXs; + + private static final XySequence expectedSingleSequenceResults; + private static final XySequence expectedIdenticalSequences; + private static final XySequence expectedSameXs; + private static final XySequence expectedDifferentXs; private static final XySequence expectedWithShorterXs; static { + double[] xs1 = new double[] { 0, 1, 2, 3 }; + double[] xs2 = new double[] { 1, 2, 3, 4 }; + double[] xs3 = new double[] { 5, 6, 7 }; + + double[] ys1 = new double[] { 10, 9, 8, 7 }; + double[] ys2 = new double[] { 5, 4, 3, 2 }; + double[] ys3 = new double[] { 10, 9, 8 }; + + xyBase = XySequence.create(xs1, ys1); + xySameXs = XySequence.create(xs1, ys2); + xyDifferentXs = XySequence.create(xs2, ys2); + xyShorter = XySequence.create(xs3, ys3); + emptyCollection = new ImmutableList.Builder<XySequence>().build(); singleSequence = new ImmutableList.Builder<XySequence>() @@ -47,6 +53,7 @@ class SequencesTests { .build(); expectedSingleSequenceResults = xyBase; + // add two copies of the same sequence identicalSequences = new ImmutableList.Builder<XySequence>() .add(xyBase) .add(xyBase) @@ -55,6 +62,7 @@ class SequencesTests { Arrays.setAll(result, i -> ys1[i] + ys1[i]); expectedIdenticalSequences = XySequence.create(xs1, result); + // sequences with the same x-values (similar) sameXs = new ImmutableList.Builder<XySequence>() .add(xyBase) .add(xySameXs) @@ -62,6 +70,7 @@ class SequencesTests { Arrays.setAll(result, i -> ys1[i] + ys2[i]); expectedSameXs = XySequence.create(xs1, result); + // sequences with different x-values differentXs = new ImmutableList.Builder<XySequence>() .add(xyBase) .add(xyDifferentXs) @@ -71,6 +80,7 @@ class SequencesTests { new double[] { 0, 1, 2, 3, 4 }, new double[] { 10, 14, 12, 10, 2 }); + // sequences with different x-values and different length withShorterXs = new ImmutableList.Builder<XySequence>() .add(xyBase) .add(xyDifferentXs)