Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit23ef4ce

Browse files
committed
Adding test code for print(Printable)
1 parent4bcdd13 commit23ef4ce

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

‎test/include/PrintableMock.h‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2020 Arduino. All rights reserved.
3+
*/
4+
5+
#ifndef PRINTABLE_MOCK_H_
6+
#definePRINTABLE_MOCK_H_
7+
8+
/**************************************************************************************
9+
* INCLUDE
10+
**************************************************************************************/
11+
12+
#include<string>
13+
14+
#include<Printable.h>
15+
16+
/**************************************************************************************
17+
* CLASS DECLARATION
18+
**************************************************************************************/
19+
20+
classPrintableMock :publicarduino::Printable
21+
{
22+
public:
23+
int _i;
24+
virtualsize_tprintTo(arduino::Print& p)constoverride
25+
{
26+
size_t written =0;
27+
written += p.print("PrintableMock i =");
28+
written += p.print(_i);
29+
return written;
30+
}
31+
};
32+
33+
#endif/* PRINTABLE_MOCK_H_*/

‎test/src/Print/test_print.cpp‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include<Print.h>
1212

1313
#include<PrintMock.h>
14+
#include<PrintableMock.h>
1415

1516
/**************************************************************************************
1617
* TEST CODE
@@ -126,3 +127,15 @@ TEST_CASE ("Print::print(double, int = 2)", "[Print-print-07]")
126127
WHEN ("val is NAN") { mock.print(NAN);REQUIRE(mock._str =="nan"); }
127128
WHEN ("val is INFINITY") { mock.print(INFINITY);REQUIRE(mock._str =="inf"); }
128129
}
130+
131+
TEST_CASE ("Print::print(Printable)","[Print-print-08]")
132+
{
133+
PrintMock mock;
134+
135+
PrintableMock printable;
136+
printable._i =1;
137+
138+
mock.print(printable);
139+
140+
REQUIRE(mock._str =="PrintableMock i = 1");
141+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp