aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/json/writer/json_ut.cpp
diff options
context:
space:
mode:
authormsherbakov <msherbakov@yandex-team.ru>2022-02-10 16:49:16 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:16 +0300
commitc224a621661ddd69699f9476922eb316607ef57e (patch)
tree33f4d878aa0a9faa964005e06bfab0272313aa71 /library/cpp/json/writer/json_ut.cpp
parent29d0b2eeae154d04156e0698067c0c21a97ea61d (diff)
downloadydb-c224a621661ddd69699f9476922eb316607ef57e.tar.gz
Restoring authorship annotation for <msherbakov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/json/writer/json_ut.cpp')
-rw-r--r--library/cpp/json/writer/json_ut.cpp80
1 files changed, 40 insertions, 40 deletions
diff --git a/library/cpp/json/writer/json_ut.cpp b/library/cpp/json/writer/json_ut.cpp
index 9980555683..d5ee4ff1c3 100644
--- a/library/cpp/json/writer/json_ut.cpp
+++ b/library/cpp/json/writer/json_ut.cpp
@@ -1,5 +1,5 @@
#include <library/cpp/testing/unittest/registar.h>
-#include <util/system/sanitizers.h>
+#include <util/system/sanitizers.h>
#include "json.h"
#include <library/cpp/json/json_value.h>
@@ -265,43 +265,43 @@ Y_UNIT_TEST_SUITE(JsonWriter) {
UNIT_ASSERT_STRINGS_EQUAL(buf.Str(), R"({"\u003C\u003E&":"Ololo","<>&":"Ololo2"})");
}
}
-
- Y_UNIT_TEST(WriteUninitializedBoolDoesntCrashProgram) {
- // makes sense only in release build w/ address sanitizer
- //
- // passing uninitialized boolean into WriteBool can make cleverly optimized code which is emitted by compiler crash program
- // https://stackoverflow.com/questions/54120862/does-the-c-standard-allow-for-an-uninitialized-bool-to-crash-a-program
-
- // looks like compiler can detect UB at compile time in simple cases, but not in this one
- class TSensorConf {
- public:
- class TAggrRuleItem {
- public:
- TVector<TString> Cond;
- TVector<TString> Target;
- };
-
- TString ToString() const {
- NJson::TJsonValue jsonValue;
- NJsonWriter::TBuf jsonOutput;
- jsonOutput.BeginObject()
- .WriteKey("rawDataMemOnly").WriteBool(RawDataMemOnly)
- .WriteKey("aggrRules").BeginList();
-
- jsonOutput.EndList()
- .EndObject();
-
- return jsonOutput.Str();
- }
-
- TVector<TAggrRuleItem> AggrRules;
- bool RawDataMemOnly;
- };
-
- TSensorConf s;
- NSan::Unpoison(&s.RawDataMemOnly, sizeof(s.RawDataMemOnly));
- auto p = s.ToString();
- // doesn't really matter
- UNIT_ASSERT(!p.empty());
- }
+
+ Y_UNIT_TEST(WriteUninitializedBoolDoesntCrashProgram) {
+ // makes sense only in release build w/ address sanitizer
+ //
+ // passing uninitialized boolean into WriteBool can make cleverly optimized code which is emitted by compiler crash program
+ // https://stackoverflow.com/questions/54120862/does-the-c-standard-allow-for-an-uninitialized-bool-to-crash-a-program
+
+ // looks like compiler can detect UB at compile time in simple cases, but not in this one
+ class TSensorConf {
+ public:
+ class TAggrRuleItem {
+ public:
+ TVector<TString> Cond;
+ TVector<TString> Target;
+ };
+
+ TString ToString() const {
+ NJson::TJsonValue jsonValue;
+ NJsonWriter::TBuf jsonOutput;
+ jsonOutput.BeginObject()
+ .WriteKey("rawDataMemOnly").WriteBool(RawDataMemOnly)
+ .WriteKey("aggrRules").BeginList();
+
+ jsonOutput.EndList()
+ .EndObject();
+
+ return jsonOutput.Str();
+ }
+
+ TVector<TAggrRuleItem> AggrRules;
+ bool RawDataMemOnly;
+ };
+
+ TSensorConf s;
+ NSan::Unpoison(&s.RawDataMemOnly, sizeof(s.RawDataMemOnly));
+ auto p = s.ToString();
+ // doesn't really matter
+ UNIT_ASSERT(!p.empty());
+ }
}