Skip to content

Commit f00c564

Browse files
author
Cruz Monrreal
authored
Merge pull request #7944 from AnttiKauppila/unittests
Cellular Unittests refactored to GoogleTest framework
2 parents c3128cd + 2b7a087 commit f00c564

File tree

156 files changed

+3092
-4634
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+3092
-4634
lines changed

UNITTESTS/CMakeLists.txt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,35 @@ endif(COVERAGE)
9090
set(unittest-includes-base
9191
"${PROJECT_SOURCE_DIR}/target_h"
9292
"${PROJECT_SOURCE_DIR}/target_h/events"
93+
"${PROJECT_SOURCE_DIR}/target_h/events/equeue"
94+
"${PROJECT_SOURCE_DIR}/target_h/platform"
9395
"${PROJECT_SOURCE_DIR}/stubs"
9496
"${PROJECT_SOURCE_DIR}/.."
9597
"${PROJECT_SOURCE_DIR}/../features"
98+
"${PROJECT_SOURCE_DIR}/../features/netsocket"
9699
"${PROJECT_SOURCE_DIR}/../platform"
97100
"${PROJECT_SOURCE_DIR}/../drivers"
98101
"${PROJECT_SOURCE_DIR}/../hal"
99102
"${PROJECT_SOURCE_DIR}/../events"
103+
"${PROJECT_SOURCE_DIR}/../events/equeue"
104+
"${PROJECT_SOURCE_DIR}/../rtos"
100105
"${PROJECT_SOURCE_DIR}/../rtos/TARGET_CORTEX"
101106
"${PROJECT_SOURCE_DIR}/../rtos/TARGET_CORTEX/rtx5/Include"
102107
"${PROJECT_SOURCE_DIR}/../cmsis"
103-
"${PROJECT_SOURCE_DIR}/../features/frameworks/nanostack-libservice/mbed-client-libservice/"
108+
"${PROJECT_SOURCE_DIR}/../features/frameworks"
109+
"${PROJECT_SOURCE_DIR}/../features/frameworks/mbed-trace"
110+
"${PROJECT_SOURCE_DIR}/../features/frameworks/nanostack-libservice"
111+
"${PROJECT_SOURCE_DIR}/../features/frameworks/nanostack-libservice/mbed-client-libservice"
112+
"${PROJECT_SOURCE_DIR}/../features/filesystem/fat"
113+
"${PROJECT_SOURCE_DIR}/../features/filesystem/fat/ChaN"
114+
"${PROJECT_SOURCE_DIR}/../features/filesystem/bd"
115+
"${PROJECT_SOURCE_DIR}/../features/filesystem/"
116+
"${PROJECT_SOURCE_DIR}/../features/filesystem/littlefs"
117+
"${PROJECT_SOURCE_DIR}/../features/filesystem/littlefs/littlefs"
118+
"${PROJECT_SOURCE_DIR}/../features/cellular/framework/API"
119+
"${PROJECT_SOURCE_DIR}/../features/cellular/framework/AT"
120+
"${PROJECT_SOURCE_DIR}/../features/cellular/framework"
121+
"${PROJECT_SOURCE_DIR}/../features/cellular/framework/common"
104122
)
105123

106124
# Create a list for test suites.
@@ -168,3 +186,4 @@ foreach(testfile ${unittest-file-list})
168186
message(WARNING "No test source files found for ${TEST_SUITE_NAME}.\n")
169187
endif(unittest-test-sources)
170188
endforeach(testfile)
189+

UNITTESTS/features/cellular/framework/AT/AT_CellularBase/at_cellularbasetest.cpp

Lines changed: 0 additions & 49 deletions
This file was deleted.

UNITTESTS/features/cellular/framework/AT/AT_CellularBase/test_at_cellularbase.cpp

Lines changed: 0 additions & 59 deletions
This file was deleted.

UNITTESTS/features/cellular/framework/AT/AT_CellularBase/test_at_cellularbase.h

Lines changed: 0 additions & 31 deletions
This file was deleted.

features/cellular/UNITTESTS/at/at_cellularbase/test_at_cellularbase.cpp renamed to UNITTESTS/features/cellular/framework/AT/at_cellularbase/at_cellularbasetest.cpp

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
#include "CppUTest/TestHarness.h"
18-
#include "test_at_cellularbase.h"
17+
18+
#include "gtest/gtest.h"
19+
#include "AT_CellularBase.h"
1920
#include "EventQueue.h"
2021
#include "AT_CellularBase.h"
2122
#include "ATHandler_stub.h"
@@ -57,26 +58,44 @@ class my_base : public AT_CellularBase {
5758
}
5859
};
5960

