aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/json/ut/json_reader_nan_ut.cpp
diff options
context:
space:
mode:
authord-dima <d-dima@yandex-team.com>2024-08-05 13:19:22 +0300
committerd-dima <d-dima@yandex-team.com>2024-08-05 13:29:58 +0300
commitacf04c75cb52f804ce76b16c356611268be3daf3 (patch)
tree73df11988fb2ba789ad9f71bd26ff3da92ca3e1e /library/cpp/json/ut/json_reader_nan_ut.cpp
parent8ead472243985333d15c527eb0d998468dc716e1 (diff)
downloadydb-acf04c75cb52f804ce76b16c356611268be3daf3.tar.gz
Allow to read Nan/Inf values from JSON
Allow to read Nan/Inf values from JSON 9fbb79a21d81cf178abc89cd11d7ac75a9a4aaed
Diffstat (limited to 'library/cpp/json/ut/json_reader_nan_ut.cpp')
-rw-r--r--library/cpp/json/ut/json_reader_nan_ut.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/library/cpp/json/ut/json_reader_nan_ut.cpp b/library/cpp/json/ut/json_reader_nan_ut.cpp
new file mode 100644
index 0000000000..fdd66249eb
--- /dev/null
+++ b/library/cpp/json/ut/json_reader_nan_ut.cpp
@@ -0,0 +1,29 @@
+#include <library/cpp/json/json_reader.h>
+#include <library/cpp/testing/unittest/registar.h>
+
+using namespace NJson;
+
+namespace {
+
+constexpr TStringBuf JSON_NAN_TEST = "{ \"Value1\": 0.0, \"Value2\": 1, \"Value3\": NaN }";
+
+}
+
+Y_UNIT_TEST_SUITE(TJsonReaderNanTest) {
+ Y_UNIT_TEST(WithoutNanTest) {
+ TJsonReaderConfig cfg;
+ TJsonValue out;
+ // This read will fail
+ UNIT_ASSERT(!ReadJsonTree(JSON_NAN_TEST, &cfg, &out, /* throwOnError */ false));
+
+ }
+ Y_UNIT_TEST(WithNanTest) {
+ TJsonReaderConfig cfg;
+ cfg.AllowReadNanInf = true;
+
+ TJsonValue out;
+ // This read will ok
+ UNIT_ASSERT(ReadJsonTree(JSON_NAN_TEST, &cfg, &out, /* throwOnError */ false));
+ }
+}
+