From f2ecdd7ea3aefa9d65b3fe6b983cf584c7465237 Mon Sep 17 00:00:00 2001 From: Fanny Linderborg Date: Fri, 24 Jan 2025 12:40:28 +0100 Subject: [PATCH] Use ElementsAreArray in corruption detection unittests Remove incorrect parantheses around expression as well Bug: webrtc:358039777 Change-Id: I0e5de93b3ef23a18989e50fbe70a37c6ed198290 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/375240 Reviewed-by: Danil Chapovalov Commit-Queue: Fanny Linderborg Cr-Commit-Position: refs/heads/main@{#43796} --- ...corruption_detection_extension_unittest.cc | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/modules/rtp_rtcp/source/corruption_detection_extension_unittest.cc b/modules/rtp_rtcp/source/corruption_detection_extension_unittest.cc index 26d70061df..356feb1220 100644 --- a/modules/rtp_rtcp/source/corruption_detection_extension_unittest.cc +++ b/modules/rtp_rtcp/source/corruption_detection_extension_unittest.cc @@ -23,6 +23,7 @@ namespace { using ::testing::DoubleEq; using ::testing::ElementsAre; +using ::testing::ElementsAreArray; TEST(CorruptionDetectionExtensionTest, ValueSizeIs1UnlessSamplesAreSpecified) { const std::optional kMessage = @@ -117,7 +118,7 @@ TEST(CorruptionDetectionExtensionTest, CorruptionDetectionMessage::Builder() .WithSequenceIndex(0b0110'1111) .WithInterpretSequenceIndexAsMostSignificantBits(true) - .WithStdDev(34.5098) // 220 / (255.0 * 40.0) + .WithStdDev(34.5098) // 220 / 255.0 * 40.0 .WithLumaErrorThreshold(0b1110) .WithChromaErrorThreshold(0b1111) .WithSampleValues(kSampleValues) @@ -138,7 +139,7 @@ TEST(CorruptionDetectionExtensionTest, CorruptionDetectionMessage::Builder() .WithSequenceIndex(0b0110'1111) .WithInterpretSequenceIndexAsMostSignificantBits(false) - .WithStdDev(34.5098) // 220 / (255.0 * 40.0) + .WithStdDev(34.5098) // 220 / 255.0 * 40.0 .WithLumaErrorThreshold(0b1110) .WithChromaErrorThreshold(0b1111) .WithSampleValues(kSampleValues) @@ -201,13 +202,10 @@ TEST(CorruptionDetectionExtensionTest, EXPECT_EQ(message.sequence_index(), 0b0100'0100); EXPECT_TRUE(message.interpret_sequence_index_as_most_significant_bits()); EXPECT_THAT(message.std_dev(), - DoubleEq(34.509803921568626)); // 220 / (255.0 * 40.0) + DoubleEq(34.509803921568626)); // 220 / 255.0 * 40.0 EXPECT_EQ(message.luma_error_threshold(), 0b1110); EXPECT_EQ(message.chroma_error_threshold(), 0b1111); - EXPECT_EQ(message.sample_values().size(), sizeof(kSampleValues)); - for (size_t i = 0; i < sizeof(kSampleValues); ++i) { - EXPECT_EQ(message.sample_values()[i], kSampleValues[i]); - } + EXPECT_THAT(message.sample_values(), ElementsAreArray(kSampleValues)); } TEST(CorruptionDetectionExtensionTest, @@ -227,13 +225,10 @@ TEST(CorruptionDetectionExtensionTest, EXPECT_EQ(message.sequence_index(), 0b0100'0100); EXPECT_FALSE(message.interpret_sequence_index_as_most_significant_bits()); EXPECT_THAT(message.std_dev(), - DoubleEq(34.509803921568626)); // 220 / (255.0 * 40.0) + DoubleEq(34.509803921568626)); // 220 / 255.0 * 40.0 EXPECT_EQ(message.luma_error_threshold(), 0b1110); EXPECT_EQ(message.chroma_error_threshold(), 0b1111); - EXPECT_EQ(message.sample_values().size(), sizeof(kSampleValues)); - for (size_t i = 0; i < sizeof(kSampleValues); ++i) { - EXPECT_EQ(message.sample_values()[i], kSampleValues[i]); - } + EXPECT_THAT(message.sample_values(), ElementsAreArray(kSampleValues)); } TEST(CorruptionDetectionExtensionTest, FailsToParseWhenGivenNullptrAsOutput) {