Tactility/Tests/TactilityKernel/TimeAndDelay.cpp
Ken Van Hoeylandt d551e467b8
Moved and renamed files for consistent C code style (#463)
* **Documentation**
  * Added new C coding style guide detailing naming conventions for files, directories, macros, constants, variables, functions, and type definitions with illustrative examples.
  * Updated C++ coding style documentation with clarifications on C naming conventions and header directory organization patterns.

* **Refactor**
  * Updated header include paths throughout the codebase to use lowercase naming conventions consistently.
2026-01-27 20:17:33 +01:00

31 lines
948 B
C++

#include "doctest.h"
#include <tactility/delay.h>
#include <tactility/time.h>
TEST_CASE("delay ticks should be accurate within 1 tick") {
auto start_time = get_ticks();
delay_ticks(100);
auto end_time = get_ticks();
auto difference = end_time - start_time;
CHECK_EQ(difference >= 100, true);
CHECK_EQ(difference <= 101, true);
}
TEST_CASE("delay millis should be accurate within 1 tick") {
auto start_time = get_millis();
delay_millis(100);
auto end_time = get_millis();
auto difference = end_time - start_time;
CHECK_EQ(difference >= 100, true);
CHECK_EQ(difference <= 101, true);
}
TEST_CASE("microsecond time should be accurate within 1 tick") {
auto start_time = get_micros_since_boot();
delay_millis(100);
auto end_time = get_micros_since_boot();
auto difference = (end_time - start_time) / 1000;
CHECK_EQ(difference >= 99, true);
CHECK_EQ(difference <= 101, true);
}