From 610d2dcaccb80256769bd367446e67c091e88b6a Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Tue, 16 Dec 2014 13:13:24 +0100 Subject: [PATCH] Add tests for EraseRequest serialization Add tests for checking equality of objects and binary data in serialization / deserialization of EraseRequest by ProtocolAdmin. Change-Id: I25c2768572d6aa419c1635586437e7bf673d301f --- test/CMakeLists.txt | 1 + test/common/protocols/admin/eraserequest.cpp | 147 +++++++++++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 test/common/protocols/admin/eraserequest.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fb9524c..99097cc 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -60,6 +60,7 @@ SET(CYNARA_TESTS_SOURCES common/exceptions/bucketrecordcorrupted.cpp common/protocols/admin/admincheckrequest.cpp common/protocols/admin/admincheckresponse.cpp + common/protocols/admin/eraserequest.cpp common/protocols/admin/listrequest.cpp common/protocols/admin/listresponse.cpp common/types/policybucket.cpp diff --git a/test/common/protocols/admin/eraserequest.cpp b/test/common/protocols/admin/eraserequest.cpp new file mode 100644 index 0000000..4b1efdc --- /dev/null +++ b/test/common/protocols/admin/eraserequest.cpp @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file test/common/protocols/admin/eraserequest.cpp + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief Tests for Cynara::EraseRequest usage in Cynara::ProtocolAdmin + */ + +#include + +#include +#include + +#include +#include + +namespace { + +template<> +void compare(const Cynara::EraseRequest &req1, const Cynara::EraseRequest &req2) { + EXPECT_EQ(req1.startBucket(), req2.startBucket()); + EXPECT_EQ(req1.recursive(), req2.recursive()); + EXPECT_EQ(req1.filter(), req2.filter()); +} + +static const bool RECURSIVE = true; +static const bool NON_RECURSIVE = false; + +} /* namespace anonymous */ + +using namespace Cynara; +using namespace RequestTestHelper; +using namespace TestDataCollection; + +/* *** compare by objects test cases *** */ + +TEST(ProtocolAdmin, EraseRequest01) { + auto request = std::make_shared(Buckets::empty, RECURSIVE, Keys::k_nun, SN::min); + auto protocol = std::make_shared(); + testRequest(request, protocol); +} + +TEST(ProtocolAdmin, EraseRequest02) { + auto request = std::make_shared(Buckets::not_empty, NON_RECURSIVE, Keys::k_cup, + SN::min_1); + auto protocol = std::make_shared(); + testRequest(request, protocol); +} + +TEST(ProtocolAdmin, EraseRequest03) { + auto request = std::make_shared(Buckets::empty, NON_RECURSIVE, Keys::k_www, + SN::min_2); + auto protocol = std::make_shared(); + testRequest(request, protocol); +} + +TEST(ProtocolAdmin, EraseRequest04) { + auto request = std::make_shared(Buckets::not_empty, RECURSIVE, Keys::k_wuw, + SN::max); + auto protocol = std::make_shared(); + testRequest(request, protocol); +} + +TEST(ProtocolAdmin, EraseRequest05) { + auto request = std::make_shared(Buckets::empty, RECURSIVE, Keys::k_aaa, + SN::max_1); + auto protocol = std::make_shared(); + testRequest(request, protocol); +} + +TEST(ProtocolAdmin, EraseRequest06) { + auto request = std::make_shared(Buckets::not_empty, NON_RECURSIVE, Keys::k_wua, + SN::max_2); + auto protocol = std::make_shared(); + testRequest(request, protocol); +} + +TEST(ProtocolAdmin, EraseRequest07) { + auto request = std::make_shared(Buckets::empty, NON_RECURSIVE, Keys::k_nua, + SN::mid); + auto protocol = std::make_shared(); + testRequest(request, protocol); +} + +/* *** compare by serialized data test cases *** */ + +TEST(ProtocolAdmin, EraseRequestBinary01) { + auto request = std::make_shared(Buckets::empty, RECURSIVE, Keys::k_nun, SN::min); + auto protocol = std::make_shared(); + binaryTestRequest(request, protocol); +} + +TEST(ProtocolAdmin, EraseRequestBinary02) { + auto request = std::make_shared(Buckets::not_empty, NON_RECURSIVE, Keys::k_cup, + SN::min_1); + auto protocol = std::make_shared(); + binaryTestRequest(request, protocol); +} + +TEST(ProtocolAdmin, EraseRequestBinary03) { + auto request = std::make_shared(Buckets::empty, NON_RECURSIVE, Keys::k_www, + SN::min_2); + auto protocol = std::make_shared(); + binaryTestRequest(request, protocol); +} + +TEST(ProtocolAdmin, EraseRequestBinary04) { + auto request = std::make_shared(Buckets::not_empty, RECURSIVE, Keys::k_wuw, + SN::max); + auto protocol = std::make_shared(); + binaryTestRequest(request, protocol); +} + +TEST(ProtocolAdmin, EraseRequestBinary05) { + auto request = std::make_shared(Buckets::empty, RECURSIVE, Keys::k_aaa, + SN::max_1); + auto protocol = std::make_shared(); + binaryTestRequest(request, protocol); +} + +TEST(ProtocolAdmin, EraseRequestBinary06) { + auto request = std::make_shared(Buckets::not_empty, NON_RECURSIVE, Keys::k_wua, + SN::max_2); + auto protocol = std::make_shared(); + binaryTestRequest(request, protocol); +} + +TEST(ProtocolAdmin, EraseRequestBinary07) { + auto request = std::make_shared(Buckets::empty, NON_RECURSIVE, Keys::k_nua, + SN::mid); + auto protocol = std::make_shared(); + binaryTestRequest(request, protocol); +} -- 2.7.4