OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 | 106 |
107 int32_t numbers[] = { 4, 8, 15, 16, 23, 42 }; | 107 int32_t numbers[] = { 4, 8, 15, 16, 23, 42 }; |
108 std::vector<int32_t> numbers_sequence(&numbers[0], &numbers[6]); | 108 std::vector<int32_t> numbers_sequence(&numbers[0], &numbers[6]); |
109 stats.m_sequence_int32->clear(); | 109 stats.m_sequence_int32->clear(); |
110 stats.m_sequence_int32->insert(stats.m_sequence_int32->end(), | 110 stats.m_sequence_int32->insert(stats.m_sequence_int32->end(), |
111 numbers_sequence.begin(), | 111 numbers_sequence.begin(), |
112 numbers_sequence.end()); | 112 numbers_sequence.end()); |
113 EXPECT_EQ(*stats.m_sequence_int32, numbers_sequence); | 113 EXPECT_EQ(*stats.m_sequence_int32, numbers_sequence); |
114 } | 114 } |
115 | 115 |
116 TEST(RTCStatsTest, EqualityOperator) { | |
117 RTCTestStats undefined("testId", 123); | |
118 EXPECT_EQ(undefined, undefined); | |
119 | |
120 RTCTestStats defined = undefined; | |
121 defined.m_bool = true; | |
122 defined.m_int32 = 123; | |
123 defined.m_uint32 = 123; | |
124 defined.m_int64 = 123; | |
125 defined.m_uint64 = 123; | |
126 defined.m_double = 123.0; | |
127 defined.m_string = "123"; | |
128 defined.m_sequence_bool = std::vector<bool>(); | |
129 defined.m_sequence_int32 = std::vector<int32_t>(); | |
130 defined.m_sequence_uint32 = std::vector<uint32_t>(); | |
131 defined.m_sequence_int64 = std::vector<int64_t>(); | |
132 defined.m_sequence_uint64 = std::vector<uint64_t>(); | |
133 defined.m_sequence_double = std::vector<double>(); | |
134 defined.m_sequence_string = std::vector<std::string>(); | |
135 EXPECT_NE(defined, undefined); | |
136 EXPECT_EQ(defined, defined); | |
137 | |
138 RTCTestStats diffs[] = { | |
139 defined, defined, defined, defined, defined, defined, defined, defined, | |
140 defined, defined, defined, defined, defined, defined, | |
141 }; | |
142 for (size_t i = 0; i < 14; ++i) { | |
143 EXPECT_EQ(defined, diffs[i]); | |
144 } | |
145 diffs[0].m_bool = false; | |
146 diffs[1].m_int32 = 321; | |
147 diffs[2].m_uint32 = 321; | |
148 diffs[3].m_int64 = 321; | |
149 diffs[4].m_uint64 = 321; | |
150 diffs[5].m_double = 321.0; | |
151 diffs[6].m_string = "321"; | |
152 diffs[7].m_sequence_bool->push_back(false); | |
153 diffs[8].m_sequence_int32->push_back(321); | |
154 diffs[9].m_sequence_uint32->push_back(321); | |
155 diffs[10].m_sequence_int64->push_back(321); | |
156 diffs[11].m_sequence_uint64->push_back(321); | |
157 diffs[12].m_sequence_double->push_back(321.0); | |
158 diffs[13].m_sequence_string->push_back("321"); | |
159 for (size_t i = 0; i < 14; ++i) { | |
160 EXPECT_NE(defined, diffs[i]); | |
161 } | |
hta-webrtc
2016/10/21 08:56:01
Add a check for the case where types are different
hbos_chromium
2016/10/21 18:59:18
Done.
| |
162 } | |
163 | |
116 TEST(RTCStatsTest, RTCStatsGrandChild) { | 164 TEST(RTCStatsTest, RTCStatsGrandChild) { |
117 RTCGrandChildStats stats("grandchild", 0.0); | 165 RTCGrandChildStats stats("grandchild", 0.0); |
118 stats.child_int = 1; | 166 stats.child_int = 1; |
119 stats.grandchild_int = 2; | 167 stats.grandchild_int = 2; |
120 int32_t sum = 0; | 168 int32_t sum = 0; |
121 for (const RTCStatsMemberInterface* member : stats.Members()) { | 169 for (const RTCStatsMemberInterface* member : stats.Members()) { |
122 sum += *member->cast_to<const RTCStatsMember<int32_t>>(); | 170 sum += *member->cast_to<const RTCStatsMember<int32_t>>(); |
123 } | 171 } |
124 EXPECT_EQ(sum, static_cast<int32_t>(3)); | 172 EXPECT_EQ(sum, static_cast<int32_t>(3)); |
125 | 173 |
(...skipping 15 matching lines...) Expand all Loading... | |
141 } | 189 } |
142 | 190 |
143 TEST(RTCStatsDeathTest, InvalidCasting) { | 191 TEST(RTCStatsDeathTest, InvalidCasting) { |
144 RTCGrandChildStats stats("grandchild", 0.0); | 192 RTCGrandChildStats stats("grandchild", 0.0); |
145 EXPECT_DEATH(stats.cast_to<RTCChildStats>(), ""); | 193 EXPECT_DEATH(stats.cast_to<RTCChildStats>(), ""); |
146 } | 194 } |
147 | 195 |
148 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 196 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
149 | 197 |
150 } // namespace webrtc | 198 } // namespace webrtc |
OLD | NEW |