Skip to content

Commit

Permalink
Updated unit testing fixture to add rpm and wheel speed dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
crsz20 committed Jul 11, 2024
1 parent 58f05be commit f8e2158
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 3 deletions.
69 changes: 69 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"files.associations": {
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"chrono": "cpp",
"cinttypes": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"semaphore": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"typeinfo": "cpp",
"variant": "cpp"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ class ShiftController {
};

State* current_state_{&neutral_state_};
int16_t& rpm_;
std::array<float, 2>& wheel_speeds_;


public:
ShiftController(int16_t &rpm_observer,
Expand All @@ -75,13 +74,15 @@ class ShiftController {
State* GetState() { return current_state_; }



private:
void SetState(State* new_state);
LowGear low_gear_state_;
Neutral neutral_state_;
MidGear mid_gear_state_;
HighGear high_gear_state_;

int16_t& rpm_;
std::array<float, 2>& wheel_speeds_;
};

} // namespace application
Expand Down
1 change: 1 addition & 0 deletions Firmware/Shifter_System/Program/Src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ void cppMain() {
can_bus->EnableInterruptMode();
}

shift_controller.Run();

}
}
Expand Down
8 changes: 8 additions & 0 deletions Firmware/Tests/Src/Application/shift_controller_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ namespace application {

class ShiftControllerWrapper : public ShiftController {
public:

int16_t rpm_;
std::array<float, 2> wheel_speeds_;

ShiftControllerWrapper()
: ShiftController(rpm_,
wheel_speeds_) { }

bool IsLowGearState() { return dynamic_cast<LowGear*>(current_state_) != nullptr; }
bool IsNeutralState() { return dynamic_cast<Neutral*>(current_state_) != nullptr; }
bool IsMidGearState() { return dynamic_cast<MidGear*>(current_state_) != nullptr; }
Expand Down

0 comments on commit f8e2158

Please sign in to comment.