CKM: tests adjusted to tizenorg.
[platform/core/test/security-tests.git] / tests / cynara-tests / test_cases_async.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
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 /*
18  * @file        test_cases_async.cpp
19  * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
20  * @version     1.0
21  * @brief       Tests for libcynara-client-async
22  */
23
24 #include <cynara_test_commons.h>
25 #include <cynara_test_client_async_client.h>
26
27 #include <dpl/test/test_runner.h>
28
29 #include <cynara-client-async.h>
30
31 #include <cstdint>
32
33 using namespace CynaraTestClientAsync;
34
35 void tca01_initialize_func()
36 {
37     Client client;
38 }
39
40 void tca02_empty_cache_miss_func()
41 {
42     std::string testNo("02");
43     Client client;
44
45     client.checkCache({testNo}, CYNARA_API_CACHE_MISS);
46     client.checkCache({testNo}, CYNARA_API_CACHE_MISS);
47 }
48
49 void tca03_create_max_requests_func()
50 {
51     std::string testNo("03");
52     cynara_check_id id;
53     RequestEntity callbackData = {RequestFunction(), 0, CYNARA_CALL_CAUSE_FINISH};
54
55     Client client;
56
57     for (auto i = 0; i <= UINT16_MAX; ++i) {
58         client.createRequest({testNo, i}, id, callbackData, CYNARA_API_SUCCESS);
59         client.assertStatus(READWRITE);
60     }
61
62     client.createRequest({testNo}, id, callbackData, CYNARA_API_MAX_PENDING_REQUESTS);
63     client.assertStatus(READWRITE);
64 }
65
66 RUNNER_TEST_GROUP_INIT(cynara_async_tests)
67
68 RUN_CYNARA_TEST(tca01_initialize)
69 RUN_CYNARA_TEST(tca02_empty_cache_miss)
70 RUN_CYNARA_TEST(tca03_create_max_requests)