Remove deprecated CLI name command
[betaflight.git] / src / test / unit / io_serial_unittest.cc
blob817272c2b4115ad0e3dada8ffdacf099a74c728e
1 /*
2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #include <stdint.h>
19 #include <stdbool.h>
21 #include <limits.h>
23 extern "C" {
24 #include "platform.h"
26 #include "drivers/serial.h"
27 #include "drivers/serial_softserial.h"
28 #include "drivers/serial_uart.h"
30 #include "io/serial.h"
32 void serialInit(bool softserialEnabled, serialPortIdentifier_e serialPortToDisable);
35 #include "unittest_macros.h"
36 #include "gtest/gtest.h"
38 TEST(IoSerialTest, TestFindPortConfig)
40 // given
41 serialInit(false, SERIAL_PORT_NONE);
43 // when
44 serialPortConfig_t *portConfig = findSerialPortConfig(FUNCTION_MSP);
46 // then
47 EXPECT_EQ(NULL, portConfig);
51 // STUBS
52 extern "C" {
53 void delay(uint32_t) {}
55 bool isSerialTransmitBufferEmpty(const serialPort_t *) { return true; }
57 void systemResetToBootloader(void) {}
59 bool telemetryCheckRxPortShared(const serialPortConfig_t *) { return false; }
61 uint32_t serialRxBytesWaiting(const serialPort_t *) { return 0; }
62 uint8_t serialRead(serialPort_t *) { return 0; }
63 void serialWrite(serialPort_t *, uint8_t) {}
65 serialPort_t *usbVcpOpen(void) { return NULL; }
67 serialPort_t *uartOpen(UARTDevice_e, serialReceiveCallbackPtr, void *, uint32_t, portMode_e, portOptions_e) {
68 return NULL;
71 serialPort_t *openSoftSerial(softSerialPortIndex_e, serialReceiveCallbackPtr, void *, uint32_t, portMode_e, portOptions_e) {
72 return NULL;
75 void serialSetCtrlLineStateCb(serialPort_t *, void (*)(void *, uint16_t ), void *) {}
76 void serialSetCtrlLineState(serialPort_t *, uint16_t ) {}
77 uint32_t serialTxBytesFree(const serialPort_t *) {return 1;}
79 void serialSetBaudRateCb(serialPort_t *, void (*)(serialPort_t *context, uint32_t baud), serialPort_t *) {}
81 void pinioSet(int, bool) {}