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

fixed: big decimal formatting according to https://www.w3.org/TR/xmls… #417

Merged
merged 1 commit into from Feb 23, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/src/main/resources/scalaxb.scala.template
Expand Up @@ -147,7 +147,7 @@ trait XMLStandardTypes {

def writes(obj: BigDecimal, namespace: Option[String], elementLabel: Option[String],
scope: scala.xml.NamespaceBinding, typeAttribute: Boolean): scala.xml.NodeSeq =
Helper.stringToXML(obj.toString, namespace, elementLabel, scope)
Helper.stringToXML(obj.bigDecimal.toEngineeringString, namespace, elementLabel, scope)
}

implicit lazy val __BigIntXMLFormat: XMLFormat[BigInt] = new XMLFormat[BigInt] {
Expand Down
13 changes: 13 additions & 0 deletions integration/src/test/resources/GeneralUsage.scala
Expand Up @@ -63,6 +63,7 @@ object GeneralUsage {
testMixedAbtractExtension
testLiteralBoolean
testUnderscoreSuffix
testBigDecimal
true
}

Expand Down Expand Up @@ -836,4 +837,16 @@ JDREVGRw==</base64Binary>
check(us)
}

def testBigDecimal {
println("testBigDecimal")
val document = scalaxb.toXML(BigDecimal(100).setScale(-2), "foo", scope)
println(document)
check(document)

def check(output: scala.xml.NodeSeq) = output.toString() match {
case o if o.matches("<foo.*>100</foo>") =>
case o if o.matches("<foo.*>100.0+</foo>") =>
case _ => sys.error("match failed: " + output)
}
}
}