diff options
author | dcherednik <dcherednik@ydb.tech> | 2023-11-29 13:50:45 +0300 |
---|---|---|
committer | dcherednik <dcherednik@ydb.tech> | 2023-11-29 15:47:31 +0300 |
commit | 10fd58d05678db9a22303a46178f5ed6c7150601 (patch) | |
tree | 3a9837bd2156df5d6e54d182679e8f0f44f7bc7d /library/cpp/grpc/server/ut/grpc_response_ut.cpp | |
parent | e92c0cb46ca4a92ac06cef509ab210296d9f0b99 (diff) | |
download | ydb-10fd58d05678db9a22303a46178f5ed6c7150601.tar.gz |
Use own copy of library/grpc
Diffstat (limited to 'library/cpp/grpc/server/ut/grpc_response_ut.cpp')
-rw-r--r-- | library/cpp/grpc/server/ut/grpc_response_ut.cpp | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/library/cpp/grpc/server/ut/grpc_response_ut.cpp b/library/cpp/grpc/server/ut/grpc_response_ut.cpp deleted file mode 100644 index 97952f41667..00000000000 --- a/library/cpp/grpc/server/ut/grpc_response_ut.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include <library/cpp/grpc/server/grpc_response.h> -#include <library/cpp/testing/unittest/registar.h> - -#include <google/protobuf/duration.pb.h> -#include <grpc++/impl/codegen/proto_utils.h> -#include <grpc++/impl/grpc_library.h> - -using namespace NGrpc; - -using google::protobuf::Duration; - -Y_UNIT_TEST_SUITE(ResponseTest) { - - template <typename T> - grpc::ByteBuffer Serialize(T resp) { - grpc::ByteBuffer buf; - bool ownBuf = false; - grpc::Status status = grpc::SerializationTraits<T>::Serialize(resp, &buf, &ownBuf); - UNIT_ASSERT(status.ok()); - return buf; - } - - template <typename T> - T Deserialize(grpc::ByteBuffer* buf) { - T message; - auto status = grpc::SerializationTraits<T>::Deserialize(buf, &message); - UNIT_ASSERT(status.ok()); - return message; - } - - Y_UNIT_TEST(UniversalResponseMsg) { - Duration d1; - d1.set_seconds(12345); - d1.set_nanos(67890); - - auto buf = Serialize(TUniversalResponse<Duration>(&d1)); - Duration d2 = Deserialize<Duration>(&buf); - - UNIT_ASSERT_VALUES_EQUAL(d2.seconds(), 12345); - UNIT_ASSERT_VALUES_EQUAL(d2.nanos(), 67890); - } - - Y_UNIT_TEST(UniversalResponseBuf) { - Duration d1; - d1.set_seconds(123); - d1.set_nanos(456); - - TString data = d1.SerializeAsString(); - grpc::Slice dataSlice{data.data(), data.size()}; - grpc::ByteBuffer dataBuf{&dataSlice, 1}; - - auto buf = Serialize(TUniversalResponse<Duration>(&dataBuf)); - Duration d2 = Deserialize<Duration>(&buf); - - UNIT_ASSERT_VALUES_EQUAL(d2.seconds(), 123); - UNIT_ASSERT_VALUES_EQUAL(d2.nanos(), 456); - } - - Y_UNIT_TEST(UniversalResponseRefMsg) { - Duration d1; - d1.set_seconds(12345); - d1.set_nanos(67890); - - auto buf = Serialize(TUniversalResponseRef<Duration>(&d1)); - Duration d2 = Deserialize<Duration>(&buf); - - UNIT_ASSERT_VALUES_EQUAL(d2.seconds(), 12345); - UNIT_ASSERT_VALUES_EQUAL(d2.nanos(), 67890); - } - - Y_UNIT_TEST(UniversalResponseRefBuf) { - Duration d1; - d1.set_seconds(123); - d1.set_nanos(456); - - TString data = d1.SerializeAsString(); - grpc::Slice dataSlice{data.data(), data.size()}; - grpc::ByteBuffer dataBuf{&dataSlice, 1}; - - auto buf = Serialize(TUniversalResponseRef<Duration>(&dataBuf)); - Duration d2 = Deserialize<Duration>(&buf); - - UNIT_ASSERT_VALUES_EQUAL(d2.seconds(), 123); - UNIT_ASSERT_VALUES_EQUAL(d2.nanos(), 456); - } -} |