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

Commit4f5332d

Browse files
committed
Compiling 'Stream.cpp' for which it's necessary to provide a fake millis function
1 parent09541b3 commit4f5332d

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

‎test/CMakeLists.txt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ set(TEST_SRCS
4848
src/Ringbuffer/test_read_char.cpp
4949
src/Ringbuffer/test_store_char.cpp
5050
src/Stream/test_getTimeout.cpp
51+
src/Stream/test_setTimeout.cpp
5152
src/String/test_concat.cpp
5253
src/String/test_operators.cpp
5354
src/String/test_compareTo.cpp
@@ -80,6 +81,7 @@ set(TEST_DUT_SRCS
8081
../api/Common.cpp
8182
../api/IPAddress.cpp
8283
../api/String.cpp
84+
../api/Stream.cpp
8385
../api/Print.cpp
8486
)
8587

@@ -90,6 +92,7 @@ set(TEST_TARGET_SRCS
9092
src/dtostrf.cpp
9193
src/itoa.cpp
9294
src/PrintMock.cpp
95+
src/millis.cpp
9396
${TEST_SRCS}
9497
${TEST_DUT_SRCS}
9598
)

‎test/include/millis.h‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2020 Arduino. All rights reserved.
3+
*/
4+
5+
#ifndefMILLIS_H_
6+
#defineMILLIS_H_
7+
8+
/**************************************************************************************
9+
* INCLUDE
10+
**************************************************************************************/
11+
12+
#include<Common.h>
13+
14+
/**************************************************************************************
15+
* FUNCTION DECLARATION
16+
**************************************************************************************/
17+
18+
#ifdef__cplusplus
19+
extern"C" {
20+
#endif
21+
22+
voidset_millis(unsigned longconstval);
23+
24+
#ifdef__cplusplus
25+
}
26+
#endif
27+
28+
#endif/* MILLIS_H_ */
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2020 Arduino. All rights reserved.
3+
*/
4+
5+
/**************************************************************************************
6+
* INCLUDE
7+
**************************************************************************************/
8+
9+
#include<catch.hpp>
10+
11+
#include<StreamMock.h>
12+
13+
/**************************************************************************************
14+
* TEST CODE
15+
**************************************************************************************/
16+
17+
TEST_CASE ("Verifying if calling 'setTimeout' is indeed modifying the timeout","[Stream-setTimeout-01]")
18+
{
19+
StreamMock mock;
20+
21+
mock.setTimeout(100);
22+
23+
REQUIRE(mock.getTimeout() ==100);
24+
}

‎test/src/millis.cpp‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (c) 2020 Arduino. All rights reserved.
3+
*/
4+
5+
/**************************************************************************************
6+
* INCLUDE
7+
**************************************************************************************/
8+
9+
#include<millis.h>
10+
11+
/**************************************************************************************
12+
* GLOBAL VARIABLES
13+
**************************************************************************************/
14+
15+
staticunsignedlong millis_val =0;
16+
17+
/**************************************************************************************
18+
* FUNCTION DEFINITION
19+
**************************************************************************************/
20+
21+
voidset_millis(unsignedlongconst val)
22+
{
23+
millis_val = val;
24+
}
25+
26+
unsignedlongmillis()
27+
{
28+
return millis_val;
29+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp