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

Unified Diff: webrtc/stats/rtcstats_unittest.cc

Issue 2441543002: RTCStats equality operator added (Closed)
Patch Set: Addressed comments 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
« no previous file with comments | « 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..95e5e97c5a124471399fe2e9bfc9a8718f5de38b 100644
--- a/webrtc/stats/rtcstats_unittest.cc
+++ b/webrtc/stats/rtcstats_unittest.cc
@@ -113,6 +113,64 @@ 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);
+ EXPECT_NE(defined.m_int32, defined.m_uint32);
+
+ 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]);
+ }
+
+ 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.
+ EXPECT_NE(undefined, undefined_diff_id);
+ RTCTestStats undefined_diff_timestamp("testId", 321);
+ EXPECT_NE(undefined, undefined_diff_timestamp);
+
+ RTCChildStats child("childId", 42);
+ RTCGrandChildStats grandchild("grandchildId", 42);
+ EXPECT_NE(child, grandchild);
+}
+
TEST(RTCStatsTest, RTCStatsGrandChild) {
RTCGrandChildStats stats("grandchild", 0.0);
stats.child_int = 1;
« no previous file with comments | « webrtc/stats/rtcstats.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698