2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <gtest/gtest.h>
20 #include <gmock/gmock.h>
22 #include "notification-ex/ex_bundle.h"
24 using ::testing::AtLeast;
25 using namespace notification;
27 TEST(Bundle, CtorDtor) {
31 TEST(Bundle, CopyCtor) {
33 bundle.Add("TestKey", "TestVal");
36 EXPECT_EQ(b2.GetString("TestKey"), "TestVal");
39 TEST(Bundle, MoveCtor) {
41 bundle.Add("TestKey", "TestVal");
43 Bundle b2(std::move(bundle));
44 EXPECT_EQ(b2.GetString("TestKey"), "TestVal");
47 TEST(Bundle, AddStringGetString) {
49 bundle.Add("TestKey", "TestVal");
51 EXPECT_EQ(bundle.GetString("TestKey"), "TestVal");
54 TEST(Bundle, AddByteGetByte) {
56 std::vector<unsigned char> v = { 0, 1, 2, 3};
57 bundle.Add("TestKey", v);
58 auto v2 = bundle.GetByte("TestKey");
60 EXPECT_EQ(v2.size(), 4);
67 TEST(Bundle, AddStringArrayGetStringArray) {
69 bundle.Add("TestKey", { "TestVal1", "TestVal2", "TestVal3" });
71 auto v = bundle.GetStringArray("TestKey");
73 EXPECT_EQ(v.size(), 3);
74 EXPECT_EQ(v[0], "TestVal1");
75 EXPECT_EQ(v[1], "TestVal2");
76 EXPECT_EQ(v[2], "TestVal3");
81 bundle.Add("TestKey", "TestVal");
83 auto r = bundle.ToRaw();
84 Bundle b2(std::move(r));
85 EXPECT_EQ(bundle.GetString("TestKey"), "TestVal");
88 TEST(Bundle, GetCount) {
90 bundle.Add("TestKey1", "TestVal1");
91 bundle.Add("TestKey2", "TestVal2");
93 EXPECT_EQ(bundle.GetCount(), 2);
96 TEST(Bundle, Remove) {
98 int r = bundle.Add("TestKey1", "TestVal1");
101 r = bundle.Remove("TestKey1");
104 EXPECT_EQ(bundle.GetString("TestKey1"), "");
107 TEST(Bundle, GetKeys) {
109 bundle.Add("TestKey1", "TestVal1");
110 bundle.Add("TestKey2", "TestVal2");
111 bundle.Add("TestKey3", "TestVal3");
113 auto v = bundle.GetKeys();
115 EXPECT_EQ(bundle.GetCount(), 3);
118 EXPECT_EQ(i.GetType(), BUNDLE_TYPE_STR);