Skip to content

Commit

Permalink
fix the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanthecoder committed Oct 14, 2024
1 parent 04431dd commit fe2b7aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 3 additions & 1 deletion include/sensors/core/tasks/capacitive_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ class FDC1004 {
return;
}
for (uint8_t i = 0; i < data_len; i++) {
data.at(i) = convert_to_fixed_point((*sensor_buffer).at(sensor_buffer_index_start + i), S15Q16_RADIX);
data.at(i) = convert_to_fixed_point(
(*sensor_buffer).at(sensor_buffer_index_start + i),
S15Q16_RADIX);
}
auto response = can::messages::BatchReadFromSensorResponse{
.message_index = message_index,
Expand Down
19 changes: 11 additions & 8 deletions sensors/tests/test_capacitive_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,7 @@ SCENARIO("read capacitance sensor values supporting shared CINs") {
WHEN("A response for S1 is received") {
auto buffer_a = i2c::messages::MaxMessageBuffer{0, 0, 0, 0, 0};
auto buffer_b = i2c::messages::MaxMessageBuffer{0, 0, 0, 0, 0};
std::array tags{sensors::utils::ResponseTag::IS_PART_OF_POLL,
sensors::utils::ResponseTag::POLL_IS_CONTINUOUS};
std::array tags{sensors::utils::ResponseTag::IS_PART_OF_POLL};
i2c::messages::TransactionResponse first{
.id =
i2c::messages::TransactionIdentifier{
Expand Down Expand Up @@ -621,8 +620,10 @@ SCENARIO("capacitance driver tests no shared CINs") {
auto second = first;
second.id.transaction_index = 1;
second.read_buffer = buffer_b;
callback_host.handle_ongoing_response(first);
callback_host.handle_ongoing_response(second);
for (auto i = 0; i < 14; i++) {
callback_host.handle_ongoing_response(first);
callback_host.handle_ongoing_response(second);
}

THEN("it should forward the converted data via can") {
REQUIRE(can_queue.has_message());
Expand Down Expand Up @@ -654,17 +655,19 @@ SCENARIO("capacitance driver tests no shared CINs") {
second.id.transaction_index = 1;
second.read_buffer = buffer_b;

callback_host.handle_ongoing_response(first);
callback_host.handle_ongoing_response(second);
for (auto i = 0; i < 14; i++) {
callback_host.handle_ongoing_response(first);
callback_host.handle_ongoing_response(second);
}

THEN("it should forward the converted data via can") {
can_queue.try_read(&empty_msg);
auto sent = std::get<can::messages::ReadFromSensorResponse>(
auto sent = std::get<can::messages::BatchReadFromSensorResponse>(
empty_msg.message);
REQUIRE(sent.sensor == can::ids::SensorType::capacitive);
// we're just checking that the data is faithfully represented,
// don't really care what it is
REQUIRE(sent.sensor_data ==
REQUIRE(sent.sensor_data[0] ==
convert_to_fixed_point(15, S15Q16_RADIX));
}
THEN("it should not touch the sync line") {
Expand Down

0 comments on commit fe2b7aa

Please sign in to comment.