aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/encode/format_ut.cpp
diff options
context:
space:
mode:
authorSergey Polovko <sergey@polovko.me>2022-02-10 16:47:02 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:02 +0300
commit3e0b762a82514bac89c1dd6ea7211e381d8aa248 (patch)
treec2d1b379ecaf05ca8f11ed0b5da9d1a950e6e554 /library/cpp/monlib/encode/format_ut.cpp
parentab3783171cc30e262243a0227c86118f7080c896 (diff)
downloadydb-3e0b762a82514bac89c1dd6ea7211e381d8aa248.tar.gz
Restoring authorship annotation for Sergey Polovko <sergey@polovko.me>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/monlib/encode/format_ut.cpp')
-rw-r--r--library/cpp/monlib/encode/format_ut.cpp224
1 files changed, 112 insertions, 112 deletions
diff --git a/library/cpp/monlib/encode/format_ut.cpp b/library/cpp/monlib/encode/format_ut.cpp
index 22a0e30c03..63475674d2 100644
--- a/library/cpp/monlib/encode/format_ut.cpp
+++ b/library/cpp/monlib/encode/format_ut.cpp
@@ -1,14 +1,14 @@
-#include "format.h"
-
+#include "format.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
-#include <util/generic/string.h>
-#include <util/string/builder.h>
-
-#include <array>
-
-using namespace NMonitoring;
-
+
+#include <util/generic/string.h>
+#include <util/string/builder.h>
+
+#include <array>
+
+using namespace NMonitoring;
+
Y_UNIT_TEST_SUITE(TFormatTest) {
Y_UNIT_TEST(ContentTypeHeader) {
UNIT_ASSERT_EQUAL(FormatFromContentType(""), EFormat::UNKNOWN);
@@ -21,116 +21,116 @@ Y_UNIT_TEST_SUITE(TFormatTest) {
Y_UNIT_TEST(AcceptHeader) {
UNIT_ASSERT_EQUAL(FormatFromAcceptHeader(""), EFormat::UNKNOWN);
UNIT_ASSERT_EQUAL(FormatFromAcceptHeader("*/*"), EFormat::UNKNOWN);
-
- UNIT_ASSERT_EQUAL(
+
+ UNIT_ASSERT_EQUAL(
FormatFromAcceptHeader("application/xml"),
- EFormat::UNKNOWN);
-
- UNIT_ASSERT_EQUAL(
+ EFormat::UNKNOWN);
+
+ UNIT_ASSERT_EQUAL(
FormatFromAcceptHeader("application/json"),
- EFormat::JSON);
-
- UNIT_ASSERT_EQUAL(
+ EFormat::JSON);
+
+ UNIT_ASSERT_EQUAL(
FormatFromAcceptHeader("application/x-solomon-spack"),
- EFormat::SPACK);
-
- UNIT_ASSERT_EQUAL(
+ EFormat::SPACK);
+
+ UNIT_ASSERT_EQUAL(
FormatFromAcceptHeader("application/x-solomon-pb"),
- EFormat::PROTOBUF);
-
- UNIT_ASSERT_EQUAL(
- FormatFromAcceptHeader("application/x-solomon-txt"),
- EFormat::TEXT);
-
- UNIT_ASSERT_EQUAL(
+ EFormat::PROTOBUF);
+
+ UNIT_ASSERT_EQUAL(
+ FormatFromAcceptHeader("application/x-solomon-txt"),
+ EFormat::TEXT);
+
+ UNIT_ASSERT_EQUAL(
FormatFromAcceptHeader("application/json, text/plain"),
- EFormat::JSON);
-
- UNIT_ASSERT_EQUAL(
+ EFormat::JSON);
+
+ UNIT_ASSERT_EQUAL(
FormatFromAcceptHeader("application/x-solomon-spack, application/json, text/plain"),
- EFormat::SPACK);
-
- UNIT_ASSERT_EQUAL(
+ EFormat::SPACK);
+
+ UNIT_ASSERT_EQUAL(
FormatFromAcceptHeader(" , application/x-solomon-spack ,, application/json , text/plain"),
- EFormat::SPACK);
-
- UNIT_ASSERT_EQUAL(
+ EFormat::SPACK);
+
+ UNIT_ASSERT_EQUAL(
FormatFromAcceptHeader("application/xml, application/x-solomon-spack, text/plain"),
- EFormat::SPACK);
-
- UNIT_ASSERT_EQUAL(
- FormatFromAcceptHeader("text/plain"),
- EFormat::PROMETHEUS);
- }
-
+ EFormat::SPACK);
+
+ UNIT_ASSERT_EQUAL(
+ FormatFromAcceptHeader("text/plain"),
+ EFormat::PROMETHEUS);
+ }
+
Y_UNIT_TEST(FormatToStrFromStr) {
- const std::array<EFormat, 6> formats = {{
- EFormat::UNKNOWN,
- EFormat::SPACK,
- EFormat::JSON,
- EFormat::PROTOBUF,
- EFormat::TEXT,
- EFormat::PROMETHEUS,
- }};
-
- for (EFormat f : formats) {
- TString str = (TStringBuilder() << f);
- EFormat g = FromString<EFormat>(str);
- UNIT_ASSERT_EQUAL(f, g);
- }
- }
-
+ const std::array<EFormat, 6> formats = {{
+ EFormat::UNKNOWN,
+ EFormat::SPACK,
+ EFormat::JSON,
+ EFormat::PROTOBUF,
+ EFormat::TEXT,
+ EFormat::PROMETHEUS,
+ }};
+
+ for (EFormat f : formats) {
+ TString str = (TStringBuilder() << f);
+ EFormat g = FromString<EFormat>(str);
+ UNIT_ASSERT_EQUAL(f, g);
+ }
+ }
+
Y_UNIT_TEST(AcceptEncodingHeader) {
- UNIT_ASSERT_EQUAL(
- CompressionFromAcceptEncodingHeader(""),
- ECompression::UNKNOWN);
-
- UNIT_ASSERT_EQUAL(
- CompressionFromAcceptEncodingHeader("br"),
- ECompression::UNKNOWN);
-
- UNIT_ASSERT_EQUAL(
- CompressionFromAcceptEncodingHeader("identity"),
- ECompression::IDENTITY);
-
- UNIT_ASSERT_EQUAL(
- CompressionFromAcceptEncodingHeader("zlib"),
- ECompression::ZLIB);
-
- UNIT_ASSERT_EQUAL(
- CompressionFromAcceptEncodingHeader("lz4"),
- ECompression::LZ4);
-
- UNIT_ASSERT_EQUAL(
- CompressionFromAcceptEncodingHeader("zstd"),
- ECompression::ZSTD);
-
- UNIT_ASSERT_EQUAL(
- CompressionFromAcceptEncodingHeader("zstd, zlib"),
- ECompression::ZSTD);
-
- UNIT_ASSERT_EQUAL(
- CompressionFromAcceptEncodingHeader(" ,, , zstd , zlib"),
- ECompression::ZSTD);
-
- UNIT_ASSERT_EQUAL(
- CompressionFromAcceptEncodingHeader("br, deflate,lz4, zlib"),
- ECompression::LZ4);
- }
-
+ UNIT_ASSERT_EQUAL(
+ CompressionFromAcceptEncodingHeader(""),
+ ECompression::UNKNOWN);
+
+ UNIT_ASSERT_EQUAL(
+ CompressionFromAcceptEncodingHeader("br"),
+ ECompression::UNKNOWN);
+
+ UNIT_ASSERT_EQUAL(
+ CompressionFromAcceptEncodingHeader("identity"),
+ ECompression::IDENTITY);
+
+ UNIT_ASSERT_EQUAL(
+ CompressionFromAcceptEncodingHeader("zlib"),
+ ECompression::ZLIB);
+
+ UNIT_ASSERT_EQUAL(
+ CompressionFromAcceptEncodingHeader("lz4"),
+ ECompression::LZ4);
+
+ UNIT_ASSERT_EQUAL(
+ CompressionFromAcceptEncodingHeader("zstd"),
+ ECompression::ZSTD);
+
+ UNIT_ASSERT_EQUAL(
+ CompressionFromAcceptEncodingHeader("zstd, zlib"),
+ ECompression::ZSTD);
+
+ UNIT_ASSERT_EQUAL(
+ CompressionFromAcceptEncodingHeader(" ,, , zstd , zlib"),
+ ECompression::ZSTD);
+
+ UNIT_ASSERT_EQUAL(
+ CompressionFromAcceptEncodingHeader("br, deflate,lz4, zlib"),
+ ECompression::LZ4);
+ }
+
Y_UNIT_TEST(CompressionToStrFromStr) {
- const std::array<ECompression, 5> algs = {{
- ECompression::UNKNOWN,
- ECompression::IDENTITY,
- ECompression::ZLIB,
- ECompression::LZ4,
- ECompression::ZSTD,
- }};
-
- for (ECompression a : algs) {
- TString str = (TStringBuilder() << a);
- ECompression b = FromString<ECompression>(str);
- UNIT_ASSERT_EQUAL(a, b);
- }
- }
-}
+ const std::array<ECompression, 5> algs = {{
+ ECompression::UNKNOWN,
+ ECompression::IDENTITY,
+ ECompression::ZLIB,
+ ECompression::LZ4,
+ ECompression::ZSTD,
+ }};
+
+ for (ECompression a : algs) {
+ TString str = (TStringBuilder() << a);
+ ECompression b = FromString<ECompression>(str);
+ UNIT_ASSERT_EQUAL(a, b);
+ }
+ }
+}