60-
Test_AT_CellularBase::Test_AT_CellularBase()
61-
{
61+
// AStyle ignored as the definition is not clear due to preprocessor usage
62+
// *INDENT-OFF*
63+
class TestAT_CellularBase : public testing::Test {
64+
protected:
6265

63-
}
66+
void SetUp()
67+
{
68+
}
69+
70+
void TearDown()
71+
{
72+
}
73+
};
74+
// *INDENT-ON*
6475

65-
Test_AT_CellularBase::~Test_AT_CellularBase()
76+
TEST_F(TestAT_CellularBase, Create)
6677
{
78+
EventQueue eq;
79+
FileHandle_stub fh;
80+
ATHandler ah(&fh, eq, 100, ",");
81+
AT_CellularBase *unit = new AT_CellularBase(ah);
82+
83+
EXPECT_TRUE(unit != NULL);
84+
85+
delete unit;
6786
}
6887

69-
void Test_AT_CellularBase::test_AT_CellularBase_get_at_handler()
88+
TEST_F(TestAT_CellularBase, test_AT_CellularBase_get_at_handler)
7089
{
7190
EventQueue eq;
7291
FileHandle_stub fh;
7392
ATHandler ah(&fh, eq, 100, ",");
7493
AT_CellularBase at(ah);
7594

76-
CHECK(&ah == &at.get_at_handler());
95+
EXPECT_TRUE(&ah == &at.get_at_handler());
7796
}
7897

79-
void Test_AT_CellularBase::test_AT_CellularBase_get_device_error()
98+
TEST_F(TestAT_CellularBase, test_AT_CellularBase_get_device_error)
8099
{
81100
EventQueue eq;
82101
FileHandle_stub fh;
@@ -85,12 +104,12 @@ void Test_AT_CellularBase::test_AT_CellularBase_get_device_error()
85104

86105
ATHandler_stub::device_err_value.errCode = 8;
87106

88-
CHECK_EQUAL(8, at.get_device_error().errCode);
107+
EXPECT_EQ(8, at.get_device_error().errCode);
89108

90109
ATHandler_stub::device_err_value.errCode = 0;
91110
}
92111

93-
void Test_AT_CellularBase::test_AT_CellularBase_set_unsupported_features()
112+
TEST_F(TestAT_CellularBase, test_AT_CellularBase_set_unsupported_features)
94113
{
95114
EventQueue eq;
96115
FileHandle_stub fh;
@@ -105,15 +124,14 @@ void Test_AT_CellularBase::test_AT_CellularBase_set_unsupported_features()
105124
at.set_unsupported_features(unsupported_features);
106125
}
107126

108-
void Test_AT_CellularBase::test_AT_CellularBase_is_supported()
127+
TEST_F(TestAT_CellularBase, test_AT_CellularBase_is_supported)
109128
{
110129
EventQueue eq;
111130
FileHandle_stub fh;
112131
ATHandler ah(&fh, eq, 0, ",");
113132
my_base my_at(ah);
114133

115-
CHECK(true == my_at.check_supported());
116-
CHECK(true == my_at.check_supported_not_found());
117-
CHECK(false == my_at.check_not_supported());
118-
134+
EXPECT_TRUE(true == my_at.check_supported());
135+
EXPECT_TRUE(true == my_at.check_supported_not_found());
136+
EXPECT_TRUE(false == my_at.check_not_supported());
119137
}

UNITTESTS/features/cellular/framework/AT/AT_CellularBase/unittest.cmake renamed to UNITTESTS/features/cellular/framework/AT/at_cellularbase/unittest.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ set(unittest-sources
2323

2424
# Test files
2525
set(unittest-test-sources
26+
features/cellular/framework/AT/at_cellularbase/at_cellularbasetest.cpp
2627
stubs/mbed_assert_stub.c
2728
stubs/ATHandler_stub.cpp
2829
stubs/EventQueue_stub.cpp
2930
stubs/FileHandle_stub.cpp
30-
features/cellular/framework/AT/AT_CellularBase/test_at_cellularbase.cpp
31-
features/cellular/framework/AT/AT_CellularBase/at_cellularbasetest.cpp
3231
)

0 commit comments

Comments
 (0)