summaryrefslogtreecommitdiff
path: root/cras/src/tests/softvol_curve_unittest.cc
blob: d14445887fcb7763982f1178d98f0d4f125f735e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2015 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <gtest/gtest.h>
#include <stdio.h>

extern "C" {
#include "softvol_curve.h"
}

namespace {

static float ABS_ERROR = 0.0000001;

TEST(SoftvolCurveTest, ScalerDecibelConvert) {
  float scaler;
  scaler = convert_softvol_scaler_from_dB(-2000);
  EXPECT_NEAR(scaler, 0.1f, ABS_ERROR);
  scaler = convert_softvol_scaler_from_dB(-1000);
  EXPECT_NEAR(scaler, 0.3162277f, ABS_ERROR);
  scaler = convert_softvol_scaler_from_dB(-4000);
  EXPECT_NEAR(scaler, 0.01f, ABS_ERROR);
  scaler = convert_softvol_scaler_from_dB(-3500);
  EXPECT_NEAR(scaler, 0.0177828f, ABS_ERROR);
}

}  //  namespace

/* Stubs */
extern "C" {}  // extern "C"

int main(int argc, char** argv) {
  ::testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}