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.
at_cellularbasetest.cpp
00001 /* 00002 * Copyright (c) 2018, Arm Limited and affiliates. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #include "gtest/gtest.h" 00019 #include "AT_CellularBase.h" 00020 #include "EventQueue.h" 00021 #include "AT_CellularBase.h" 00022 #include "ATHandler_stub.h" 00023 #include "FileHandle_stub.h" 00024 #include <string.h> 00025 00026 using namespace mbed; 00027 using namespace events; 00028 00029 class my_base : public AT_CellularBase { 00030 public: 00031 my_base(ATHandler &at) : AT_CellularBase(at) 00032 { 00033 } 00034 bool check_not_supported() 00035 { 00036 static const AT_CellularBase::SupportedFeature unsupported_features[] = { 00037 AT_CellularBase::AT_CGSN_WITH_TYPE, 00038 AT_CellularBase::SUPPORTED_FEATURE_END_MARK 00039 }; 00040 set_unsupported_features(unsupported_features); 00041 return is_supported(AT_CGSN_WITH_TYPE); 00042 } 00043 00044 bool check_supported() 00045 { 00046 set_unsupported_features(NULL); 00047 return is_supported(AT_CGSN_WITH_TYPE); 00048 } 00049 00050 bool check_supported_not_found() 00051 { 00052 static const AT_CellularBase::SupportedFeature unsupported_features[] = { 00053 AT_CellularBase::AT_CGSN_WITH_TYPE, 00054 AT_CellularBase::SUPPORTED_FEATURE_END_MARK 00055 }; 00056 set_unsupported_features(unsupported_features); 00057 return is_supported(SUPPORTED_FEATURE_END_MARK); 00058 } 00059 }; 00060 00061 // AStyle ignored as the definition is not clear due to preprocessor usage 00062 // *INDENT-OFF* 00063 class TestAT_CellularBase : public testing::Test { 00064 protected: 00065 00066 void SetUp() 00067 { 00068 } 00069 00070 void TearDown() 00071 { 00072 } 00073 }; 00074 // *INDENT-ON* 00075 00076 TEST_F(TestAT_CellularBase, Create) 00077 { 00078 EventQueue eq; 00079 FileHandle_stub fh; 00080 ATHandler ah(&fh, eq, 100, ","); 00081 AT_CellularBase *unit = new AT_CellularBase(ah); 00082 00083 EXPECT_TRUE(unit != NULL); 00084 00085 delete unit; 00086 } 00087 00088 TEST_F(TestAT_CellularBase, test_AT_CellularBase_get_at_handler) 00089 { 00090 EventQueue eq; 00091 FileHandle_stub fh; 00092 ATHandler ah(&fh, eq, 100, ","); 00093 AT_CellularBase at(ah); 00094 00095 EXPECT_TRUE(&ah == &at.get_at_handler()); 00096 } 00097 00098 TEST_F(TestAT_CellularBase, test_AT_CellularBase_get_device_error) 00099 { 00100 EventQueue eq; 00101 FileHandle_stub fh; 00102 ATHandler ah(&fh, eq, 0, ","); 00103 AT_CellularBase at(ah); 00104 00105 ATHandler_stub::device_err_value.errCode = 8; 00106 00107 EXPECT_EQ(8, at.get_device_error().errCode); 00108 00109 ATHandler_stub::device_err_value.errCode = 0; 00110 } 00111 00112 TEST_F(TestAT_CellularBase, test_AT_CellularBase_set_unsupported_features) 00113 { 00114 EventQueue eq; 00115 FileHandle_stub fh; 00116 ATHandler ah(&fh, eq, 0, ","); 00117 AT_CellularBase at(ah); 00118 00119 static const AT_CellularBase::SupportedFeature unsupported_features[] = { 00120 AT_CellularBase::AT_CGSN_WITH_TYPE, 00121 AT_CellularBase::SUPPORTED_FEATURE_END_MARK 00122 }; 00123 00124 at.set_unsupported_features(unsupported_features); 00125 } 00126 00127 TEST_F(TestAT_CellularBase, test_AT_CellularBase_is_supported) 00128 { 00129 EventQueue eq; 00130 FileHandle_stub fh; 00131 ATHandler ah(&fh, eq, 0, ","); 00132 my_base my_at(ah); 00133 00134 EXPECT_TRUE(true == my_at.check_supported()); 00135 EXPECT_TRUE(true == my_at.check_supported_not_found()); 00136 EXPECT_TRUE(false == my_at.check_not_supported()); 00137 }
Generated on Tue Aug 9 2022 00:37:02 by
1.7.2