Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to allow NaNs for IEEE754 data types #646

Merged
merged 5 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public class FieldValueValidator {
DATE_TIME_VALID_FORMATS.put(FieldType.ASCII_TIME.getXMLType(), "hh:mm:ss[.ffffff][Z]");
}

private static List<FieldType> realTypes = Arrays.asList(
FieldType.IEEE754LSBDOUBLE,
FieldType.IEEE754LSBSINGLE,
FieldType.IEEE754MSBDOUBLE,
FieldType.IEEE754MSBSINGLE);

/** Container to capture messages. */
private ProblemListener listener;
private String parentName;
Expand Down Expand Up @@ -544,7 +550,7 @@ private void checkType(String value, FieldType type) throws InvalidTableExceptio

LOG.debug("checkType:value,type:after [{}],[{}]", value, type);

if (INF_NAN_VALUES.contains(value.toUpperCase())) {
if (INF_NAN_VALUES.contains(value.toUpperCase()) && !realTypes.contains(type)) {
throw new InvalidTableException(value + " is not allowed");
}
if (FieldType.ASCII_INTEGER.getXMLType().equals(type.getXMLType())) {
Expand Down
6 changes: 4 additions & 2 deletions src/test/resources/features/validate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Scenario Outline: Execute validate command for tests below.
| testName | testDir | messageCount | messageText | problemEnum | resourceDir | reportDir | commandArgs | refOutputValue |


# Validate#644
|"NASA-PDS/validate#644 Success NaN and Inf in FITS" | "github644" | 0 | "0 errors expected" | "totalErrors" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github644.json -s json -t {resourceDir}/github644/scam_0072_0673327336_185_cp2_scam01072_scct_41_irsalign_____04p04.xml" | "report_github644.json" |

# Validate#631
|"NASA-PDS/validate#631 Success context case matching" | "github631" | 0 | "0 errors expected" | "totalErrors" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github631.json -s json -v 1 -t {resourceDir}/github631/hyb2_tir_20180629_075501_l1.xml" | "report_github631.json" |

Expand Down Expand Up @@ -49,9 +52,8 @@ Scenario Outline: Execute validate command for tests below.
|"NASA-PDS/validate#529 Success Update Compare Scale" | "github529" | 0 | "0 errors expected" | "totalErrors" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github529_1.json -s json -t {resourceDir}/github529/success/m0154651923f6_2p_cif_gbl.xml " | "report_github529_1.json" |
# 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
# 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" | 3 | "3 errors expected" | "FIELD_VALUE_DATA_TYPE_MISMATCH" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github514_1.json -s json -t {resourceDir}/github514/success/8table.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
Loading