25 lines
801 B
C
25 lines
801 B
C
#include <assert.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "command_queue.h"
|
|
|
|
int main(void) {
|
|
command_queue_t queue = {0};
|
|
app_command_t input = {.type = COMMAND_SHOT, .session_index = 1, .game_id = 7, .version = 3, .coordinate = {4, 5}};
|
|
app_command_t output = {0};
|
|
assert(!command_queue_pop(&queue, &output));
|
|
for (int index = 0; index < kCommandQueueCapacity; ++index) {
|
|
input.coordinate.x = (uint8_t)index;
|
|
assert(command_queue_push(&queue, &input));
|
|
}
|
|
assert(!command_queue_push(&queue, &input));
|
|
for (int index = 0; index < kCommandQueueCapacity; ++index) {
|
|
assert(command_queue_pop(&queue, &output));
|
|
assert(output.coordinate.x == (uint8_t)index);
|
|
}
|
|
assert(!command_queue_pop(&queue, &output));
|
|
puts("command queue tests passed");
|
|
return 0;
|
|
}
|