File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
tests/device/test_iostream Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 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 () { }
You can’t perform that action at this time.
0 commit comments