// Copyright 2021 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "components/optimization_guide/core/noisy_metrics_recorder.h" #include <cmath> #include "base/check_op.h" #include "base/logging.h" #include "base/rand_util.h" #include "testing/gtest/include/gtest/gtest.h" // Tests that the original metric is returned as it is when the bit flip // probability is set to 0. TEST(NoisyMetricsRecorderTest, BasicsNoNoise) { … } // Tests that the original metric is within the expected bounds. TEST(NoisyMetricsRecorderTest, RandomNoise) { … } // TestNoisyMetricsRecorder returns deterministic random number based on how // it's configured. class TestNoisyMetricsRecorder : public NoisyMetricsRecorder { … }; TEST(NoisyMetricsRecorderTest, All0s) { … } TEST(NoisyMetricsRecorderTest, All1s) { … } // Tests that the flipped return value matches the expected value. The noise is // added deterministically using TestNoisyMetricsRecorder. TEST(NoisyMetricsRecorderTest, AlternateBits) { … }