avr/packet-radio/tests/radio.c

47 lines
1.9 KiB
C

/*
Copyright 2022, Savanni D'Gerinel <savanni@luminescent-dreams.com>
This file is part of Savanni's AVR library.
This AVR library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This AVR library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this AVR library. If not, see <https://www.gnu.org/licenses/>.
*/
#include <criterion/criterion.h>
#include "radio.h"
/*
typedef struct {
void (*set_mode)(radio_mock_t *, radio_mode_e, radio_status_e *);
flags_t (*get_flags)(radio_mock_t *, radio_status_e *);
radio_mock_t (*transmit)(radio_mock_t *, packet_t *, radio_status_e *);
void (*receive)(radio_mock_t *, uint8_t data[66], radio_status_e *);
} radio_mock_t;
*/
void set_mode(radio_t *radio, radio_mode_e mode, radio_status_e *status) { }
flags_t get_flags(radio_t *radio, radio_status_e *status) {
flags_t flags = { .packet_sent = false, .packet_ready = false };
return flags;
}
void transmit(radio_t *radio, packet_t *packet, radio_status_e *status) { }
void receive(radio_t *radio, uint8_t data[66], radio_status_e *status) { }
Test(radio, connect) {
radio_t radio = (radio_t){ .set_mode = set_mode, .get_flags = get_flags, .transmit = transmit, .receive = receive };
conn_t *conn = conn_connect((radio_t *)&radio);
radio_status_e status = ok;
flags_t flags = conn_get_flags(conn, &status);
cr_assert(IS_OK(&status));
cr_assert(flags.packet_sent == false);
cr_assert(flags.packet_ready == false);
}