From 861df2ae60a83fc83a68777aefc4366efc888bbd Mon Sep 17 00:00:00 2001 From: Michael Beckerle Date: Mon, 18 Nov 2024 12:13:54 -0500 Subject: [PATCH] Added tests of decimalSigned to show that it fails in a few cases. Tests show that parse of negative representations (from packed decimal reps) does not detect the error when decimalSigned="no". Test aalso show that unparse of negative values into binary, packed, and bcd all are broken. This doesn't fix the issue. Just adds tests to illustrate the failing cases. DAFFODIL-2957 --- .../section13/decimal/TestDecimalSigned.tdml | 157 ++++++++++++++++++ .../section13/decimal/TestDecimalSigned.scala | 60 +++++++ 2 files changed, 217 insertions(+) create mode 100644 daffodil-test/src/test/resources/org/apache/daffodil/section13/decimal/TestDecimalSigned.tdml create mode 100644 daffodil-test/src/test/scala/org/apache/daffodil/section13/decimal/TestDecimalSigned.scala diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section13/decimal/TestDecimalSigned.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section13/decimal/TestDecimalSigned.tdml new file mode 100644 index 0000000000..2c077e397e --- /dev/null +++ b/daffodil-test/src/test/resources/org/apache/daffodil/section13/decimal/TestDecimalSigned.tdml @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + FF85 + + + + 654.13 + + + + + + + + -1.23 + + + + + Unparse Error + unsigned + + + + + + D123 + + + Parse Error + 13 + + + + + + + -1.23 + + + + + 0123 + + + + + + + 123D + + + + Parse Error + unsigned + + + + + + + -1.23 + + + + Unparse Error + unsigned + + + + + + + D123 + + + + Parse Error + unsigned + + + + + + + -1.23 + + + + Unparse Error + unsigned + + + + + diff --git a/daffodil-test/src/test/scala/org/apache/daffodil/section13/decimal/TestDecimalSigned.scala b/daffodil-test/src/test/scala/org/apache/daffodil/section13/decimal/TestDecimalSigned.scala new file mode 100644 index 0000000000..c9ada291cb --- /dev/null +++ b/daffodil-test/src/test/scala/org/apache/daffodil/section13/decimal/TestDecimalSigned.scala @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.daffodil.section13.decimal + +import org.apache.daffodil.tdml.Runner + +import org.junit.AfterClass +import org.junit.Test + +object TestDecimalSigned { + val testDir = "/org/apache/daffodil/section13/decimal/" + val runner: Runner = Runner(testDir, "TestDecimalSigned.tdml") + + @AfterClass def shutDown(): Unit = { + runner.reset + } +} +class TestDecimalSigned { + import TestDecimalSigned._ + + @Test def parseTestDecimalSigned_no_binary(): Unit = + runner.runOneTest("parseTestDecimalSigned_no_binary") + @Test def parseTestdecimalSigned_no_bcd(): Unit = + runner.runOneTest("parseTestdecimalSigned_no_bcd") + +// DAFFODIL-2957 - the tests below all failing +// Abort with usage error. Should be unparse error. +// @Test def unparseTestDecimalSigned_no_binary(): Unit = +// runner.runOneTest("unparseTestDecimalSigned_no_binary") +// error not detected +// @Test def unparseTestdecimalSigned_no_bcd(): Unit = +// runner.runOneTest("unparseTestdecimalSigned_no_bcd") +// error not detected +// @Test def parseTestDecimalSigned_no_packed(): Unit = +// runner.runOneTest("parseTestDecimalSigned_no_packed") +// error not detected +// @Test def unparseTestDecimalSigned_no_packed(): Unit = +// runner.runOneTest("unparseTestDecimalSigned_no_packed") +// error not detected +// @Test def parseTestDecimalSigned_no_ibm4690Packed(): Unit = +// runner.runOneTest("parseTestDecimalSigned_no_ibm4690Packed") +// error not detected +// @Test def unparseTestDecimalSigned_no_ibm4690Packed(): Unit = +// runner.runOneTest("unparseTestDecimalSigned_no_ibm4690Packed") +}