Skip to content

Cellular Unittests refactored to GoogleTest framework #7944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion UNITTESTS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,35 @@ endif(COVERAGE)
set(unittest-includes-base
"${PROJECT_SOURCE_DIR}/target_h"
"${PROJECT_SOURCE_DIR}/target_h/events"
"${PROJECT_SOURCE_DIR}/target_h/events/equeue"
"${PROJECT_SOURCE_DIR}/target_h/platform"
"${PROJECT_SOURCE_DIR}/stubs"
"${PROJECT_SOURCE_DIR}/.."
"${PROJECT_SOURCE_DIR}/../features"
"${PROJECT_SOURCE_DIR}/../features/netsocket"
"${PROJECT_SOURCE_DIR}/../platform"
"${PROJECT_SOURCE_DIR}/../drivers"
"${PROJECT_SOURCE_DIR}/../hal"
"${PROJECT_SOURCE_DIR}/../events"
"${PROJECT_SOURCE_DIR}/../events/equeue"
"${PROJECT_SOURCE_DIR}/../rtos"
"${PROJECT_SOURCE_DIR}/../rtos/TARGET_CORTEX"
"${PROJECT_SOURCE_DIR}/../rtos/TARGET_CORTEX/rtx5/Include"
"${PROJECT_SOURCE_DIR}/../cmsis"
"${PROJECT_SOURCE_DIR}/../features/frameworks/nanostack-libservice/mbed-client-libservice/"
"${PROJECT_SOURCE_DIR}/../features/frameworks"
"${PROJECT_SOURCE_DIR}/../features/frameworks/mbed-trace"
"${PROJECT_SOURCE_DIR}/../features/frameworks/nanostack-libservice"
"${PROJECT_SOURCE_DIR}/../features/frameworks/nanostack-libservice/mbed-client-libservice"
"${PROJECT_SOURCE_DIR}/../features/filesystem/fat"
"${PROJECT_SOURCE_DIR}/../features/filesystem/fat/ChaN"
"${PROJECT_SOURCE_DIR}/../features/filesystem/bd"
"${PROJECT_SOURCE_DIR}/../features/filesystem/"
"${PROJECT_SOURCE_DIR}/../features/filesystem/littlefs"
"${PROJECT_SOURCE_DIR}/../features/filesystem/littlefs/littlefs"
"${PROJECT_SOURCE_DIR}/../features/cellular/framework/API"
"${PROJECT_SOURCE_DIR}/../features/cellular/framework/AT"
"${PROJECT_SOURCE_DIR}/../features/cellular/framework"
"${PROJECT_SOURCE_DIR}/../features/cellular/framework/common"
)

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

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "CppUTest/TestHarness.h"
#include "test_at_cellularbase.h"

#include "gtest/gtest.h"
#include "AT_CellularBase.h"
#include "EventQueue.h"
#include "AT_CellularBase.h"
#include "ATHandler_stub.h"
Expand Down Expand Up @@ -57,26 +58,44 @@ class my_base : public AT_CellularBase {
}
};

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

}
void SetUp()
{
}

void TearDown()
{
}
};
// *INDENT-ON*

Test_AT_CellularBase::~Test_AT_CellularBase()
TEST_F(TestAT_CellularBase, Create)
{
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 100, ",");
AT_CellularBase *unit = new AT_CellularBase(ah);

EXPECT_TRUE(unit != NULL);

delete unit;
}

void Test_AT_CellularBase::test_AT_CellularBase_get_at_handler()
TEST_F(TestAT_CellularBase, test_AT_CellularBase_get_at_handler)
{
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 100, ",");
AT_CellularBase at(ah);

CHECK(&ah == &at.get_at_handler());
EXPECT_TRUE(&ah == &at.get_at_handler());
}

void Test_AT_CellularBase::test_AT_CellularBase_get_device_error()
TEST_F(TestAT_CellularBase, test_AT_CellularBase_get_device_error)
{
EventQueue eq;
FileHandle_stub fh;
Expand All @@ -85,12 +104,12 @@ void Test_AT_CellularBase::test_AT_CellularBase_get_device_error()

ATHandler_stub::device_err_value.errCode = 8;

CHECK_EQUAL(8, at.get_device_error().errCode);
EXPECT_EQ(8, at.get_device_error().errCode);

ATHandler_stub::device_err_value.errCode = 0;
}

void Test_AT_CellularBase::test_AT_CellularBase_set_unsupported_features()
TEST_F(TestAT_CellularBase, test_AT_CellularBase_set_unsupported_features)
{
EventQueue eq;
FileHandle_stub fh;
Expand All @@ -105,15 +124,14 @@ void Test_AT_CellularBase::test_AT_CellularBase_set_unsupported_features()
at.set_unsupported_features(unsupported_features);
}

void Test_AT_CellularBase::test_AT_CellularBase_is_supported()
TEST_F(TestAT_CellularBase, test_AT_CellularBase_is_supported)
{
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 0, ",");
my_base my_at(ah);

CHECK(true == my_at.check_supported());
CHECK(true == my_at.check_supported_not_found());
CHECK(false == my_at.check_not_supported());

EXPECT_TRUE(true == my_at.check_supported());
EXPECT_TRUE(true == my_at.check_supported_not_found());
EXPECT_TRUE(false == my_at.check_not_supported());
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ set(unittest-sources

# Test files
set(unittest-test-sources
features/cellular/framework/AT/at_cellularbase/at_cellularbasetest.cpp
stubs/mbed_assert_stub.c
stubs/ATHandler_stub.cpp
stubs/EventQueue_stub.cpp
stubs/FileHandle_stub.cpp
features/cellular/framework/AT/AT_CellularBase/test_at_cellularbase.cpp
features/cellular/framework/AT/AT_CellularBase/at_cellularbasetest.cpp
)
Loading