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

Side by Side Diff: tools/battor_agent/battor_sample_converter_unittest.cc

Issue 1648123002: Fix narrowing warning in battor_sample_converter_unittest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/battor_agent/battor_sample_converter.h" 5 #include "tools/battor_agent/battor_sample_converter.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "tools/battor_agent/battor_protocol_types.h" 10 #include "tools/battor_agent/battor_protocol_types.h"
11 11
12 using namespace testing; 12 using namespace testing;
13 13
14 namespace battor { 14 namespace battor {
15 15
16 TEST(BattOrSampleConverterTest, ToSampleSimple) { 16 TEST(BattOrSampleConverterTest, ToSampleSimple) {
17 BattOrEEPROM eeprom; 17 BattOrEEPROM eeprom;
18 eeprom.r1 = 1.0f; 18 eeprom.r1 = 1.0f;
19 eeprom.r2 = 1.0f; 19 eeprom.r2 = 1.0f;
20 eeprom.r3 = 1.0f; 20 eeprom.r3 = 1.0f;
21 eeprom.low_gain = 1.0f; 21 eeprom.low_gain = 1.0f;
22 eeprom.low_gain_correction_offset = 0.0f; 22 eeprom.low_gain_correction_offset = 0.0f;
23 eeprom.low_gain_correction_factor = 1.0f; 23 eeprom.low_gain_correction_factor = 1.0f;
24 eeprom.sd_sample_rate = 1000; 24 eeprom.sd_sample_rate = 1000;
25 25
26 // Create a calibration frame with a baseline voltage and current of zero. 26 // Create a calibration frame with a baseline voltage and current of zero.
27 std::vector<RawBattOrSample> calibration_frame; 27 std::vector<RawBattOrSample> calibration_frame;
28 calibration_frame.push_back(RawBattOrSample{0.0, 0.0}); 28 calibration_frame.push_back(RawBattOrSample{0, 0});
29 BattOrSampleConverter converter(eeprom, calibration_frame); 29 BattOrSampleConverter converter(eeprom, calibration_frame);
30 30
31 // Set both the voltage and current to their max values. 31 // Set both the voltage and current to their max values.
32 RawBattOrSample raw_one{2048, 2048}; 32 RawBattOrSample raw_one{2048, 2048};
33 BattOrSample one = converter.ToSample(raw_one, 0); 33 BattOrSample one = converter.ToSample(raw_one, 0);
34 34
35 ASSERT_DOUBLE_EQ(0, one.time_ms); 35 ASSERT_DOUBLE_EQ(0, one.time_ms);
36 ASSERT_DOUBLE_EQ(2401.172447484123, one.voltage_mV); 36 ASSERT_DOUBLE_EQ(2401.172447484123, one.voltage_mV);
37 ASSERT_DOUBLE_EQ(1200.5862237420615, one.current_mA); 37 ASSERT_DOUBLE_EQ(1200.5862237420615, one.current_mA);
38 } 38 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 BattOrSample one = converter.ToSample(RawBattOrSample{0, 0}, 0); 152 BattOrSample one = converter.ToSample(RawBattOrSample{0, 0}, 0);
153 BattOrSample two = converter.ToSample(RawBattOrSample{0, 0}, 1); 153 BattOrSample two = converter.ToSample(RawBattOrSample{0, 0}, 1);
154 BattOrSample three = converter.ToSample(RawBattOrSample{0, 0}, 2); 154 BattOrSample three = converter.ToSample(RawBattOrSample{0, 0}, 2);
155 155
156 ASSERT_DOUBLE_EQ(0, one.time_ms); 156 ASSERT_DOUBLE_EQ(0, one.time_ms);
157 ASSERT_DOUBLE_EQ(20, two.time_ms); 157 ASSERT_DOUBLE_EQ(20, two.time_ms);
158 ASSERT_DOUBLE_EQ(40, three.time_ms); 158 ASSERT_DOUBLE_EQ(40, three.time_ms);
159 } 159 }
160 160
161 } // namespace battor 161 } // namespace battor
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698