Skip to content

Commit

Permalink
♻️ Refactor tests (#47)
Browse files Browse the repository at this point in the history
* :recylce: Refactor tests

* add missing ;

* update names of tests
  • Loading branch information
MaliaLabor authored Dec 3, 2024
1 parent 7022195 commit 2664fd6
Show file tree
Hide file tree
Showing 21 changed files with 25 additions and 97 deletions.
3 changes: 1 addition & 2 deletions tests/as_bytes.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
#include <boost/ut.hpp>

namespace hal {
void as_bytes_test()
{
boost::ut::suite<"as_bytes_test"> as_bytes_test = [] {
using namespace boost::ut;

"hal::as_bytes()"_test = []() {
Expand Down
3 changes: 1 addition & 2 deletions tests/bit.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
#include <boost/ut.hpp>

namespace hal {
void bit_test()
{
boost::ut::suite<"bit_test"> bit_test = [] {
using namespace boost::ut;

"hal::bit_modify<template> compile time masks APIs"_test = []() {
Expand Down
5 changes: 2 additions & 3 deletions tests/can.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ void check_validity(hal::hertz p_operating_frequency,
} // namespace

namespace hal {
void can_test()
{
boost::ut::suite<"can_test"> can_test = [] {
using namespace boost::ut;

"operator==(can::message, can::message) "_test = []() {
Expand Down Expand Up @@ -157,5 +156,5 @@ void can_test()
expect(that % not fail2.has_value());
expect(that % not fail4.has_value());
};
}
};
} // namespace hal
3 changes: 1 addition & 2 deletions tests/enum.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
#include <boost/ut.hpp>

namespace hal {
void enum_test()
{
boost::ut::suite<"enum_test"> enum_test = [] {
using namespace boost::ut;

"hal::value(enum)"_test = []() {
Expand Down
3 changes: 1 addition & 2 deletions tests/i2c.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
#include <boost/ut.hpp>

namespace hal {
void i2c_util_test()
{
boost::ut::suite<"i2c_test"> i2c_test = [] {
using namespace boost::ut;

static constexpr hal::byte successful_address{ 0x15 };
Expand Down
3 changes: 1 addition & 2 deletions tests/input_pin.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
#include <boost/ut.hpp>

namespace hal {
void input_pin_util_test()
{
boost::ut::suite<"input_pin_test"> input_pin_test = [] {
using namespace boost::ut;
"operator==(input_pin::settings)"_test = []() {
input_pin::settings a{};
Expand Down
3 changes: 1 addition & 2 deletions tests/interrupt_pin.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
#include <boost/ut.hpp>

namespace hal {
void interrupt_pin_util_test()
{
boost::ut::suite<"interrupt_pin_test"> interrupt_pin_test = [] {
using namespace boost::ut;
"operator==(interrupt_pin::settings)"_test = []() {
interrupt_pin::settings a{};
Expand Down
48 changes: 0 additions & 48 deletions tests/main.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,56 +14,8 @@

namespace hal {
// TODO(#45): Replace these with boost.ut named global test suites
extern void as_bytes_test();
extern void bit_test();
extern void can_test();
extern void enum_test();
extern void i2c_util_test();
extern void input_pin_util_test();
extern void interrupt_pin_util_test();
extern void map_test();
extern void math_test();
extern void move_interceptor_test();
extern void output_pin_util_test();
extern void overflow_counter_test();
extern void serial_util_test();
extern void spi_util_test();
extern void static_callable_test();
extern void static_list_test();
extern void steady_clock_utility_test();
extern void timeout_test();
extern void units_test();
extern void stream_terminated_test();
extern void parse_stream_test();
extern void find_stream_test();
extern void fill_upto_stream_test();
extern void multi_stream_test();
} // namespace hal

int main()
{
hal::as_bytes_test();
hal::bit_test();
hal::can_test();
hal::enum_test();
hal::i2c_util_test();
hal::input_pin_util_test();
hal::interrupt_pin_util_test();
hal::map_test();
hal::math_test();
hal::move_interceptor_test();
hal::output_pin_util_test();
hal::overflow_counter_test();
hal::serial_util_test();
hal::spi_util_test();
hal::static_callable_test();
hal::static_list_test();
hal::steady_clock_utility_test();
hal::timeout_test();
hal::units_test();
hal::stream_terminated_test();
hal::parse_stream_test();
hal::find_stream_test();
hal::fill_upto_stream_test();
hal::multi_stream_test();
}
3 changes: 1 addition & 2 deletions tests/map.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
#include <boost/ut.hpp>

namespace hal {
void map_test()
{
boost::ut::suite<"map_test"> map_test = [] {
using namespace boost::ut;

"hal::map<std::floating_point>()"_test = []() {
Expand Down
3 changes: 1 addition & 2 deletions tests/math.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
#include <boost/ut.hpp>

namespace hal {
void math_test()
{
boost::ut::suite<"math_test"> math_test = [] {
using namespace boost::ut;

"hal::multiply()"_test = []() {
Expand Down
3 changes: 1 addition & 2 deletions tests/move_interceptor.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
#include <boost/ut.hpp>

namespace hal {
void move_interceptor_test()
{
boost::ut::suite<"move_interceptor_test"> move_interceptor_test = [] {
using namespace boost::ut;

"move_interceptor<mock>::intercept"_test = []() {
Expand Down
3 changes: 1 addition & 2 deletions tests/output_pin.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
#include <boost/ut.hpp>

namespace hal {
void output_pin_util_test()
{
boost::ut::suite<"output_pin_test"> output_pin_test = [] {
using namespace boost::ut;
"operator==(output_pin::settings)"_test = []() {
output_pin::settings a{};
Expand Down
3 changes: 1 addition & 2 deletions tests/overflow_counter.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
#include <boost/ut.hpp>

namespace hal {
void overflow_counter_test()
{
boost::ut::suite<"overflow_counter_test"> overflow_counter_test = [] {
using namespace boost::ut;

"overflow_counter::update() increment by 1"_test = []() {
Expand Down
3 changes: 1 addition & 2 deletions tests/serial.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
#include <boost/ut.hpp>

namespace hal {
void serial_util_test()
{
boost::ut::suite<"serial_test"> serial_test = [] {
using namespace boost::ut;

static constexpr hal::byte write_failure_byte{ 'C' };
Expand Down
3 changes: 1 addition & 2 deletions tests/spi.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#include <boost/ut.hpp>

namespace hal {
void spi_util_test()
{
boost::ut::suite<"spi_test"> spi_test = [] {
using namespace boost::ut;

static constexpr hal::byte success_filler{ 0xF5 };
Expand Down
3 changes: 1 addition & 2 deletions tests/static_callable.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
#include <boost/ut.hpp>

namespace hal {
void static_callable_test()
{
boost::ut::suite<"static_callable_test"> static_callable_test = [] {
using namespace boost::ut;

// Setup
Expand Down
3 changes: 1 addition & 2 deletions tests/static_list.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
#include <boost/ut.hpp>

namespace hal {
void static_list_test()
{
boost::ut::suite<"static_list_test"> static_list_test = [] {
using namespace boost::ut;

"static_list::ctor()"_test = []() {
Expand Down
3 changes: 1 addition & 2 deletions tests/steady_clock.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
// #include <libhal/testing.hpp>

namespace hal {
void steady_clock_utility_test()
{
boost::ut::suite<"steady_clock_test"> steady_clock_test = [] {
using namespace boost::ut;

// Make the frequency equal to inverse of the time duration period, giving you
Expand Down
15 changes: 5 additions & 10 deletions tests/streams.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ std::span<hal::byte const> operator|(
}
} // namespace

void stream_terminated_test()
{
boost::ut::suite<"stream_terminated_test"> stream_terminated_test = [] {
using namespace boost::ut;
using namespace std::literals;

Expand Down Expand Up @@ -97,8 +96,7 @@ void stream_terminated_test()
// | parse<T> Stream |
//
// =============================================================================
void parse_stream_test()
{
boost::ut::suite<"parse_stream_test"> parse_stream_test = [] {
using namespace boost::ut;
using namespace std::literals;

Expand Down Expand Up @@ -264,8 +262,7 @@ void parse_stream_test()
// | Find Stream |
//
// =============================================================================
void find_stream_test()
{
boost::ut::suite<"find_stream_test"> find_stream_test = [] {
// Setup
using namespace boost::ut;
using namespace std::literals;
Expand Down Expand Up @@ -375,8 +372,7 @@ void find_stream_test()
// | fill_upto Stream |
//
// =============================================================================
void fill_upto_stream_test()
{
boost::ut::suite<"fill_upto_stream_test"> fill_upto_stream_test = [] {
// Setup
using namespace boost::ut;
using namespace std::literals;
Expand Down Expand Up @@ -448,8 +444,7 @@ void fill_upto_stream_test()
// | Multi Stream Test |
//
// =============================================================================
void multi_stream_test()
{
boost::ut::suite<"multi_stream_test"> multi_stream_test = [] {
using namespace boost::ut;
using namespace std::literals;

Expand Down
3 changes: 1 addition & 2 deletions tests/timeout.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#include <boost/ut.hpp>

namespace hal {
void timeout_test()
{
boost::ut::suite<"timeout_test"> timeout_test = [] {
using namespace boost::ut;
"hal::try_until(callback, timeout)"_test = []() {
// Setup
Expand Down
3 changes: 1 addition & 2 deletions tests/units.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ std::ostream& operator<<(std::ostream& p_os,

namespace hal {

void units_test()
{
boost::ut::suite<"units_test"> units_test = [] {
using namespace boost::ut;
using namespace std::literals;

Expand Down

0 comments on commit 2664fd6

Please sign in to comment.