Skip to content

Commit

Permalink
Merge pull request #765 from NASA-PDS/issue_760
Browse files Browse the repository at this point in the history
schematron and nans
  • Loading branch information
jordanpadams authored Nov 21, 2023
2 parents fb8544c + 7e0913e commit 544f14f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/main/java/gov/nasa/pds/tools/validate/TargetExaminer.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public static boolean isTargetBundleType(URL url, boolean ignoreErrors) {
boolean targetIsBundleFlag = false;

// Do a sanity check if the file or directory exist.
if (!"file".equalsIgnoreCase(url.getProtocol())) {
return (targetIsBundleFlag);
}
if (!FileUtils.toFile(url).exists()) {
LOG.error("Provided file does not exist: {}", FileUtils.toFile(url));
return (targetIsBundleFlag);
Expand Down Expand Up @@ -85,6 +88,9 @@ public static boolean isTargetCollectionType(URL url, boolean ignoreErrors) {
boolean targetIsCollectionFlag = false;

// Do a sanity check if the file or directory exist.
if (!"file".equalsIgnoreCase(url.getProtocol())) {
return (targetIsCollectionFlag);
}
if (!FileUtils.toFile(url).exists()) {
LOG.error("Provided file does not exist: {}", FileUtils.toFile(url));
return (targetIsCollectionFlag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ private void validatePosition(Array array, ArrayObject arrayObject, ArrayLocatio
// {},{},{}",dataType,value,rangeChecker.contains(value));

if (!isSpecialConstant) {
if (!rangeChecker.contains(value)) {
if (!rangeChecker.contains(value) && !isNanOrInf(value)) {
addArrayProblem(ExceptionType.ERROR, ProblemType.ARRAY_VALUE_OUT_OF_DATA_TYPE_RANGE,
ArrayContentValidator.tableNameReportStr
+ "Value is not within the valid range of the data type '" + dataType.name() + "': "
Expand All @@ -320,6 +320,17 @@ private void validatePosition(Array array, ArrayObject arrayObject, ArrayLocatio
}
}

private boolean isNanOrInf (Number value) {
if (value instanceof Double) {
Double v = (Double)value;
return v.isInfinite() || v.isNaN();
}
if (value instanceof Float) {
Float v = (Float)value;
return v.isInfinite() || v.isNaN();
}
return false;
}
private static boolean sameContent (Number number, String constant_repr) {
if (constant_repr == null) return false;
if (number.toString().equals(constant_repr)) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/features/developer.feature
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Scenario Outline: Execute validate command for tests below.
# fixed: |"NASA-PDS/validate#529 Fail Update Compare Scale" | "github529" | 1 | "1 errors expected" | "ARRAY_VALUE_OUT_OF_MIN_MAX_RANGE" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github529_2.json -s json -t {resourceDir}/github529/fail/m0126360726f4_2p_cif_gbl.xml " | "report_github529_2.json" |

# Validate#514 - binary tables should allow NaN
|"NASA-PDS/validate#514 Success Update Compare Scale" | "github514" | 3 | "3 errors expected" | "ARRAY_VALUE_OUT_OF_DATA_TYPE_RANGE" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github514_1.json -s json -t {resourceDir}/github514/success/8array.xml" | "report_github514_1.json" |
|"NASA-PDS/validate#514 Success Update Compare Scale" | "github514" | 0 | "0 errors expected" | "totalErrors" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github514_1.json -s json -t {resourceDir}/github514/success/8array.xml" | "report_github514_1.json" |

# Validate#499
|"NASA-PDS/validate#499 Success Table EOL" | "github499" | 0 | "0 errors expected" | "totalErrors" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github499_1.json -s json -t {resourceDir}/github499/success/M7_217_044546_N.xml" | "report_github499_1.json" |
Expand Down

0 comments on commit 544f14f

Please sign in to comment.