Skip to content

Commit 9938420

Browse files
committed
Merge branch 'fakeit_integration'
2 parents 638e630 + 7c96cc4 commit 9938420

File tree

8 files changed

+35
-15
lines changed

8 files changed

+35
-15
lines changed

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
cmake_minimum_required(VERSION 3.2.2)
22
project(ArduinoFake VERSION 0.1)
33

4-
set(CMAKE_CXX_STANDARD 11)
4+
set(CMAKE_CXX_STANDARD 17)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
66

77
LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
88

99
# Include external libs
10-
add_subdirectory(external)
10+
add_subdirectory(external/fakeit)
11+
add_subdirectory(external/unity)
1112

1213
# Targets that we develop here
1314
enable_testing()

external/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Include external libs
22
add_subdirectory(unity)
3+
add_subdirectory(fakeit)

external/fakeit/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
cmake_minimum_required(VERSION 3.2.2)
2+
project(fakeit VERSION 2.4.0 LANGUAGES CXX)
3+
4+
include(git-download)
5+
6+
set(REPO_DIR ${PROJECT_SOURCE_DIR}/${PROJECT_NAME}-repo)
7+
8+
download_repo(
9+
URL "https://github.com/eranpeer/FakeIt.git"
10+
TAG ${PROJECT_VERSION}
11+
CLONE_DIR ${REPO_DIR}
12+
)
13+
14+
add_library(${PROJECT_NAME} INTERFACE)
15+
16+
target_include_directories(${PROJECT_NAME} INTERFACE
17+
${REPO_DIR}/single_header/standalone/
18+
)

platformio.ini

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,5 @@
1010

1111
[env:native]
1212
platform = native
13-
build_flags = -std=gnu++11
14-
-I .pio/libdeps/native/FakeIt/single_header/standalone
13+
build_flags = -std=gnu++17
1514
test_build_src = yes
16-
lib_deps =
17-
https://github.com/eranpeer/FakeIt.git
18-
throwtheswitch/Unity@^2.5.2

src/ArduinoFake.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <cstring>
99
#include <cstdint>
1010
#include <stdexcept>
11-
#include "fakeit.hpp"
11+
#include <fakeit.hpp>
1212

1313
#include "arduino/Arduino.h"
1414

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ aux_source_directory(./fakeit SRC_LIST)
33
aux_source_directory(./arduino SRC_LIST)
44

55
add_library(${PROJECT_NAME} SHARED ${SRC_LIST})
6+
7+
target_link_libraries(${PROJECT_NAME} fakeit)

src/FunctionFake.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include "fakeit.hpp"
3+
#include <fakeit.hpp>
44

55
struct FunctionFake
66
{

test/test_client.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const char * host = "localhost";
44

55
namespace ClientTest
66
{
7+
const char * localhost = "localhost";
8+
79
class MyService
810
{
911
public:
@@ -32,7 +34,7 @@ namespace ClientTest
3234
Client* client = ArduinoFakeMock(Client);
3335

3436
TEST_ASSERT_EQUAL(0, client->connected());
35-
TEST_ASSERT_EQUAL(1, client->connect(host, 8080));
37+
TEST_ASSERT_EQUAL(1, client->connect(localhost, 8080));
3638
TEST_ASSERT_EQUAL(1, client->connected());
3739
TEST_ASSERT_EQUAL(2, client->peek());
3840

@@ -43,7 +45,7 @@ namespace ClientTest
4345
Verify(Method(ArduinoFake(Client), peek)).Once();
4446
Verify(Method(ArduinoFake(Client), flush)).Once();
4547
Verify(Method(ArduinoFake(Client), connected)).Exactly(2_Times);
46-
Verify(OverloadedMethod(ArduinoFake(Client), connect, int(const char*, uint16_t)).Using(host, 8080)).Once();
48+
Verify(OverloadedMethod(ArduinoFake(Client), connect, int(const char*, uint16_t)).Using(localhost, 8080)).Once();
4749
}
4850

4951
void test_connect(void)
@@ -56,14 +58,14 @@ namespace ClientTest
5658

5759
Client* client = ArduinoFakeMock(Client);
5860

59-
TEST_ASSERT_EQUAL(1, client->connect(host, 8080));
60-
TEST_ASSERT_EQUAL(0, client->connect(host, 80));
61+
TEST_ASSERT_EQUAL(1, client->connect(localhost, 8080));
62+
TEST_ASSERT_EQUAL(0, client->connect(localhost, 80));
6163

6264
TEST_ASSERT_EQUAL(0, client->connect(ipAddress1, 8080));
6365
TEST_ASSERT_EQUAL(1, client->connect(ipAddress2, 8080));
6466

65-
Verify(OverloadedMethod(ArduinoFake(Client), connect, int(const char*, uint16_t)).Using(host, 8080)).Once();
66-
Verify(OverloadedMethod(ArduinoFake(Client), connect, int(const char*, uint16_t)).Using(host, 80)).Once();
67+
Verify(OverloadedMethod(ArduinoFake(Client), connect, int(const char*, uint16_t)).Using(localhost, 8080)).Once();
68+
Verify(OverloadedMethod(ArduinoFake(Client), connect, int(const char*, uint16_t)).Using(localhost, 80)).Once();
6769

6870
Verify(OverloadedMethod(ArduinoFake(Client), connect, int(IPAddress, uint16_t)).Using(ipAddress1, 8080)).Once();
6971
Verify(OverloadedMethod(ArduinoFake(Client), connect, int(IPAddress, uint16_t)).Using(ipAddress2, 8080)).Once();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy