1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-27 18:02:17 +03:00

Device side test library and test runner

This commit is contained in:
Ivan Grokhotkov
2016-03-10 09:12:11 +03:00
committed by Ivan Grokhotkov
parent 33723a9b52
commit ab7af89002
26 changed files with 1118 additions and 206 deletions

View File

@ -0,0 +1,38 @@
#include <BSTest.h>
#include <StreamString.h>
BS_ENV_DECLARE();
void setup()
{
Serial.begin(115200);
BS_RUN(Serial);
}
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 (int 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() {}