From 02e1dd293199c2060347b4d7b96557ed1241aa00 Mon Sep 17 00:00:00 2001 From: Emanuela Epure <67077116+emanuelaepure10@users.noreply.github.com> Date: Mon, 10 Jun 2024 14:34:28 +0200 Subject: [PATCH] fixup! fix: use appropriate methods to convert the numbers in XML --- .../internal/StreamGmlWriter2Test.groovy | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/io/plugins/eu.esdihumboldt.hale.io.gml.test/src/eu/esdihumboldt/hale/io/gml/writer/internal/StreamGmlWriter2Test.groovy b/io/plugins/eu.esdihumboldt.hale.io.gml.test/src/eu/esdihumboldt/hale/io/gml/writer/internal/StreamGmlWriter2Test.groovy index 1e7d831894..8f4b8e72e4 100644 --- a/io/plugins/eu.esdihumboldt.hale.io.gml.test/src/eu/esdihumboldt/hale/io/gml/writer/internal/StreamGmlWriter2Test.groovy +++ b/io/plugins/eu.esdihumboldt.hale.io.gml.test/src/eu/esdihumboldt/hale/io/gml/writer/internal/StreamGmlWriter2Test.groovy @@ -386,15 +386,18 @@ class StreamGmlWriter2Test { void testNumbers() throws Exception { /**test DOUBLE numbers*/ testNumber("doubleNumber", 12345.123456789, null) + testNumber("doubleNumber", 12345.123456789, "12345.123456789") double doubleNumber = 123456789.123456789 double expected = java.lang.Double.parseDouble(doubleNumber.toString()) testNumber("doubleSimpleNumber", doubleNumber, expected) + testNumber("doubleSimpleNumber", doubleNumber, expected.toString()) testFloatingPointNumber(doubleNumber, "doubleNumber") /**test INT, SHORT numbers*/ testNumber("integerNumber", 12345, null) + testNumber("integerNumber", 12345, "12345") testNumber("shortNumber", 12345 as short, null) - + testNumber("shortNumber", 12345 as short, "12345") float smallDecimal = 0.12345F float largeDecimal = 12345.6789F @@ -405,10 +408,15 @@ class StreamGmlWriter2Test { float maxFloat = Float.MAX_VALUE float minFloat = Float.MIN_VALUE + // for Float and Double we are expecting to use using scientific notation testFloatingPointNumber(smallDecimal, "floatNumber") + testNumber("floatNumber", smallDecimal, "0.12345") testFloatingPointNumber(largeDecimal, "floatNumber") + testNumber("floatNumber", largeDecimal, "12345.679") testFloatingPointNumber(verySmall, "floatNumber") + testNumber("floatNumber", verySmall, "1.0E-7") testFloatingPointNumber(veryLarge, "floatNumber") + testNumber("floatNumber", veryLarge, "1.2345679E7") testFloatingPointNumber(negative, "floatNumber") testFloatingPointNumber(scientific, "floatNumber") testFloatingPointNumber(maxFloat, "floatNumber") @@ -427,8 +435,8 @@ class StreamGmlWriter2Test { long nearMaxLong = 9223372036854775806L long nearMinLong = -9223372036854775807L - testNumber("longNumber", smallPositive, null) - testNumber("longNumber", largePositive, null) + testNumber("longNumber", smallPositive, "12345") + testNumber("longNumber", largePositive, "1234567890123456789") testNumber("longNumber", smallNegative, null) testNumber("longNumber", largeNegative, null) testNumber("longNumber", maxLong, null) @@ -448,6 +456,7 @@ class StreamGmlWriter2Test { String numberAsString = "1.23456789123456789E8" testNumber("decimalNumber", new BigDecimal(numberAsString), null) + testNumber("decimalNumber", new BigDecimal(numberAsString), "123456789.123456789") } void testNumber(String elementName, number, expected) throws Exception { @@ -464,11 +473,16 @@ class StreamGmlWriter2Test { String actualText = xml.featureMember.PrimitiveTest."$elementName".text() if (expected != null) { - compareValues(expected, actualText) + if (expected instanceof String) { + assertEquals(expected.toString(), xml.featureMember.PrimitiveTest."$elementName".text()) + } else { + compareValues(expected, actualText) + } } else { compareValues(number, actualText) } + if (DEL_TEMP_FILES) { outFile.delete() } @@ -493,6 +507,7 @@ class StreamGmlWriter2Test { void testFloatingPointNumber(floatNumber, type) { def expected = java.lang.Double.parseDouble(floatNumber.toString()) + println expected testNumber(type, floatNumber, expected) }