Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: LedController mbed-rtos mbed NerfUSXbee Servomotor TargetManager
Fork of NerfUS by
TESTS/TargetTest.cpp@18:353fb432c03c, 2017-03-08 (annotated)
- Committer:
- Maxime Dupuis
- Date:
- Wed Mar 08 12:24:17 2017 -0500
- Revision:
- 18:353fb432c03c
- Child:
- 19:377887760869
Implement 1st draft of Target execute_command
Raise servomotor and turn on LED if necessary
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Maxime Dupuis |
18:353fb432c03c | 1 | #include "gmock/gmock.h" |
| Maxime Dupuis |
18:353fb432c03c | 2 | #include "gtest/gtest.h" |
| Maxime Dupuis |
18:353fb432c03c | 3 | |
| Maxime Dupuis |
18:353fb432c03c | 4 | #include "Target.hpp" |
| Maxime Dupuis |
18:353fb432c03c | 5 | #include "MockServomotor.hpp" |
| Maxime Dupuis |
18:353fb432c03c | 6 | #include "MockLedController.hpp" |
| Maxime Dupuis |
18:353fb432c03c | 7 | |
| Maxime Dupuis |
18:353fb432c03c | 8 | class TargetTest : public ::testing::Test |
| Maxime Dupuis |
18:353fb432c03c | 9 | { |
| Maxime Dupuis |
18:353fb432c03c | 10 | public: |
| Maxime Dupuis |
18:353fb432c03c | 11 | TargetTest() : |
| Maxime Dupuis |
18:353fb432c03c | 12 | target(mock_servomotor, mock_led_controller) |
| Maxime Dupuis |
18:353fb432c03c | 13 | { |
| Maxime Dupuis |
18:353fb432c03c | 14 | } |
| Maxime Dupuis |
18:353fb432c03c | 15 | |
| Maxime Dupuis |
18:353fb432c03c | 16 | MockServomotor mock_servomotor; |
| Maxime Dupuis |
18:353fb432c03c | 17 | MockLedController mock_led_controller; |
| Maxime Dupuis |
18:353fb432c03c | 18 | Target target; |
| Maxime Dupuis |
18:353fb432c03c | 19 | }; |
| Maxime Dupuis |
18:353fb432c03c | 20 | |
| Maxime Dupuis |
18:353fb432c03c | 21 | TEST_F(TargetTest, AllyCommandRaisesTarget) |
| Maxime Dupuis |
18:353fb432c03c | 22 | { |
| Maxime Dupuis |
18:353fb432c03c | 23 | EXPECT_CALL(mock_servomotor, set_position_up()) |
| Maxime Dupuis |
18:353fb432c03c | 24 | .Times(1); |
| Maxime Dupuis |
18:353fb432c03c | 25 | |
| Maxime Dupuis |
18:353fb432c03c | 26 | target.ally_command(); |
| Maxime Dupuis |
18:353fb432c03c | 27 | } |
| Maxime Dupuis |
18:353fb432c03c | 28 | |
| Maxime Dupuis |
18:353fb432c03c | 29 | TEST_F(TargetTest, EnemyCommandRaisesTargetAndTurnsOnLED) |
| Maxime Dupuis |
18:353fb432c03c | 30 | { |
| Maxime Dupuis |
18:353fb432c03c | 31 | EXPECT_CALL(mock_servomotor, set_position_up()) |
| Maxime Dupuis |
18:353fb432c03c | 32 | .Times(1); |
| Maxime Dupuis |
18:353fb432c03c | 33 | EXPECT_CALL(mock_led_controller, turn_on()) |
| Maxime Dupuis |
18:353fb432c03c | 34 | .Times(1); |
| Maxime Dupuis |
18:353fb432c03c | 35 | |
| Maxime Dupuis |
18:353fb432c03c | 36 | target.enemy_command(); |
| Maxime Dupuis |
18:353fb432c03c | 37 | } |
| Maxime Dupuis |
18:353fb432c03c | 38 |
