Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: webrtc/stats/rtcstats_unittest.cc

Issue 2441543002: RTCStats equality operator added (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« webrtc/stats/rtcstats.cc ('K') | « webrtc/stats/rtcstats.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/stats/rtcstats_unittest.cc
diff --git a/webrtc/stats/rtcstats_unittest.cc b/webrtc/stats/rtcstats_unittest.cc
index ad839d811dbbfe747f80c9b60daf4eb08fa95352..a5a41604b591726037ee1183e7f257c83d1087cf 100644
--- a/webrtc/stats/rtcstats_unittest.cc
+++ b/webrtc/stats/rtcstats_unittest.cc
@@ -113,6 +113,54 @@ TEST(RTCStatsTest, RTCStatsAndMembers) {
EXPECT_EQ(*stats.m_sequence_int32, numbers_sequence);
}
+TEST(RTCStatsTest, EqualityOperator) {
+ RTCTestStats undefined("testId", 123);
+ EXPECT_EQ(undefined, undefined);
+
+ RTCTestStats defined = undefined;
+ defined.m_bool = true;
+ defined.m_int32 = 123;
+ defined.m_uint32 = 123;
+ defined.m_int64 = 123;
+ defined.m_uint64 = 123;
+ defined.m_double = 123.0;
+ defined.m_string = "123";
+ defined.m_sequence_bool = std::vector<bool>();
+ defined.m_sequence_int32 = std::vector<int32_t>();
+ defined.m_sequence_uint32 = std::vector<uint32_t>();
+ defined.m_sequence_int64 = std::vector<int64_t>();
+ defined.m_sequence_uint64 = std::vector<uint64_t>();
+ defined.m_sequence_double = std::vector<double>();
+ defined.m_sequence_string = std::vector<std::string>();
+ EXPECT_NE(defined, undefined);
+ EXPECT_EQ(defined, defined);
+
+ RTCTestStats diffs[] = {
+ defined, defined, defined, defined, defined, defined, defined, defined,
+ defined, defined, defined, defined, defined, defined,
+ };
+ for (size_t i = 0; i < 14; ++i) {
+ EXPECT_EQ(defined, diffs[i]);
+ }
+ diffs[0].m_bool = false;
+ diffs[1].m_int32 = 321;
+ diffs[2].m_uint32 = 321;
+ diffs[3].m_int64 = 321;
+ diffs[4].m_uint64 = 321;
+ diffs[5].m_double = 321.0;
+ diffs[6].m_string = "321";
+ diffs[7].m_sequence_bool->push_back(false);
+ diffs[8].m_sequence_int32->push_back(321);
+ diffs[9].m_sequence_uint32->push_back(321);
+ diffs[10].m_sequence_int64->push_back(321);
+ diffs[11].m_sequence_uint64->push_back(321);
+ diffs[12].m_sequence_double->push_back(321.0);
+ diffs[13].m_sequence_string->push_back("321");
+ for (size_t i = 0; i < 14; ++i) {
+ EXPECT_NE(defined, diffs[i]);
+ }
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.
+}
+
TEST(RTCStatsTest, RTCStatsGrandChild) {
RTCGrandChildStats stats("grandchild", 0.0);
stats.child_int = 1;
« webrtc/stats/rtcstats.cc ('K') | « webrtc/stats/rtcstats.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698