alexander | 3c79893 | 2021-03-26 21:42:19 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2021 Arm Limited. All rights reserved. |
| 3 | * SPDX-License-Identifier: Apache-2.0 |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | #include "AppContext.hpp" |
| 18 | |
| 19 | #include <catch.hpp> |
| 20 | |
| 21 | TEST_CASE("Common: Application context") |
| 22 | { |
| 23 | SECTION("Add primitive type Parameter") |
| 24 | { |
| 25 | arm::app::ApplicationContext context; |
| 26 | context.Set<uint32_t>("imgIndex", 0); |
| 27 | auto data = context.Get<uint32_t>("imgIndex"); |
| 28 | |
| 29 | REQUIRE(0 == data); |
| 30 | |
| 31 | } |
| 32 | |
| 33 | SECTION("Add object parameter") |
| 34 | { |
| 35 | arm::app::ApplicationContext context; |
| 36 | std::vector <std::string> vect{"a"}; |
| 37 | context.Set<std::vector <std::string>>("vect", vect); |
| 38 | auto data = context.Get<std::vector <std::string>>("vect"); |
| 39 | |
| 40 | REQUIRE(vect == data); |
| 41 | } |
| 42 | |
| 43 | SECTION("Add reference object parameter") |
| 44 | { |
| 45 | arm::app::ApplicationContext context; |
| 46 | std::vector <std::string> vect{"a"}; |
| 47 | context.Set<std::vector <std::string>&>("vect", vect); |
| 48 | auto data = context.Get<std::vector <std::string>&>("vect"); |
| 49 | |
| 50 | REQUIRE(vect == data); |
| 51 | } |
| 52 | |
| 53 | SECTION("Add object pointer parameter") |
| 54 | { |
| 55 | arm::app::ApplicationContext context; |
| 56 | std::vector <std::string>* vect = new std::vector <std::string>{"a"}; |
| 57 | context.Set<std::vector <std::string>*>("vect", vect); |
| 58 | auto data = context.Get<std::vector <std::string>*>("vect"); |
| 59 | |
| 60 | REQUIRE(vect == data); |
| 61 | delete(vect); |
| 62 | } |
| 63 | } |