File tree Expand file tree Collapse file tree 4 files changed +33
-2
lines changed
Expand file tree Collapse file tree 4 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ set(TEST_SRCS
2828 src/Common/test_makeWord.cpp
2929 src/Common/test_max.cpp
3030 src/Common/test_min.cpp
31+ src/Print/test_getWriteError.cpp
3132 src/Print/test_print.cpp
3233 src/Ringbuffer/test_available.cpp
3334 src/Ringbuffer/test_availableForStore.cpp
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ class PrintMock : public Print
2222public:
2323 std::string _str;
2424 virtual size_t write (uint8_t b) override ;
25+ void mock_setWriteError () { setWriteError (); }
26+ void mock_setWriteError (int err) { setWriteError (err); }
2527};
2628
2729#endif /* PRINT_MOCK_H_ */
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2020 Arduino. All rights reserved.
3+ */
4+
5+ /* *************************************************************************************
6+ * INCLUDE
7+ **************************************************************************************/
8+
9+ #include < catch.hpp>
10+
11+ #include < Print.h>
12+
13+ #include < PrintMock.h>
14+
15+ /* *************************************************************************************
16+ * TEST CODE
17+ **************************************************************************************/
18+
19+ TEST_CASE (" No write error has been set" , " [Print-getWriteError-01]" )
20+ {
21+ PrintMock mock;
22+ REQUIRE (mock.getWriteError () == 0 );
23+ }
24+
25+ TEST_CASE (" A write error has been set" , " [Print-getWriteError-02]" )
26+ {
27+ PrintMock mock;
28+ mock.mock_setWriteError (5 );
29+ REQUIRE (mock.getWriteError () == 5 );
30+ }
Original file line number Diff line number Diff line change 88
99#include < catch.hpp>
1010
11- #include < string>
12-
1311#include < Print.h>
1412
1513#include < PrintMock.h>
You can’t perform that action at this time.
0 commit comments