1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

device tests: some of them can be run on host (#6912)

* device tests: mock scripts + rename some tests to enable mock-testing them

* move symbol
This commit is contained in:
david gauchard
2019-12-16 19:20:07 +01:00
committed by GitHub
parent d1237fd016
commit d40dbb4584
16 changed files with 41 additions and 6 deletions

View File

@ -0,0 +1,43 @@
#include <BSTest.h>
#include <StreamString.h>
BS_ENV_DECLARE();
void setup()
{
Serial.begin(115200);
BS_RUN(Serial);
}
bool pretest()
{
return true;
}
TEST_CASE("Print::printf works for any reasonable output length", "[Print]")
{
auto test_printf = [](size_t size) {
StreamString str;
auto buf = new char[size + 1];
for (size_t i = 0; i < size; ++i) {
buf[i] = 'a';
}
buf[size] = 0;
str.printf("%s%8d", buf, 56789102);
delete[] buf;
CHECK(str.length() == size + 8);
CHECK(str.substring(size) == "56789102");
};
auto before = ESP.getFreeHeap();
test_printf(1);
test_printf(10);
test_printf(100);
test_printf(1000);
test_printf(10000);
auto after = ESP.getFreeHeap();
CHECK(before == after);
}
void loop() {}