diff options
author | msherbakov <msherbakov@yandex-team.ru> | 2022-02-10 16:49:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:17 +0300 |
commit | a0ffafe83b7d6229709a32fa942c71d672ac989c (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/json/writer/json_ut.cpp | |
parent | c224a621661ddd69699f9476922eb316607ef57e (diff) | |
download | ydb-a0ffafe83b7d6229709a32fa942c71d672ac989c.tar.gz |
Restoring authorship annotation for <msherbakov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/json/writer/json_ut.cpp')
-rw-r--r-- | library/cpp/json/writer/json_ut.cpp | 80 |
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 d5ee4ff1c3..9980555683 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()); + } } |