Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
🎨 Move to east const
Browse files Browse the repository at this point in the history
  • Loading branch information
kammce committed Aug 18, 2024
1 parent ec5a120 commit 5aba7cc
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 30 deletions.
3 changes: 2 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ AlwaysBreakAfterDefinitionReturnType: None
AllowShortFunctionsOnASingleLine: None
FixNamespaceComments: true
SpacesBeforeTrailingComments: 2
ColumnLimit: 80
ColumnLimit: 80
QualifierAlignment: Right
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,3 @@ See [`CONTRIBUTING.md`](CONTRIBUTING.md) for details.
## License

Apache 2.0; see [`LICENSE`](LICENSE) for details.

## Disclaimer

This project is not an official Google project. It is not supported by
Google and Google specifically disclaims all warranties as to its quality,
merchantability, or fitness for a particular purpose.
8 changes: 4 additions & 4 deletions include/libhal-mock/can.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct can : public hal::can
spy_handler<hal::callback<handler>> spy_on_receive;

private:
void driver_configure(const settings& p_settings) override
void driver_configure(settings const& p_settings) override
{
spy_configure.record(p_settings);
}
Expand All @@ -58,7 +58,7 @@ struct can : public hal::can
spy_bus_on.record(true);
}

void driver_send(const message_t& p_message) override
void driver_send(message_t const& p_message) override
{
spy_send.record(p_message);
}
Expand Down Expand Up @@ -86,13 +86,13 @@ struct can : public hal::can
template<class CharT, class Traits>
std::basic_ostream<CharT, Traits>& operator<<(
std::basic_ostream<CharT, Traits>& p_ostream,
const hal::can::message_t& p_message)
hal::can::message_t const& p_message)
{
p_ostream << "{ id: " << std::hex << "0x" << p_message.id;
p_ostream << ", length: " << std::dec << unsigned{ p_message.length };
p_ostream << ", is_remote_request: " << p_message.is_remote_request;
p_ostream << ", payload = [";
for (const auto& element : p_message.payload) {
for (auto const& element : p_message.payload) {
p_ostream << std::hex << "0x" << unsigned{ element } << ", ";
}
p_ostream << "] }";
Expand Down
2 changes: 1 addition & 1 deletion include/libhal-mock/input_pin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct input_pin : public hal::input_pin
}

private:
void driver_configure(const settings& p_settings) override
void driver_configure(settings const& p_settings) override
{
spy_configure.record(p_settings);
}
Expand Down
2 changes: 1 addition & 1 deletion include/libhal-mock/interrupt_pin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct interrupt_pin : public hal::interrupt_pin
spy_handler<std::function<handler>> spy_on_trigger;

private:
void driver_configure(const settings& p_settings) override
void driver_configure(settings const& p_settings) override
{
spy_configure.record(p_settings);
}
Expand Down
2 changes: 1 addition & 1 deletion include/libhal-mock/output_pin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct output_pin : public hal::output_pin
spy_handler<bool> spy_level;

private:
void driver_configure(const settings& p_settings) override
void driver_configure(settings const& p_settings) override
{
spy_configure.record(p_settings);
}
Expand Down
4 changes: 2 additions & 2 deletions include/libhal-mock/spi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ struct write_only_spi : public hal::spi
std::vector<std::vector<hal::byte>> write_record;

private:
void driver_configure(const settings& p_settings) override
void driver_configure(settings const& p_settings) override
{
spy_configure.record(p_settings);
};

void driver_transfer(std::span<const hal::byte> p_data_out,
void driver_transfer(std::span<hal::byte const> p_data_out,
[[maybe_unused]] std::span<hal::byte> p_data_in,
[[maybe_unused]] hal::byte p_filler) override
{
Expand Down
14 changes: 7 additions & 7 deletions include/libhal-mock/testing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class spy_handler
*
* @return const auto& - reference to the call history vector
*/
[[nodiscard]] const auto& call_history() const
[[nodiscard]] auto const& call_history() const
{
return m_call_history;
}
Expand All @@ -102,7 +102,7 @@ class spy_handler
* @throws std::out_of_range - if p_call is beyond the size of call_history
*/
template<size_t ArgumentIndex>
[[nodiscard]] const auto& history(size_t p_call) const
[[nodiscard]] auto const& history(size_t p_call) const
{
return std::get<ArgumentIndex>(m_call_history.at(p_call));
}
Expand All @@ -127,28 +127,28 @@ class spy_handler
template<typename Rep, typename Period>
inline std::ostream& operator<<(
std::ostream& p_os,
const std::chrono::duration<Rep, Period>& p_duration)
std::chrono::duration<Rep, Period> const& p_duration)
{
return p_os << p_duration.count() << " * (" << Period::num << "/"
<< Period::den << ")s";
}

template<typename T, size_t size>
inline std::ostream& operator<<(std::ostream& p_os,
const std::array<T, size>& p_array)
std::array<T, size> const& p_array)
{
p_os << "{";
for (const auto& element : p_array) {
for (auto const& element : p_array) {
p_os << element << ", ";
}
return p_os << "}\n";
}

template<typename T>
inline std::ostream& operator<<(std::ostream& p_os, const std::span<T>& p_array)
inline std::ostream& operator<<(std::ostream& p_os, std::span<T> const& p_array)
{
p_os << "{";
for (const auto& element : p_array) {
for (auto const& element : p_array) {
p_os << element << ", ";
}
return p_os << "}\n";
Expand Down
6 changes: 3 additions & 3 deletions tests/can.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ void can_mock_test()
constexpr hal::can::message_t expected_message{ .id = 1,
.payload = { 'a' },
.length = 1 };
const hal::callback<hal::can::handler> expected1 =
[&counter](const hal::can::message_t) { counter++; };
const hal::callback<hal::can::handler> expected2 =
hal::callback<hal::can::handler> const expected1 =
[&counter](hal::can::message_t const) { counter++; };
hal::callback<hal::can::handler> const expected2 =
[&counter](hal::can::message_t) { counter--; };
mock.spy_on_receive.trigger_error_on_call(3, error_callback(mock));

Expand Down
4 changes: 2 additions & 2 deletions tests/interrupt_pin.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void interrupt_pin_mock_test()
"hal::mock::interrupt_pin::on_trigger()"_test = []() {
// Setup
int counter = 0;
const hal::callback<void(bool)> expected_callback = [&counter](bool) {
hal::callback<void(bool)> const expected_callback = [&counter](bool) {
counter++;
};
hal::mock::interrupt_pin mock;
Expand All @@ -71,7 +71,7 @@ void interrupt_pin_mock_test()
"hal::mock::interrupt_pin::reset()"_test = []() {
// Setup
constexpr hal::interrupt_pin::settings mock_settings_default{};
const hal::callback<void(bool)> expected_callback = [](bool) {};
hal::callback<void(bool)> const expected_callback = [](bool) {};
hal::mock::interrupt_pin mock;
mock.configure(mock_settings_default);
expect(that % 1 == mock.spy_configure.call_history().size());
Expand Down
4 changes: 2 additions & 2 deletions tests/timer.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ void timer_mock_test()
// Setup
hal::mock::timer mock;
bool callback_stored_successfully = false;
const hal::callback<void(void)> expected_callback =
hal::callback<void(void)> const expected_callback =
[&callback_stored_successfully]() { callback_stored_successfully = true; };
const std::chrono::nanoseconds expected_delay = {};
std::chrono::nanoseconds const expected_delay = {};

// Exercise + Verify
expect(false == mock.is_running());
Expand Down

0 comments on commit 5aba7cc

Please sign in to comment.