Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
Updated unit tests for updated type bit parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
crsz20 committed Jan 5, 2024
1 parent fff8615 commit d89988a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions Project/Tests/Src/Sensor/ECU/PE3/frame_parsing_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ class Pe3EcuFrameFieldParsingFixture : public testing::Test {
uint8_t rx_buffer[kByteArrayMaxLength] = { 0xBE, 0x05,
0xBB, 0x05,
0x8F, 0x03,
0x00, 0xFF };
0x01, 0xFF };

// Expected output
const int16_t kExpectedField1 = 1470;
const int16_t kExpectedField2 = 1467;
const int16_t kExpectedField3 = 911;
const int16_t kExpectedField4 = 65280;
const int16_t kExpectedField4 = 65281;
};

TEST_F(Pe3EcuFrameFieldParsingFixture, ParseFieldsOutput) {
Expand Down Expand Up @@ -108,8 +108,8 @@ TEST_F(Pe3EcuFrameFieldParsingFixture, ExcessiveFieldsRequested) {
EXPECT_FALSE(ParseFields(rx_buffer, fields));
}

TEST_F(Pe3EcuFrameFieldParsingFixture, ParseTypeBitUnkown) {
rx_buffer[7] = 0xA0;
TEST_F(Pe3EcuFrameFieldParsingFixture, ParseTypeBitUnknown) {
rx_buffer[kByteArrayMaxLength - 2] = 0xA0;
EXPECT_EQ(ParseTypeBit(rx_buffer), TypeBit::kUnknown);
}

Expand All @@ -118,7 +118,7 @@ TEST_F(Pe3EcuFrameFieldParsingFixture, ParseTypeBitHigh) {
}

TEST_F(Pe3EcuFrameFieldParsingFixture, ParseTypeBitLow) {
rx_buffer[7] = 0;
rx_buffer[kByteArrayMaxLength - 2] = 0;
EXPECT_EQ(ParseTypeBit(rx_buffer), TypeBit::kLow);
}

Expand Down
12 changes: 6 additions & 6 deletions Project/Tests/Src/Sensor/ECU/PE3/pe_frames_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ TEST(Pe3EcuFrames, FramePe2PressureKiloPascal) {
uint8_t rx_buffer[kByteArrayMaxLength] = { 0xBE, 0x05,
0xBB, 0x05,
0x8F, 0x03,
0x00, 0xFF };
0x01, 0xFF };
FramePE2 frame(rx_buffer);

static constexpr float kExpectedBarometerPressure = 14.7f;
Expand All @@ -82,7 +82,7 @@ TEST(Pe3EcuFrames, FramePe2PressurePoundsPerSquareInch) {
uint8_t rx_buffer[kByteArrayMaxLength] = { 0xBE, 0x05,
0xBB, 0x05,
0x8F, 0x03,
0x00, 0x00 };
0x00, 0xFF };
FramePE2 frame(rx_buffer);

static constexpr PressureType kExpectedPressureUnit = PressureType::kPoundsPerSquareInch;
Expand All @@ -94,7 +94,7 @@ TEST(Pe3EcuFrames, FramePe2PressureUnkown) {
uint8_t rx_buffer[kByteArrayMaxLength] = { 0xBE, 0x05,
0xBB, 0x05,
0x8F, 0x03,
0x00, 0x0A };
0x0A, 0xFF };
FramePE2 frame(rx_buffer);

static constexpr PressureType kExpectedPressureUnit = PressureType::kUnknown;
Expand Down Expand Up @@ -202,7 +202,7 @@ TEST(Pe3EcuFrames, FramePe6TempCelsius) {
uint8_t rx_buffer[kByteArrayMaxLength] = { 0x14, 0x05,
0xAA, 0x02,
0xCE, 0x02,
0x00, 0xFF };
0x01, 0xFF };
FramePE6 frame(rx_buffer);

static constexpr float kExpectedBatteryVoltage = 13.0f;
Expand All @@ -228,12 +228,12 @@ TEST(Pe3EcuFrames, FramePe6TempFaranheit) {
EXPECT_EQ(frame.TemperatureUnit(), kExpectedTemperatureUnit);
}

TEST(Pe3EcuFrames, FramePe6TempUnkown) {
TEST(Pe3EcuFrames, FramePe6TempUnknown) {
// Sample data
uint8_t rx_buffer[kByteArrayMaxLength] = { 0x14, 0x05,
0xAA, 0x02,
0xCE, 0x02,
0x00, 0x0C };
0xCC, 0xFF };
FramePE6 frame(rx_buffer);

static constexpr TemperatureType kExpectedTemperatureUnit = TemperatureType::kUnknown;
Expand Down

0 comments on commit d89988a

Please sign in to comment.