FIX tests namespaces

This commit is contained in:
fastium 2024-12-27 11:13:22 +01:00 committed by Fastium
parent c0335b38a4
commit 31e1f22c59
7 changed files with 64 additions and 43 deletions

View File

@ -32,7 +32,8 @@
#include "unity/unity.h"
#include "utest/utest.h"
namespace utest::v1 {
namespace utest {
namespace v1 {
// test_bike_system handler function
static void test_bike_system() {
@ -139,9 +140,9 @@ static void test_bike_system_with_event() {
}
}
static utest::v1::status_t greentea_setup(const size_t number_of_cases) {
// Here, we specify the timeout (60s) and the host test (a built-in host test or the
// name of our Python file)
static status_t greentea_setup(const size_t number_of_cases) {
// Here, we specify the timeout (60s) and the host test (a built-in host test
// or the name of our Python file)
GREENTEA_SETUP(180, "default_auto");
return greentea_test_setup_handler(number_of_cases);
@ -156,5 +157,7 @@ static Case cases[] = {
static Specification specification(greentea_setup, cases);
int main() { return !Harness::run(specification); }
}; // namespace utest::v1
}; // namespace v1
}; // namespace utest
int main() { return !utest::v1::Harness::run(utest::v1::specification); }

View File

@ -29,7 +29,8 @@
#include "unity/unity.h"
#include "utest/utest.h"
namespace utest::v1 {
namespace utest {
namespace v1 {
// test_hdc1000 test handler function
static control_t test_sensor_device(const size_t call_count) {
@ -53,9 +54,9 @@ static control_t test_sensor_device(const size_t call_count) {
return CaseNext;
}
static utest::v1::status_t greentea_setup(const size_t number_of_cases) {
// Here, we specify the timeout (60s) and the host test (a built-in host test or the
// name of our Python file)
static status_t greentea_setup(const size_t number_of_cases) {
// Here, we specify the timeout (60s) and the host test (a built-in host test
// or the name of our Python file)
GREENTEA_SETUP(60, "default_auto");
return greentea_test_setup_handler(number_of_cases);
@ -65,6 +66,7 @@ static utest::v1::status_t greentea_setup(const size_t number_of_cases) {
static Case cases[] = {Case("test sensor device", test_sensor_device)};
static Specification specification(greentea_setup, cases);
}; // namespace v1
}; // namespace utest
int main() { return !Harness::run(specification); }
}; // namespace utest::v1
int main() { return !utest::v1::Harness::run(utest::v1::specification); }

View File

@ -31,13 +31,15 @@
#include "static_scheduling/gear_device.hpp"
#include "unity/unity.h"
#include "utest/utest.h"
namespace utest::v1 {
// allow for 0.1 km/h difference
static constexpr float kAllowedSpeedDelta = 0.1f;
// allow for 1m difference
static constexpr float kAllowedDistanceDelta = 1.0f / 1000.0;
namespace utest {
namespace v1 {
// function called by test handler functions for verifying the current speed
void check_current_speed(const std::chrono::milliseconds& pedalRotationTime,
uint8_t traySize,
@ -74,7 +76,8 @@ float compute_distance(const std::chrono::milliseconds& pedalRotationTime,
float trayGearRatio = static_cast<float>(traySize) / static_cast<float>(gearSize);
float distancePerPedalTurn = trayGearRatio * wheelCircumference;
// distancePerPedalTurn is expressed in m, divide per 1000 for a distance in km
// distancePerPedalTurn is expressed in m, divide per 1000 for a distance in
// km
return (distancePerPedalTurn * pedalRotations) / 1000.0;
}
@ -85,7 +88,8 @@ void check_distance(const std::chrono::milliseconds& pedalRotationTime,
float wheelCircumference,
const std::chrono::milliseconds& travelTime,
float distance) {
// distancePerPedalTurn is expressed in m, divide per 1000 for a distance in km
// distancePerPedalTurn is expressed in m, divide per 1000 for a distance in
// km
float expectedDistance = compute_distance(
pedalRotationTime, traySize, gearSize, wheelCircumference, travelTime);
printf(" Expected distance is %f, current distance is %f\n",
@ -333,9 +337,9 @@ static control_t test_reset(const size_t call_count) {
return CaseNext;
}
static utest::v1::status_t greentea_setup(const size_t number_of_cases) {
// Here, we specify the timeout (60s) and the host test (a built-in host test or the
// name of our Python file)
static status_t greentea_setup(const size_t number_of_cases) {
// Here, we specify the timeout (60s) and the host test (a built-in host test
// or the name of our Python file)
GREENTEA_SETUP(180, "default_auto");
return greentea_test_setup_handler(number_of_cases);
@ -349,6 +353,7 @@ static Case cases[] = {
Case("test speedometer reset", test_reset)};
static Specification specification(greentea_setup, cases);
}; // namespace v1
}; // namespace utest
int main() { return !Harness::run(specification); }
}; // namespace utest::v1
int main() { return !utest::v1::Harness::run(utest::v1::specification); }

View File

@ -27,7 +27,8 @@
#include "unity/unity.h"
#include "utest/utest.h"
namespace utest::v1 {
namespace utest {
namespace v1 {
// test handler function
static control_t always_succeed(const size_t call_count) {
@ -38,9 +39,9 @@ static control_t always_succeed(const size_t call_count) {
return CaseNext;
}
static utest::v1::status_t greentea_setup(const size_t number_of_cases) {
// Here, we specify the timeout (60s) and the host test (a built-in host test or the
// name of our Python file)
static status_t greentea_setup(const size_t number_of_cases) {
// Here, we specify the timeout (60s) and the host test (a built-in host test
// or the name of our Python file)
GREENTEA_SETUP(60, "default_auto");
return greentea_test_setup_handler(number_of_cases);
@ -51,5 +52,7 @@ static Case cases[] = {Case("always succeed test", always_succeed)};
static Specification specification(greentea_setup, cases);
int main() { return !Harness::run(specification); }
}; // namespace utest::v1
}; // namespace v1
}; // namespace utest
int main() { return !utest::v1::Harness::run(utest::v1::specification); }

View File

@ -29,7 +29,9 @@
#include "unity/unity.h" // NOLINT
#include "utest/utest.h" // NOLINT
namespace utest::v1 {
namespace utest {
namespace v1 {
struct Test {
Test() {
_instanceCount++;
@ -48,7 +50,8 @@ struct Test {
uint32_t Test::_instanceCount = 0;
/**
* Test that a shared pointer correctly manages the lifetime of the underlying raw pointer
* Test that a shared pointer correctly manages the lifetime of the underlying
* raw pointer
*/
void test_single_sharedptr_lifetime() {
// Sanity-check value of counter
@ -66,8 +69,8 @@ void test_single_sharedptr_lifetime() {
}
/**
* Test that multiple instances of shared pointers correctly manage the reference count
* to release the object at the correct point
* Test that multiple instances of shared pointers correctly manage the
* reference count to release the object at the correct point
*/
void test_instance_sharing() {
std::shared_ptr<Test> shared_ptr1(nullptr);
@ -228,7 +231,8 @@ void test_unique_ptr_swap() {
*******************/
/**
* Test that a shared pointer correctly manages the lifetime of the underlying raw pointer
* Test that a shared pointer correctly manages the lifetime of the underlying
* raw pointer
*/
void test_single_raw_ptr_lifetime() {
// Sanity-check value of counter
@ -258,9 +262,9 @@ void test_single_raw_ptr_lifetime() {
TEST_ASSERT_EQUAL(0, Test::_instanceCount);
}
static utest::v1::status_t greentea_setup(const size_t number_of_cases) {
// Here, we specify the timeout (60s) and the host test (a built-in host test or the
// name of our Python file)
static status_t greentea_setup(const size_t number_of_cases) {
// Here, we specify the timeout (60s) and the host test (a built-in host test
// or the name of our Python file)
GREENTEA_SETUP(60, "default_auto");
return greentea_test_setup_handler(number_of_cases);
}
@ -283,5 +287,7 @@ static Case cases[] = {
static Specification specification(greentea_setup, cases);
int main() { return !Harness::run(specification); }
}; // namespace utest::v1
}; // namespace v1
}; // namespace utest
int main() { return !utest::v1::Harness::run(utest::v1::specification); }

View File

@ -25,7 +25,6 @@ int main() {
static_scheduling_with_event::BikeSystem bikeSystem;
bikeSystem.start();
// hello
}
#endif // MBED_TEST_MODE

View File

@ -220,8 +220,9 @@ void BikeSystem::temperatureTask() {
// simulate task computation by waiting for the required task computation time
// std::chrono::microseconds elapsedTime = std::chrono::microseconds::zero();
// while (elapsedTime < kTemperatureTaskComputationTime) {
// std::chrono::microseconds elapsedTime =
// std::chrono::microseconds::zero(); while (elapsedTime <
// kTemperatureTaskComputationTime) {
// elapsedTime = _timer.elapsed_time() - taskStartTime;
// }
@ -255,8 +256,9 @@ void BikeSystem::displayTask1() {
// simulate task computation by waiting for the required task computation time
// std::chrono::microseconds elapsedTime = std::chrono::microseconds::zero();
// while (elapsedTime < kDisplayTask1ComputationTime) {
// std::chrono::microseconds elapsedTime =
// std::chrono::microseconds::zero(); while (elapsedTime <
// kDisplayTask1ComputationTime) {
// elapsedTime = _timer.elapsed_time() - taskStartTime;
// }
@ -274,8 +276,9 @@ void BikeSystem::displayTask2() {
// simulate task computation by waiting for the required task computation time
// std::chrono::microseconds elapsedTime = std::chrono::microseconds::zero();
// while (elapsedTime < kDisplayTask2ComputationTime) {
// std::chrono::microseconds elapsedTime =
// std::chrono::microseconds::zero(); while (elapsedTime <
// kDisplayTask2ComputationTime) {
// elapsedTime = _timer.elapsed_time() - taskStartTime;
// }
_taskLogger.logPeriodAndExecutionTime(