Chromium Code Reviews| 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 EXPECT_NE(defined.m_int32, defined.m_uint32); | |
| 138 | |
| 139 RTCTestStats diffs[] = { | |
| 140 defined, defined, defined, defined, defined, defined, defined, defined, | |
| 141 defined, defined, defined, defined, defined, defined, | |
| 142 }; | |
| 143 for (size_t i = 0; i < 14; ++i) { | |
| 144 EXPECT_EQ(defined, diffs[i]); | |
| 145 } | |
| 146 diffs[0].m_bool = false; | |
| 147 diffs[1].m_int32 = 321; | |
| 148 diffs[2].m_uint32 = 321; | |
| 149 diffs[3].m_int64 = 321; | |
| 150 diffs[4].m_uint64 = 321; | |
| 151 diffs[5].m_double = 321.0; | |
| 152 diffs[6].m_string = "321"; | |
| 153 diffs[7].m_sequence_bool->push_back(false); | |
| 154 diffs[8].m_sequence_int32->push_back(321); | |
| 155 diffs[9].m_sequence_uint32->push_back(321); | |
| 156 diffs[10].m_sequence_int64->push_back(321); | |
| 157 diffs[11].m_sequence_uint64->push_back(321); | |
| 158 diffs[12].m_sequence_double->push_back(321.0); | |
| 159 diffs[13].m_sequence_string->push_back("321"); | |
| 160 for (size_t i = 0; i < 14; ++i) { | |
| 161 EXPECT_NE(defined, diffs[i]); | |
| 162 } | |
| 163 | |
| 164 RTCTestStats undefined_diff_id("testId2", 123); | |
|
hta-webrtc
2016/10/25 10:30:30
"undefined" is a very poor name, because it looks
hbos
2016/10/25 10:49:41
Done.
| |
| 165 EXPECT_NE(undefined, undefined_diff_id); | |
| 166 RTCTestStats undefined_diff_timestamp("testId", 321); | |
| 167 EXPECT_NE(undefined, undefined_diff_timestamp); | |
| 168 | |
| 169 RTCChildStats child("childId", 42); | |
| 170 RTCGrandChildStats grandchild("grandchildId", 42); | |
| 171 EXPECT_NE(child, grandchild); | |
| 172 } | |
| 173 | |
| 116 TEST(RTCStatsTest, RTCStatsGrandChild) { | 174 TEST(RTCStatsTest, RTCStatsGrandChild) { |
| 117 RTCGrandChildStats stats("grandchild", 0.0); | 175 RTCGrandChildStats stats("grandchild", 0.0); |
| 118 stats.child_int = 1; | 176 stats.child_int = 1; |
| 119 stats.grandchild_int = 2; | 177 stats.grandchild_int = 2; |
| 120 int32_t sum = 0; | 178 int32_t sum = 0; |
| 121 for (const RTCStatsMemberInterface* member : stats.Members()) { | 179 for (const RTCStatsMemberInterface* member : stats.Members()) { |
| 122 sum += *member->cast_to<const RTCStatsMember<int32_t>>(); | 180 sum += *member->cast_to<const RTCStatsMember<int32_t>>(); |
| 123 } | 181 } |
| 124 EXPECT_EQ(sum, static_cast<int32_t>(3)); | 182 EXPECT_EQ(sum, static_cast<int32_t>(3)); |
| 125 | 183 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 141 } | 199 } |
| 142 | 200 |
| 143 TEST(RTCStatsDeathTest, InvalidCasting) { | 201 TEST(RTCStatsDeathTest, InvalidCasting) { |
| 144 RTCGrandChildStats stats("grandchild", 0.0); | 202 RTCGrandChildStats stats("grandchild", 0.0); |
| 145 EXPECT_DEATH(stats.cast_to<RTCChildStats>(), ""); | 203 EXPECT_DEATH(stats.cast_to<RTCChildStats>(), ""); |
| 146 } | 204 } |
| 147 | 205 |
| 148 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 206 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
| 149 | 207 |
| 150 } // namespace webrtc | 208 } // namespace webrtc |
| OLD | NEW |