1 // Copyright 2015 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <stdio.h>
6 #include <gtest/gtest.h>
7
8 extern "C" {
9 #include "softvol_curve.h"
10 }
11
12 namespace {
13
14 static float ABS_ERROR = 0.0000001;
15
TEST(SoftvolCurveTest,ScalerDecibelConvert)16 TEST(SoftvolCurveTest, ScalerDecibelConvert) {
17 float scaler;
18 scaler = convert_softvol_scaler_from_dB(-2000);
19 EXPECT_NEAR(scaler, 0.1f, ABS_ERROR);
20 scaler = convert_softvol_scaler_from_dB(-1000);
21 EXPECT_NEAR(scaler, 0.3162277f, ABS_ERROR);
22 scaler = convert_softvol_scaler_from_dB(-4000);
23 EXPECT_NEAR(scaler, 0.01f, ABS_ERROR);
24 scaler = convert_softvol_scaler_from_dB(-3500);
25 EXPECT_NEAR(scaler, 0.0177828f, ABS_ERROR);
26 }
27
28 } // namespace
29
30 /* Stubs */
31 extern "C" {
32
33 } // extern "C"
34
main(int argc,char ** argv)35 int main(int argc, char **argv) {
36 ::testing::InitGoogleTest(&argc, argv);
37 return RUN_ALL_TESTS();
38 }
39
40