Skip to content

Commit

Permalink
Use tolerance when comparing doubles
Browse files Browse the repository at this point in the history
  • Loading branch information
Tara Drwenski committed Jan 10, 2024
1 parent 332b2ad commit 10f775f
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static com.google.common.truth.Truth.assertThat;

public class TestEnhancements {
private static final double TOLERANCE = 1.0e-5;

final static String ENHANCED_FILE = "localContent/testOffset.nc";
final static String NCML_ENHANCED_FILE = "testOffsetWithNcml.nc";
Expand Down Expand Up @@ -73,7 +74,7 @@ private void checkResultWithEnhancements(NetcdfFile netcdfFile, int expectedDiff
final Array values1 = enhancedVar.read();
final Array values2 = orgVar.read();
for (int i = 0; i < values1.getSize(); i++) {
assertThat(values1.getDouble(i)).isEqualTo(values2.getDouble(i) + expectedDiff);
assertThat(values1.getDouble(i)).isWithin(TOLERANCE).of(values2.getDouble(i) + expectedDiff);
}
}
}

0 comments on commit 10f775f

Please sign in to comment.