Skip to content

Commit 9646500

Browse files
Tara Drwenskihaileyajohnson
authored andcommitted
Also test the coordinate values when testing the bounds
1 parent 04f2492 commit 9646500

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

cdm-test/src/test/java/ucar/nc2/iosp/grib/TestIntervalsTimeCoords2D.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
@Category(NeedsCdmUnitTest.class)
5858
public class TestIntervalsTimeCoords2D {
5959
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
60+
private static final double TOLERANCE = 1e-6;
6061

6162
@Parameterized.Parameters(name = "{0}")
6263
public static Collection<Object[]> getTestParameters() throws IOException {
@@ -113,19 +114,26 @@ public void checkTimeIntervalCoordinates() throws Exception {
113114
Variable interval = best.findVariableLocal(dimBounds);
114115
assertThat(interval != null).isTrue();
115116

117+
Variable coordinate = best.findVariableLocal(dim.getShortName());
118+
assertThat(coordinate != null).isTrue();
119+
116120
Array data = interval.read();
117121
IndexIterator iter = data.getIndexIterator();
122+
Array coordinateData = coordinate.read();
123+
IndexIterator coordinateIter = coordinateData.getIndexIterator();
118124
int idx = 0;
119125
while (iter.hasNext()) {
120126
int start = iter.getIntNext();
121127
int end = iter.getIntNext();
128+
double coordinateValue = coordinateIter.getDoubleNext();
122129
if (start != bounds[idx][0] || end != bounds[idx][1]) {
123130
logger.error("bounds " + interval.getFullName() + " for file " + filename + ", parameter " + var.getFullName()
124131
+ " failed");
125132
logger.error("interval " + start + " - " + end + " known " + bounds[idx][0] + " - " + bounds[idx][0]);
126133
}
127134
assertThat(start).isEqualTo(bounds[idx][0]);
128135
assertThat(end).isEqualTo(bounds[idx][1]);
136+
assertThat(coordinateValue).isWithin(TOLERANCE).of((start + end) / 2.0);
129137
idx++;
130138
}
131139

0 commit comments

Comments
 (0)