Skip to content

Commit 6e906b2

Browse files
committed
tests: add test for output to std::cout
1 parent 074dff7 commit 6e906b2

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <ESP8266WiFi.h>
2+
#include <BSTest.h>
3+
#include <sstream>
4+
#include <iostream>
5+
6+
BS_ENV_DECLARE();
7+
8+
void setup()
9+
{
10+
Serial.begin(115200);
11+
BS_RUN(Serial);
12+
}
13+
14+
TEST_CASE("can print to std::cout", "[iostream]")
15+
{
16+
std::stringstream test_stream("");
17+
test_stream << "hello stream";
18+
19+
// empty the RX buffer, just in case
20+
Serial.readString();
21+
22+
USC0(0) |= (1 << UCLBE); // enable loopback
23+
std::cout << test_stream.str().c_str() << std::endl;
24+
delay(100);
25+
USC0(0) &= ~(1 << UCLBE); // disable loopback
26+
27+
String result = Serial.readStringUntil('\n');
28+
29+
Serial.printf("result: '%s'\n", result.c_str());
30+
31+
CHECK(result == test_stream.str().c_str());
32+
}
33+
34+
void loop() { }

0 commit comments

Comments
 (0)