mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-17 09:01:30 +10:00
Refactor test utilities to use portable delay function and include necessary headers
This commit is contained in:
@@ -4,6 +4,13 @@
|
||||
|
||||
#include "TestUtil.h"
|
||||
|
||||
#if defined(ARDUINO)
|
||||
#include <Arduino.h>
|
||||
#else
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#endif
|
||||
|
||||
void initializeTestEnvironment()
|
||||
{
|
||||
concurrency::hasBeenSetup = true;
|
||||
@@ -15,4 +22,13 @@ void initializeTestEnvironment()
|
||||
perhapsSetRTC(RTCQualityNTP, &tv);
|
||||
#endif
|
||||
concurrency::OSThread::setup();
|
||||
}
|
||||
|
||||
void testDelay(unsigned long ms)
|
||||
{
|
||||
#if defined(ARDUINO)
|
||||
::delay(ms);
|
||||
#else
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
|
||||
#endif
|
||||
}
|
||||
+4
-1
@@ -1,4 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
// Initialize testing environment.
|
||||
void initializeTestEnvironment();
|
||||
void initializeTestEnvironment();
|
||||
|
||||
// Portable delay for tests (Arduino or host).
|
||||
void testDelay(unsigned long ms);
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <string.h>
|
||||
#include <unity.h>
|
||||
|
||||
#include "TestUtil.h"
|
||||
|
||||
/**
|
||||
* Get actual string length for nanopb char array fields.
|
||||
* Nanopb stores strings as fixed-size char arrays that may contain embedded nulls.
|
||||
@@ -202,8 +204,8 @@ void setup()
|
||||
{
|
||||
// NOTE!!! Wait for >2 secs
|
||||
// if board doesn't support software reset via Serial.DTR/RTS
|
||||
delay(10);
|
||||
delay(2000);
|
||||
testDelay(10);
|
||||
testDelay(2000);
|
||||
|
||||
UNITY_BEGIN();
|
||||
RUN_TEST(test_normal_string);
|
||||
|
||||
Reference in New Issue
Block a user