/* * Copyright (c) 2023 Fancy Code. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "ILog.h" #include "UartDevice.h" #include #include namespace UartDeviceTest { // ../output_files/test/bin/UartDeviceTest --gtest_filter=UartDeviceTest.UNIT_UartDevice_AUTO_IllegalObject /** * UartDevice module api will not crash when object is illegal. */ TEST(UartDeviceTest, UNIT_UartDevice_AUTO_IllegalObject) { CreateLogModule(); ILogInit(LOG_INSTANCE_TYPE_END); IUartOpen(nullptr); IUartSend(nullptr, nullptr, 0); IUartRecv(nullptr, nullptr, 0, 0); IUartTcflush(nullptr); IUartDeviceFree(nullptr); char illegalObject[100] = {0}; void *object = &illegalObject[10]; IUartOpen(object); IUartSend(object, nullptr, 0); IUartRecv(object, nullptr, 0, 0); IUartTcflush(object); IUartDeviceFree(object); ILogUnInit(); } // ../output_files/test/bin/UartDeviceTest --gtest_filter=UartDeviceTest.UNIT_UartDevice_EXAMPLE_Demo TEST(UartDeviceTest, UNIT_UartDevice_EXAMPLE_Demo) { CreateLogModule(); ILogInit(LOG_INSTANCE_TYPE_END); UartInfo device = { "dev/s1", }; void *object = CreateUartDevice(device); IUartOpen(object); // IUartSend(object, nullptr, 0); // IUartRecv(object, nullptr, 0, 0); // IUartTcflush(object); IUartDeviceFree(object); ILogUnInit(); } } // namespace UartDeviceTest