mirror of https://github.com/ARMmbed/mbed-os.git
unittests: fix astyle
parent
4b3a031087
commit
3a5ef5ee24
|
|
@ -26,10 +26,12 @@ using namespace events;
|
|||
class TestAT_CellularDevice : public testing::Test {
|
||||
protected:
|
||||
|
||||
void SetUp() {
|
||||
void SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
void TearDown() {
|
||||
void TearDown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@
|
|||
|
||||
using namespace events;
|
||||
|
||||
class my_phy : public LoRaPHY
|
||||
{
|
||||
class my_phy : public LoRaPHY {
|
||||
public:
|
||||
my_phy() {};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
#include "LoRaPHY_stub.h"
|
||||
#include "LoRaPHY.h"
|
||||
|
||||
class my_LoRaPHY : public LoRaPHY
|
||||
{
|
||||
class my_LoRaPHY : public LoRaPHY {
|
||||
public:
|
||||
my_LoRaPHY() {};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
|
||||
#include "LoRaPHY_stub.h"
|
||||
|
||||
class my_LoRaPHY : public LoRaPHY
|
||||
{
|
||||
class my_LoRaPHY : public LoRaPHY {
|
||||
public:
|
||||
my_LoRaPHY() {};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,20 +20,22 @@
|
|||
|
||||
#include "LoRaWANTimer_stub.h"
|
||||
|
||||
class my_LoRaPHY : public LoRaPHY
|
||||
{
|
||||
class my_LoRaPHY : public LoRaPHY {
|
||||
public:
|
||||
my_LoRaPHY(){phy_params.adr_ack_delay = 1;}
|
||||
my_LoRaPHY()
|
||||
{
|
||||
phy_params.adr_ack_delay = 1;
|
||||
}
|
||||
|
||||
virtual ~my_LoRaPHY() {}
|
||||
|
||||
loraphy_params_t &get_phy_params() {
|
||||
loraphy_params_t &get_phy_params()
|
||||
{
|
||||
return phy_params;
|
||||
}
|
||||
};
|
||||
|
||||
class my_radio : public LoRaRadio
|
||||
{
|
||||
class my_radio : public LoRaRadio {
|
||||
public:
|
||||
|
||||
virtual void init_radio(radio_events_t *events) {};
|
||||
|
|
@ -66,7 +68,10 @@ public:
|
|||
|
||||
virtual uint32_t random(void) {};
|
||||
|
||||
virtual uint8_t get_status(void){return uint8_value;};
|
||||
virtual uint8_t get_status(void)
|
||||
{
|
||||
return uint8_value;
|
||||
};
|
||||
|
||||
virtual void set_max_payload_length(radio_modems_t modem, uint8_t max) {};
|
||||
|
||||
|
|
@ -77,11 +82,17 @@ public:
|
|||
virtual bool perform_carrier_sense(radio_modems_t modem,
|
||||
uint32_t freq,
|
||||
int16_t rssi_threshold,
|
||||
uint32_t max_carrier_sense_time){ return bool_value;};
|
||||
uint32_t max_carrier_sense_time)
|
||||
{
|
||||
return bool_value;
|
||||
};
|
||||
|
||||
virtual void start_cad(void) {};
|
||||
|
||||
virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; };
|
||||
virtual bool check_rf_frequency(uint32_t frequency)
|
||||
{
|
||||
return bool_value;
|
||||
};
|
||||
|
||||
virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time) {};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
|
||||
#include "LoRaPHY_stub.h"
|
||||
|
||||
class my_radio : public LoRaRadio
|
||||
{
|
||||
class my_radio : public LoRaRadio {
|
||||
public:
|
||||
|
||||
virtual void init_radio(radio_events_t *events) {};
|
||||
|
|
@ -54,7 +53,10 @@ public:
|
|||
|
||||
virtual uint32_t random(void) {};
|
||||
|
||||
virtual uint8_t get_status(void){return uint8_value;};
|
||||
virtual uint8_t get_status(void)
|
||||
{
|
||||
return uint8_value;
|
||||
};
|
||||
|
||||
virtual void set_max_payload_length(radio_modems_t modem, uint8_t max) {};
|
||||
|
||||
|
|
@ -65,11 +67,17 @@ public:
|
|||
virtual bool perform_carrier_sense(radio_modems_t modem,
|
||||
uint32_t freq,
|
||||
int16_t rssi_threshold,
|
||||
uint32_t max_carrier_sense_time){ return bool_value;};
|
||||
uint32_t max_carrier_sense_time)
|
||||
{
|
||||
return bool_value;
|
||||
};
|
||||
|
||||
virtual void start_cad(void) {};
|
||||
|
||||
virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; };
|
||||
virtual bool check_rf_frequency(uint32_t frequency)
|
||||
{
|
||||
return bool_value;
|
||||
};
|
||||
|
||||
virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time) {};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
|
||||
#include "LoRaPHY_stub.h"
|
||||
|
||||
class my_radio : public LoRaRadio
|
||||
{
|
||||
class my_radio : public LoRaRadio {
|
||||
public:
|
||||
|
||||
virtual void init_radio(radio_events_t *events) {};
|
||||
|
|
@ -54,7 +53,10 @@ public:
|
|||
|
||||
virtual uint32_t random(void) {};
|
||||
|
||||
virtual uint8_t get_status(void){return uint8_value;};
|
||||
virtual uint8_t get_status(void)
|
||||
{
|
||||
return uint8_value;
|
||||
};
|
||||
|
||||
virtual void set_max_payload_length(radio_modems_t modem, uint8_t max) {};
|
||||
|
||||
|
|
@ -65,11 +67,17 @@ public:
|
|||
virtual bool perform_carrier_sense(radio_modems_t modem,
|
||||
uint32_t freq,
|
||||
int16_t rssi_threshold,
|
||||
uint32_t max_carrier_sense_time){ return bool_value;};
|
||||
uint32_t max_carrier_sense_time)
|
||||
{
|
||||
return bool_value;
|
||||
};
|
||||
|
||||
virtual void start_cad(void) {};
|
||||
|
||||
virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; };
|
||||
virtual bool check_rf_frequency(uint32_t frequency)
|
||||
{
|
||||
return bool_value;
|
||||
};
|
||||
|
||||
virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time) {};
|
||||
|
||||
|
|
@ -227,8 +235,12 @@ TEST_F(Test_LoRaPHYAU915, apply_DR_offset)
|
|||
for (int j = 0; j < 6; j++) {
|
||||
uint8_t val = 8 + i;
|
||||
val -= j;
|
||||
if (val > 13) val = 13;
|
||||
if (val < 8) val = 8;
|
||||
if (val > 13) {
|
||||
val = 13;
|
||||
}
|
||||
if (val < 8) {
|
||||
val = 8;
|
||||
}
|
||||
EXPECT_TRUE(val == object->apply_DR_offset(i, j));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
|
||||
#include "LoRaPHY_stub.h"
|
||||
|
||||
class my_radio : public LoRaRadio
|
||||
{
|
||||
class my_radio : public LoRaRadio {
|
||||
public:
|
||||
|
||||
virtual void init_radio(radio_events_t *events) {};
|
||||
|
|
@ -54,7 +53,10 @@ public:
|
|||
|
||||
virtual uint32_t random(void) {};
|
||||
|
||||
virtual uint8_t get_status(void){return uint8_value;};
|
||||
virtual uint8_t get_status(void)
|
||||
{
|
||||
return uint8_value;
|
||||
};
|
||||
|
||||
virtual void set_max_payload_length(radio_modems_t modem, uint8_t max) {};
|
||||
|
||||
|
|
@ -65,11 +67,17 @@ public:
|
|||
virtual bool perform_carrier_sense(radio_modems_t modem,
|
||||
uint32_t freq,
|
||||
int16_t rssi_threshold,
|
||||
uint32_t max_carrier_sense_time){ return bool_value;};
|
||||
uint32_t max_carrier_sense_time)
|
||||
{
|
||||
return bool_value;
|
||||
};
|
||||
|
||||
virtual void start_cad(void) {};
|
||||
|
||||
virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; };
|
||||
virtual bool check_rf_frequency(uint32_t frequency)
|
||||
{
|
||||
return bool_value;
|
||||
};
|
||||
|
||||
virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time) {};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@
|
|||
#include "LoRaPHY_stub.h"
|
||||
#include "LoRaRadio.h"
|
||||
|
||||
class my_radio : public LoRaRadio
|
||||
{
|
||||
class my_radio : public LoRaRadio {
|
||||
public:
|
||||
|
||||
virtual void init_radio(radio_events_t *events) {};
|
||||
|
|
@ -65,11 +64,17 @@ public:
|
|||
virtual bool perform_carrier_sense(radio_modems_t modem,
|
||||
uint32_t freq,
|
||||
int16_t rssi_threshold,
|
||||
uint32_t max_carrier_sense_time){ return bool_value;};
|
||||
uint32_t max_carrier_sense_time)
|
||||
{
|
||||
return bool_value;
|
||||
};
|
||||
|
||||
virtual void start_cad(void) {};
|
||||
|
||||
virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; };
|
||||
virtual bool check_rf_frequency(uint32_t frequency)
|
||||
{
|
||||
return bool_value;
|
||||
};
|
||||
|
||||
virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time) {};
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@
|
|||
#include "LoRaPHYUS915.h"
|
||||
#include "LoRaPHY_stub.h"
|
||||
|
||||
class my_radio : public LoRaRadio
|
||||
{
|
||||
class my_radio : public LoRaRadio {
|
||||
public:
|
||||
|
||||
virtual void init_radio(radio_events_t *events) {};
|
||||
|
|
@ -53,7 +52,10 @@ public:
|
|||
|
||||
virtual uint32_t random(void) {};
|
||||
|
||||
virtual uint8_t get_status(void){return uint8_value;};
|
||||
virtual uint8_t get_status(void)
|
||||
{
|
||||
return uint8_value;
|
||||
};
|
||||
|
||||
virtual void set_max_payload_length(radio_modems_t modem, uint8_t max) {};
|
||||
|
||||
|
|
@ -64,11 +66,17 @@ public:
|
|||
virtual bool perform_carrier_sense(radio_modems_t modem,
|
||||
uint32_t freq,
|
||||
int16_t rssi_threshold,
|
||||
uint32_t max_carrier_sense_time){ return bool_value;};
|
||||
uint32_t max_carrier_sense_time)
|
||||
{
|
||||
return bool_value;
|
||||
};
|
||||
|
||||
virtual void start_cad(void) {};
|
||||
|
||||
virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; };
|
||||
virtual bool check_rf_frequency(uint32_t frequency)
|
||||
{
|
||||
return bool_value;
|
||||
};
|
||||
|
||||
virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time) {};
|
||||
|
||||
|
|
@ -224,8 +232,12 @@ TEST_F(Test_LoRaPHYUS915, apply_DR_offset)
|
|||
for (int j = 0; j < 4; j++) {
|
||||
uint8_t val = 10 + i;
|
||||
val -= j;
|
||||
if (val > 13) val = 13;
|
||||
if (val < 8) val = 8;
|
||||
if (val > 13) {
|
||||
val = 13;
|
||||
}
|
||||
if (val < 8) {
|
||||
val = 8;
|
||||
}
|
||||
EXPECT_TRUE(val == object->apply_DR_offset(i, j));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@
|
|||
#include "gtest/gtest.h"
|
||||
#include "LoRaWANInterface.h"
|
||||
|
||||
class my_radio : public LoRaRadio
|
||||
{
|
||||
class my_radio : public LoRaRadio {
|
||||
public:
|
||||
|
||||
virtual void init_radio(radio_events_t *events) {};
|
||||
|
|
@ -76,8 +75,7 @@ public:
|
|||
virtual void unlock(void) {};
|
||||
};
|
||||
|
||||
class my_LoRaPHY : public LoRaPHY
|
||||
{
|
||||
class my_LoRaPHY : public LoRaPHY {
|
||||
public:
|
||||
my_LoRaPHY() {};
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@ static uint8_t batt_level = 0;
|
|||
|
||||
using namespace events;
|
||||
|
||||
class my_LoRaPHY : public LoRaPHY
|
||||
{
|
||||
class my_LoRaPHY : public LoRaPHY {
|
||||
public:
|
||||
my_LoRaPHY() {};
|
||||
|
||||
|
|
@ -41,12 +40,14 @@ uint8_t my_cb()
|
|||
return 1;
|
||||
}
|
||||
|
||||
class my_radio : public LoRaRadio
|
||||
{
|
||||
class my_radio : public LoRaRadio {
|
||||
public:
|
||||
radio_events_t *_ev;
|
||||
|
||||
virtual void init_radio(radio_events_t *events){_ev = events;};
|
||||
virtual void init_radio(radio_events_t *events)
|
||||
{
|
||||
_ev = events;
|
||||
};
|
||||
|
||||
virtual void radio_reset() {};
|
||||
|
||||
|
|
@ -76,7 +77,10 @@ public:
|
|||
|
||||
virtual uint32_t random(void) {};
|
||||
|
||||
virtual uint8_t get_status(void){return uint8_value;};
|
||||
virtual uint8_t get_status(void)
|
||||
{
|
||||
return uint8_value;
|
||||
};
|
||||
|
||||
virtual void set_max_payload_length(radio_modems_t modem, uint8_t max) {};
|
||||
|
||||
|
|
@ -87,11 +91,17 @@ public:
|
|||
virtual bool perform_carrier_sense(radio_modems_t modem,
|
||||
uint32_t freq,
|
||||
int16_t rssi_threshold,
|
||||
uint32_t max_carrier_sense_time){ return bool_value;};
|
||||
uint32_t max_carrier_sense_time)
|
||||
{
|
||||
return bool_value;
|
||||
};
|
||||
|
||||
virtual void start_cad(void) {};
|
||||
|
||||
virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; };
|
||||
virtual bool check_rf_frequency(uint32_t frequency)
|
||||
{
|
||||
return bool_value;
|
||||
};
|
||||
|
||||
virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time) {};
|
||||
|
||||
|
|
|
|||
|
|
@ -42,8 +42,7 @@ uint32_t rtos::EventFlags::wait_all(uint32_t flags, uint32_t timeout, bool clear
|
|||
}
|
||||
uint32_t rtos::EventFlags::wait_any(uint32_t flags, uint32_t timeout, bool clear)
|
||||
{
|
||||
if (!eventFlagsStubNextRetval.empty())
|
||||
{
|
||||
if (!eventFlagsStubNextRetval.empty()) {
|
||||
uint32_t ret = eventFlagsStubNextRetval.front();
|
||||
eventFlagsStubNextRetval.pop_front();
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@
|
|||
|
||||
#include <inttypes.h>
|
||||
|
||||
namespace EventQueue_stub
|
||||
{
|
||||
namespace EventQueue_stub {
|
||||
extern int int_value;
|
||||
extern unsigned unsigned_value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,27 +20,26 @@
|
|||
|
||||
#include "FileHandle.h"
|
||||
|
||||
namespace mbed
|
||||
{
|
||||
namespace mbed {
|
||||
|
||||
static uint8_t filehandle_stub_short_value_counter = 0;
|
||||
static char *filehandle_stub_table = NULL;
|
||||
static uint8_t filehandle_stub_table_pos = 0;
|
||||
|
||||
class FileHandle_stub : public FileHandle
|
||||
{
|
||||
class FileHandle_stub : public FileHandle {
|
||||
public:
|
||||
ssize_t size_value;
|
||||
|
||||
FileHandle_stub() { size_value = 0; }
|
||||
FileHandle_stub()
|
||||
{
|
||||
size_value = 0;
|
||||
}
|
||||
|
||||
virtual ssize_t read(void *buffer, size_t size)
|
||||
{
|
||||
if (filehandle_stub_table)
|
||||
{
|
||||
if (filehandle_stub_table) {
|
||||
ssize_t ret = strlen(filehandle_stub_table) - filehandle_stub_table_pos;
|
||||
if (size < ret)
|
||||
{
|
||||
if (size < ret) {
|
||||
ret = size;
|
||||
}
|
||||
memcpy(buffer, filehandle_stub_table, ret);
|
||||
|
|
@ -52,33 +51,35 @@ class FileHandle_stub : public FileHandle
|
|||
|
||||
virtual ssize_t write(const void *buffer, size_t size)
|
||||
{
|
||||
if (size_value > 0)
|
||||
{
|
||||
if (size_value > 0) {
|
||||
size_value--;
|
||||
return size;
|
||||
}
|
||||
else if (size_value < 0)
|
||||
{
|
||||
} else if (size_value < 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual off_t seek(off_t offset, int whence = SEEK_SET) { return 0; }
|
||||
virtual off_t seek(off_t offset, int whence = SEEK_SET)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int close() {}
|
||||
|
||||
virtual short poll(short events) const
|
||||
{
|
||||
if (filehandle_stub_short_value_counter)
|
||||
{
|
||||
if (filehandle_stub_short_value_counter) {
|
||||
filehandle_stub_short_value_counter--;
|
||||
return short_value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void sigio(Callback<void()> func) { func(); }
|
||||
virtual void sigio(Callback<void()> func)
|
||||
{
|
||||
func();
|
||||
}
|
||||
|
||||
short short_value;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@
|
|||
#include <inttypes.h>
|
||||
#include "lorawan_types.h"
|
||||
|
||||
namespace LoRaMacCommand_stub
|
||||
{
|
||||
namespace LoRaMacCommand_stub {
|
||||
extern lorawan_status_t status_value;
|
||||
extern bool bool_value;
|
||||
extern uint8_t uint8_value;
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@
|
|||
|
||||
#include <inttypes.h>
|
||||
|
||||
namespace LoRaMacCrypto_stub
|
||||
{
|
||||
namespace LoRaMacCrypto_stub {
|
||||
extern int int_table_idx_value;
|
||||
extern int int_table[20];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@
|
|||
#include "lorawan_types.h"
|
||||
#include "lorawan_data_structures.h"
|
||||
|
||||
namespace LoRaMac_stub
|
||||
{
|
||||
namespace LoRaMac_stub {
|
||||
extern bool bool_value;
|
||||
extern int bool_false_counter;
|
||||
extern int bool_true_counter;
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@
|
|||
|
||||
#include "lorawan_types.h"
|
||||
|
||||
namespace LoRaPHY_stub
|
||||
{
|
||||
namespace LoRaPHY_stub {
|
||||
extern LoRaRadio *radio;
|
||||
extern uint8_t bool_counter;
|
||||
extern bool bool_table[20];
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@
|
|||
|
||||
#include "LoRaWANTimer.h"
|
||||
|
||||
namespace LoRaWANTimer_stub
|
||||
{
|
||||
namespace LoRaWANTimer_stub {
|
||||
extern lorawan_time_t time_value;
|
||||
extern bool call_cb_immediately;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,8 +47,7 @@ public:
|
|||
protected:
|
||||
virtual nsapi_error_t socket_open(nsapi_socket_t *handle, nsapi_protocol_t proto)
|
||||
{
|
||||
if (return_value == NSAPI_ERROR_OK && return_values.front() == NSAPI_ERROR_OK)
|
||||
{
|
||||
if (return_value == NSAPI_ERROR_OK && return_values.front() == NSAPI_ERROR_OK) {
|
||||
// Make sure a non-NULL value is returned if error is not expected
|
||||
*handle = reinterpret_cast<nsapi_socket_t *>(1234);
|
||||
}
|
||||
|
|
@ -68,8 +67,7 @@ protected:
|
|||
};
|
||||
virtual nsapi_error_t socket_connect(nsapi_socket_t handle, const SocketAddress &address)
|
||||
{
|
||||
if (!return_values.empty())
|
||||
{
|
||||
if (!return_values.empty()) {
|
||||
nsapi_error_t ret = return_values.front();
|
||||
return_values.pop_front();
|
||||
return ret;
|
||||
|
|
@ -84,8 +82,7 @@ protected:
|
|||
virtual nsapi_size_or_error_t socket_send(nsapi_socket_t handle,
|
||||
const void *data, nsapi_size_t size)
|
||||
{
|
||||
if (!return_values.empty())
|
||||
{
|
||||
if (!return_values.empty()) {
|
||||
nsapi_error_t ret = return_values.front();
|
||||
return_values.pop_front();
|
||||
return ret;
|
||||
|
|
@ -95,8 +92,7 @@ protected:
|
|||
virtual nsapi_size_or_error_t socket_recv(nsapi_socket_t handle,
|
||||
void *data, nsapi_size_t size)
|
||||
{
|
||||
if (!return_values.empty())
|
||||
{
|
||||
if (!return_values.empty()) {
|
||||
nsapi_error_t ret = return_values.front();
|
||||
return_values.pop_front();
|
||||
return ret;
|
||||
|
|
@ -111,8 +107,7 @@ protected:
|
|||
virtual nsapi_size_or_error_t socket_recvfrom(nsapi_socket_t handle, SocketAddress *address,
|
||||
void *buffer, nsapi_size_t size)
|
||||
{
|
||||
if (!return_values.empty())
|
||||
{
|
||||
if (!return_values.empty()) {
|
||||
nsapi_error_t ret = return_values.front();
|
||||
return_values.pop_front();
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -108,7 +108,8 @@ void equeue_chain(equeue_t *queue, equeue_t *target)
|
|||
|
||||
}
|
||||
|
||||
int equeue_call_in(equeue_t *q, int ms, void (*cb)(void*), void *data) {
|
||||
int equeue_call_in(equeue_t *q, int ms, void (*cb)(void *), void *data)
|
||||
{
|
||||
// The stub does not implement the delay mechanism.
|
||||
return equeue_post(q, cb, data);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue