File tree Expand file tree Collapse file tree 6 files changed +176
-152
lines changed Expand file tree Collapse file tree 6 files changed +176
-152
lines changed Original file line number Diff line number Diff line change 1
1
build /
2
- Testing /
3
2
.dep /
4
3
* .o
5
4
* .hex
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ This file is part of AYAB.
29
29
#ifndef HARD_I2C
30
30
#define HARD_I2C
31
31
#endif
32
- #include " ./libraries/ Alt_MCP23008/Alt_MCP23008.h "
32
+ #include < Alt_MCP23008.h >
33
33
#include < Wire.h>
34
34
35
35
Alt_MCP23008 mcp_0;
Original file line number Diff line number Diff line change 1
- cmake_minimum_required (VERSION 2.8.8 )
1
+ cmake_minimum_required (VERSION 3.1 )
2
2
project (ayab_test)
3
3
4
4
set (CMAKE_CXX_STANDARD 11 CACHE STRING "Set the C++ standard to be used for compiling" )
5
5
6
- message ("building all tests" )
7
-
8
6
find_package (Threads REQUIRED)
9
7
10
8
add_subdirectory (arduino_mock)
@@ -21,6 +19,9 @@ add_executable(${PROJECT_NAME}
21
19
22
20
${PROJECT_SOURCE_DIR} /../encoders.cpp
23
21
${PROJECT_SOURCE_DIR} /./test_encoders.cpp
22
+
23
+ ${PROJECT_SOURCE_DIR} /../beeper.cpp
24
+ ${PROJECT_SOURCE_DIR} /./test_beeper.cpp
24
25
)
25
26
26
27
target_compile_definitions (${PROJECT_NAME}
@@ -45,11 +46,5 @@ target_link_libraries(${PROJECT_NAME}
45
46
46
47
add_dependencies (${PROJECT_NAME} arduino_mock)
47
48
48
- # add_custom_command(TARGET ${PROJECT_NAME}
49
- # POST_BUILD
50
- # COMMAND gcovr -r . -e test_* -e arduino_mock*
51
- # COMMAND gcovr -r . --branches -e test_* -e arduino_mock*
52
- # )
53
-
54
49
enable_testing ()
55
50
add_test (test_all ${PROJECT_NAME} )
Original file line number Diff line number Diff line change 4
4
5
5
#include " gtest/gtest.h"
6
6
7
- int main (int argc, char *argv[])
8
- {
9
- ::testing::InitGoogleTest (&argc, argv);
10
- return RUN_ALL_TESTS ();
7
+ int main (int argc, char *argv[]) {
8
+ ::testing::InitGoogleTest (&argc, argv);
9
+ return RUN_ALL_TESTS ();
11
10
}
Original file line number Diff line number Diff line change
1
+ #include " gtest/gtest.h"
2
+
3
+ #include " ../beeper.h"
4
+
5
+ using ::testing::Return;
6
+
7
+ class BeeperTest : public ::testing::Test {
8
+ protected:
9
+ void SetUp () override {
10
+ arduinoMock = arduinoMockInstance ();
11
+ b = Beeper ();
12
+ }
13
+
14
+ void TearDown () override {
15
+ releaseArduinoMock ();
16
+ }
17
+
18
+ void checkBeepTime (byte length) {
19
+ EXPECT_CALL (*arduinoMock, analogWrite (PIEZO_PIN, 0 )).Times (length);
20
+ EXPECT_CALL (*arduinoMock, analogWrite (PIEZO_PIN, 20 )).Times (length);
21
+ EXPECT_CALL (*arduinoMock, delay (BEEPDELAY)).Times (length * 2 );
22
+ EXPECT_CALL (*arduinoMock, analogWrite (PIEZO_PIN, 255 )).Times (1 );
23
+ }
24
+
25
+ ArduinoMock *arduinoMock;
26
+ Beeper b;
27
+ };
28
+
29
+ TEST_F (BeeperTest, test_ready) {
30
+ checkBeepTime (5 );
31
+ b.ready ();
32
+ }
33
+
34
+ TEST_F (BeeperTest, test_finishedLine) {
35
+ checkBeepTime (3 );
36
+ b.finishedLine ();
37
+ }
38
+
39
+ TEST_F (BeeperTest, test_endWork) {
40
+ checkBeepTime (10 );
41
+ b.endWork ();
42
+ }
You can’t perform that action at this time.
0 commit comments