diff --git a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_fixed_value_e.ttcn b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_fixed_value_e.ttcn index d3478eb1fe3f20ecc10dc3b119a9cf158bfc368f..fef4c8964ae3fa67d2ea47479695046b7e7c5027 100644 --- a/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_fixed_value_e.ttcn +++ b/regression_test/XML/XmlWorkflow/XmlTest_expectedTtcns/www_example_org_fixed_value_e.ttcn @@ -86,6 +86,48 @@ with { }; +type XSD.Float FloatType5 (3.0) +with { + variant "defaultForEmpty as '3'"; + variant "element"; +}; + + +type XSD.Float FloatType6 (-3.0) +with { + variant "defaultForEmpty as '-3'"; + variant "element"; +}; + + +type XSD.Float FloatType7 (-1E4) +with { + variant "defaultForEmpty as '-1E4'"; + variant "element"; +}; + + +type XSD.Float FloatType8 (12.78e-2) +with { + variant "defaultForEmpty as '12.78e-2'"; + variant "element"; +}; + + +type XSD.Float FloatType9 (0.0) +with { + variant "defaultForEmpty as '0'"; + variant "element"; +}; + + +type XSD.Float FloatType10 (-0.0) +with { + variant "defaultForEmpty as '-0'"; + variant "element"; +}; + + type XSD.Double DoubleType (7.0) with { variant "defaultForEmpty as '7.0'"; diff --git a/regression_test/XML/XmlWorkflow/xsd/fixed_value.xsd b/regression_test/XML/XmlWorkflow/xsd/fixed_value.xsd index b7e4d7900bee2e01d71fcb7342608f028cb9ee92..8841ea4e6f202e6991653c9742a83cc438ee1c30 100644 --- a/regression_test/XML/XmlWorkflow/xsd/fixed_value.xsd +++ b/regression_test/XML/XmlWorkflow/xsd/fixed_value.xsd @@ -9,6 +9,12 @@ <xsd:element name="FloatType2" type="xsd:float" fixed="INF"/> <xsd:element name="FloatType3" type="xsd:float" fixed="-INF"/> <xsd:element name="FloatType4" type="xsd:float" fixed="NaN"/> +<xsd:element name="FloatType5" type="xsd:float" fixed="3"/> +<xsd:element name="FloatType6" type="xsd:float" fixed="-3"/> +<xsd:element name="FloatType7" type="xsd:float" fixed="-1E4"/> +<xsd:element name="FloatType8" type="xsd:float" fixed="12.78e-2"/> +<xsd:element name="FloatType9" type="xsd:float" fixed="0"/> +<xsd:element name="FloatType10" type="xsd:float" fixed="-0"/> <xsd:element name="DoubleType" type="xsd:double" fixed="7.0"/> <xsd:element name="BooleanType" type="xsd:boolean" fixed="true"/> <xsd:element name="BooleanType2" type="xsd:boolean" fixed="0"/> diff --git a/xsdconvert/Mstring.cc b/xsdconvert/Mstring.cc index 4c020d8bac91614fce28e8a65dfb7eb089669090..e3b8ab8dff8cf47fbbe4c64d61627cce0087f95a 100644 --- a/xsdconvert/Mstring.cc +++ b/xsdconvert/Mstring.cc @@ -86,19 +86,19 @@ void Mstring::insertChar(size_t pos, char c) { text = mcopystr(temp.text); } -bool Mstring::isFound(const Mstring & s) { +bool Mstring::isFound(const Mstring & s) const { return strstr(text, s.text); } -bool Mstring::isFound(const char * s) { +bool Mstring::isFound(const char * s) const { return strstr(text, s); } -bool Mstring::isFound(char c) { +bool Mstring::isFound(char c) const { return strchr(text, c); } -char * Mstring::foundAt(const char * s) { +char * Mstring::foundAt(const char * s) const { return strstr(text, s); } diff --git a/xsdconvert/Mstring.hh b/xsdconvert/Mstring.hh index 244b277e1e66e4bac4e43772ae2c528c5928f087..5e8af1621933be13e891af05735763dfe6d629b6 100644 --- a/xsdconvert/Mstring.hh +++ b/xsdconvert/Mstring.hh @@ -98,21 +98,21 @@ public: * true if s is found * false otherwise */ - bool isFound(const Mstring & s); + bool isFound(const Mstring & s) const; /** * Look for s c-string content * true if s is found * false otherwise */ - bool isFound(const char * s); + bool isFound(const char * s) const; /** * Look for c character content * true if s is found * false otherwise */ - bool isFound(char c); + bool isFound(char c) const; /** * Look for c-string content @@ -120,7 +120,7 @@ public: * character where the matching found, * returns null otherwise */ - char * foundAt(const char * c); + char * foundAt(const char * c) const; /** * The first character of the Mstring is set to uppercase diff --git a/xsdconvert/SimpleType.cc b/xsdconvert/SimpleType.cc index b186c6b0f0ddaee09e4c91ce7664aabc91161494..2f7c43a13471ca8d26f633da4f90690453df9c91 100644 --- a/xsdconvert/SimpleType.cc +++ b/xsdconvert/SimpleType.cc @@ -1559,6 +1559,10 @@ void ValueType::printToFile(FILE * file) const { val = "-infinity"; } else if (fixed_value == "NaN") { val = "not_a_number"; + } else if (!fixed_value.isFound('.') && !fixed_value.isFound('e') && + !fixed_value.isFound('E')) { + // Float types need the .0 if it is a single integer. + val = fixed_value + Mstring(".0"); } else { val = fixed_value; }