-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4641 from telefonicaid/hardening/large-float-numbers
FIX improve double2string function to cope with very large float numbers
- Loading branch information
Showing
3 changed files
with
148 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
test/functionalTest/cases/4642_large_float_numbers/large_float_numbers.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
# Copyright 2025 Telefonica Investigacion y Desarrollo, S.A.U | ||
# | ||
# This file is part of Orion Context Broker. | ||
# | ||
# Orion Context Broker is free software: you can redistribute it and/or | ||
# modify it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# Orion Context Broker is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero | ||
# General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. | ||
# | ||
# For those usages not covered by this license please contact with | ||
# iot_support at tid dot es | ||
|
||
# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh | ||
|
||
--NAME-- | ||
Large float numbers in attributes | ||
|
||
--SHELL-INIT-- | ||
dbInit CB | ||
brokerStart CB | ||
|
||
--SHELL-- | ||
|
||
# We are using the the limits included in the IEEE754 standard. However, note that | ||
# min non zero cases are rounded to 0 due to how double2string() function is implemented | ||
# (ten digits precision). We could remove that rounding, but consequences may not be | ||
# backward compatible (eg. places where we have now 1.7 could become in 1.666666666666666666669) | ||
# | ||
# 01. Create entity with large float number | ||
# 02. Retrieve entity with large float numbers | ||
# | ||
|
||
echo "01. Create entity with large float number" | ||
echo "=========================================" | ||
payload='{ | ||
"id": "E", | ||
"type": "T", | ||
"A": { | ||
"value": 1.79e308, | ||
"type": "Number" | ||
}, | ||
"maxPositive": { | ||
"value": 1.7976931348623157e308, | ||
"type": "Number" | ||
}, | ||
"minNonZeroPositive": { | ||
"value": 4.9406564584124654e-324, | ||
"type": "Number" | ||
}, | ||
"maxNegative": { | ||
"value": -1.7976931348623157e308, | ||
"type": "Number" | ||
}, | ||
"minNonZeroNegative": { | ||
"value": -4.9406564584124654e-324, | ||
"type": "Number" | ||
} | ||
}' | ||
orionCurl --url '/v2/entities' --payload "$payload" | ||
echo | ||
echo | ||
|
||
|
||
echo "02. Retrieve entity with large float numbers" | ||
echo "============================================" | ||
orionCurl --url '/v2/entities/E' | ||
echo | ||
echo | ||
|
||
|
||
--REGEXPECT-- | ||
01. Create entity with large float number | ||
========================================= | ||
HTTP/1.1 201 Created | ||
Date: REGEX(.*) | ||
Fiware-Correlator: REGEX([0-9a-f\-]{36}) | ||
Location: /v2/entities/E?type=T | ||
Content-Length: 0 | ||
|
||
|
||
|
||
02. Retrieve entity with large float numbers | ||
============================================ | ||
HTTP/1.1 200 OK | ||
Date: REGEX(.*) | ||
Fiware-Correlator: REGEX([0-9a-f\-]{36}) | ||
Content-Type: application/json | ||
Content-Length: 358 | ||
|
||
{ | ||
"A": { | ||
"metadata": {}, | ||
"type": "Number", | ||
"value": 1.79e+308 | ||
}, | ||
"id": "E", | ||
"maxNegative": { | ||
"metadata": {}, | ||
"type": "Number", | ||
"value": -1.7976931348623157e+308 | ||
}, | ||
"maxPositive": { | ||
"metadata": {}, | ||
"type": "Number", | ||
"value": 1.7976931348623157e+308 | ||
}, | ||
"minNonZeroNegative": { | ||
"metadata": {}, | ||
"type": "Number", | ||
"value": 0 | ||
}, | ||
"minNonZeroPositive": { | ||
"metadata": {}, | ||
"type": "Number", | ||
"value": 0 | ||
}, | ||
"type": "T" | ||
} | ||
|
||
|
||
--TEARDOWN-- | ||
brokerStop CB | ||
dbDrop CB |