blob: 9c9c1cfd82f5c1141d2ece5556a11db63e66c19a [file] [log] [blame]
Rolf Badorekef2bf512019-08-20 11:17:15 +03001/*
2 Copyright (c) 2018-2019 Nokia.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#include "config.h"
18#include <type_traits>
19#include <memory>
20#include <cstring>
21#include <gtest/gtest.h>
22#include <async.h>
23#include <sdl/errorqueries.hpp>
24
25using namespace shareddatalayer;
26using namespace testing;
27
28namespace
29{
30 std::string getErrorConditionMessage(std::error_condition ec)
31 {
32 return ec.message();
33 }
34
35 class ErrorCodeQueriesTest: public testing::Test
36 {
37 public:
38 ErrorCodeQueriesTest()
39 {
40 }
41
42 virtual ~ErrorCodeQueriesTest()
43 {
44 }
45 };
46}
47
48TEST_F(ErrorCodeQueriesTest, AllClientErrorCodeEnumsHaveCorrectDescriptionMessage)
49{
50 EXPECT_EQ(std::error_code().message(), getErrorConditionMessage(shareddatalayer::Error::SUCCESS));
51 EXPECT_EQ("shareddatalayer not connected to backend data storage", getErrorConditionMessage(shareddatalayer::Error::NOT_CONNECTED));
52 EXPECT_EQ("shareddatalayer sent the request to backend data storage but did not receive reply",getErrorConditionMessage(shareddatalayer::Error::OPERATION_INTERRUPTED));
53 EXPECT_EQ("backend data storage failed to process the request", getErrorConditionMessage(shareddatalayer::Error::BACKEND_FAILURE));
54}