Compare commits
No commits in common. "master" and "ad8f6f80930f666a6326e1e5186e3946519b23b9" have entirely different histories.
master
...
ad8f6f8093
82
a1/program.c
82
a1/program.c
@ -1,82 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
char line[100];
|
|
||||||
double num1, num2, result, expected_result;
|
|
||||||
char op;
|
|
||||||
|
|
||||||
while (fgets(line, sizeof(line), stdin) != NULL) {
|
|
||||||
if (line[0] == '\n') {
|
|
||||||
// Stop when the user enters a blank line
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
num1 = num2 = result = expected_result = 0;
|
|
||||||
op = '\0';
|
|
||||||
|
|
||||||
// Remove any spaces between symbols
|
|
||||||
for (int i = 0; line[i] != '\0'; i++) {
|
|
||||||
if (isspace(line[i])) {
|
|
||||||
for (int j = i; line[j] != '\0'; j++) {
|
|
||||||
line[j] = line[j + 1];
|
|
||||||
}
|
|
||||||
i--; // Move back one step to recheck the current character
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the line
|
|
||||||
if (sscanf(line, "%lf%c%lf=%lf", &num1, &op, &num2, &expected_result) != 4) {
|
|
||||||
printf("CHYBA\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the input is valid
|
|
||||||
if (op != '+' && op != '-' && op != '*' && op != '/') {
|
|
||||||
printf("CHYBA\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for division by zero
|
|
||||||
if (op == '/' && num2 == 0) {
|
|
||||||
printf("ZLE\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Perform the calculation
|
|
||||||
switch (op) {
|
|
||||||
case '+':
|
|
||||||
result = num1 + num2;
|
|
||||||
break;
|
|
||||||
case '-':
|
|
||||||
result = num1 - num2;
|
|
||||||
break;
|
|
||||||
case '*':
|
|
||||||
result = num1 * num2;
|
|
||||||
break;
|
|
||||||
case '/':
|
|
||||||
if (num2 == 0) {
|
|
||||||
printf("CHYBA\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
result = num1 / num2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Round both result and expected_result to two decimal places
|
|
||||||
result = round(result * 100.0) / 100.0;
|
|
||||||
expected_result = round(expected_result * 100.0) / 100.0;
|
|
||||||
|
|
||||||
// Check if the result is correct
|
|
||||||
if (result == expected_result) {
|
|
||||||
printf("OK\n");
|
|
||||||
} else {
|
|
||||||
printf("ZLE\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
86
a2/snake.c
86
a2/snake.c
@ -1,86 +0,0 @@
|
|||||||
#include <stdlib.h>
|
|
||||||
#include <curses.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "world.h"
|
|
||||||
#include "snake.h"
|
|
||||||
|
|
||||||
// Initialize game state
|
|
||||||
void* init_game() {
|
|
||||||
struct state* st = calloc(1, sizeof(struct state));
|
|
||||||
st->width = 0;
|
|
||||||
st->height = 0;
|
|
||||||
st->sx = 0;
|
|
||||||
st->sy = 0;
|
|
||||||
st->snake = NULL;
|
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
st->foodx[i] = 0;
|
|
||||||
st->foody[i] = 0;
|
|
||||||
}
|
|
||||||
return st;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize game state
|
|
||||||
void init_snake(struct event* world, struct state* st) {
|
|
||||||
int cy = world->height / 2;
|
|
||||||
int cx = world->width / 2 - 5;
|
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
st->snake = add_snake(st->snake, cx + i, cy);
|
|
||||||
}
|
|
||||||
|
|
||||||
int h = world->height;
|
|
||||||
int w = world->width;
|
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
st->foodx[i] = rand() % w;
|
|
||||||
st->foody[i] = rand() % h;
|
|
||||||
}
|
|
||||||
st->sx = 1;
|
|
||||||
st->sy = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle game events
|
|
||||||
int world_event(struct event* w, void* game) {
|
|
||||||
struct state* st = game;
|
|
||||||
if (w->type == EVENT_START) {
|
|
||||||
init_snake(w, st);
|
|
||||||
} else if (w->type == EVENT_KEY) {
|
|
||||||
int key = w->key;
|
|
||||||
if (key == KEY_RIGHT) {
|
|
||||||
st->sx = 1;
|
|
||||||
st->sy = 0;
|
|
||||||
} else if (key == KEY_LEFT) {
|
|
||||||
st->sx = -1;
|
|
||||||
st->sy = 0;
|
|
||||||
} else if (key == KEY_DOWN) {
|
|
||||||
st->sx = 0;
|
|
||||||
st->sy = 1;
|
|
||||||
} else if (key == KEY_UP) {
|
|
||||||
st->sx = 0;
|
|
||||||
st->sy = -1;
|
|
||||||
}
|
|
||||||
} else if (w->type == EVENT_ESC) {
|
|
||||||
return 1;
|
|
||||||
} else if (w->type == EVENT_TIMEOUT) {
|
|
||||||
clear_screen();
|
|
||||||
st->width = w->width;
|
|
||||||
st->height = w->height;
|
|
||||||
int r = step_state(st);
|
|
||||||
char ms[200];
|
|
||||||
sprintf(ms, "r %d\n", r);
|
|
||||||
set_message(ms, 9, 9);
|
|
||||||
struct snake* sn = st->snake;
|
|
||||||
while (sn != NULL) {
|
|
||||||
set_cell('x', sn->x, sn->y);
|
|
||||||
sn = sn->next;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < FOOD_COUNT; i++) {
|
|
||||||
if (st->foodx[i] >= 0 && st->foody[i] >= 0) {
|
|
||||||
set_cell('*', st->foodx[i], st->foody[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (r) {
|
|
||||||
char message[] = "Koniec";
|
|
||||||
set_message(message, 10, 10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,84 +0,0 @@
|
|||||||
#include "binary_search_tree.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
int count_nodes(node_t *tree);
|
|
||||||
void in_order_traversal(node_t *tree, int **ptr);
|
|
||||||
|
|
||||||
node_t *build_tree(int *tree_data, size_t tree_data_len) {
|
|
||||||
if (tree_data_len == 0) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
node_t *root = malloc(sizeof(node_t));
|
|
||||||
root->data = tree_data[0];
|
|
||||||
root->left = NULL;
|
|
||||||
root->right = NULL;
|
|
||||||
|
|
||||||
for (size_t i = 1; i < tree_data_len; i++) {
|
|
||||||
node_t *current = root;
|
|
||||||
node_t *parent = NULL;
|
|
||||||
|
|
||||||
while (current!= NULL) {
|
|
||||||
parent = current;
|
|
||||||
if (tree_data[i] < current->data) {
|
|
||||||
current = current->left;
|
|
||||||
} else {
|
|
||||||
current = current->right;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
current = malloc(sizeof(node_t));
|
|
||||||
if (current == NULL) {
|
|
||||||
free_tree(root);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
current->data = tree_data[i];
|
|
||||||
current->left = NULL;
|
|
||||||
current->right = NULL;
|
|
||||||
|
|
||||||
if (tree_data[i] < parent->data) {
|
|
||||||
parent->left = current;
|
|
||||||
} else {
|
|
||||||
parent->right = current;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_tree(node_t *tree) {
|
|
||||||
if (tree == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
free_tree(tree->left);
|
|
||||||
free_tree(tree->right);
|
|
||||||
free(tree);
|
|
||||||
}
|
|
||||||
|
|
||||||
int *sorted_data(node_t *tree) {
|
|
||||||
int *data = malloc(sizeof(int) * count_nodes(tree));
|
|
||||||
int *ptr = data;
|
|
||||||
in_order_traversal(tree, &ptr);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
int count_nodes(node_t *tree) {
|
|
||||||
if (tree == NULL) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1 + count_nodes(tree->left) + count_nodes(tree->right);
|
|
||||||
}
|
|
||||||
|
|
||||||
void in_order_traversal(node_t *tree, int **ptr) {
|
|
||||||
if (tree == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
in_order_traversal(tree->left, ptr);
|
|
||||||
**ptr = tree->data;
|
|
||||||
(*ptr)++;
|
|
||||||
in_order_traversal(tree->right, ptr);
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int main(){
|
|
||||||
int c;
|
|
||||||
int line_count = 0;
|
|
||||||
|
|
||||||
while ((c = getchar()) != EOF){
|
|
||||||
if (c >= 'a' && c <= 'z') {
|
|
||||||
c = c - 'a' + 'A'; // Zmena malého písmena na veľké
|
|
||||||
}
|
|
||||||
else if (c >= 'A' && c <= 'Z') {
|
|
||||||
c = c - 'A' + 'a'; // Zmena veľkého písmena na malé
|
|
||||||
}
|
|
||||||
else if (c == '\n') {
|
|
||||||
line_count++; // Zvýšte počítadlo riadkov na konce riadka
|
|
||||||
}
|
|
||||||
else if (c == '\t'){
|
|
||||||
putchar(c);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (c < ' ' || c >= 127) {
|
|
||||||
continue; // Preskočiť značky
|
|
||||||
}
|
|
||||||
|
|
||||||
putchar(c); // Vypíš znak
|
|
||||||
}
|
|
||||||
printf("\nLines count: %d\n", line_count);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
int compare_names(const void *a, const void *b) {
|
|
||||||
return strcmp(*(const char **)a, *(const char **)b);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
int count;
|
|
||||||
char buffer[100];
|
|
||||||
char **applications;
|
|
||||||
int i, j, accepted_count = 0;
|
|
||||||
|
|
||||||
if (scanf("%d", &count) != 1 || count <= 0) {
|
|
||||||
printf("Nespravny vstup\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
applications = (char **)malloc(count * sizeof(char *));
|
|
||||||
if (!applications) {
|
|
||||||
printf("Chyba pri alokacii pamate\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
while (i < count && fgets(buffer, sizeof(buffer), stdin)) {
|
|
||||||
int len = strlen(buffer);
|
|
||||||
if (len > 0 && buffer[len - 1] == '\n') { // Remove newline character if present
|
|
||||||
buffer[len - 1] = '\0';
|
|
||||||
}
|
|
||||||
int found = 0;
|
|
||||||
for (j = 0; j < i; j++) {
|
|
||||||
if (strcmp(applications[j], buffer) == 0) {
|
|
||||||
found = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
applications[i] = strdup(buffer);
|
|
||||||
i++;
|
|
||||||
accepted_count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (accepted_count == 0) {
|
|
||||||
printf("Ziadne prihlasky\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sort the applications alphabetically
|
|
||||||
qsort(applications, accepted_count, sizeof(char *), compare_names);
|
|
||||||
|
|
||||||
printf("Prijati studenti:");
|
|
||||||
for (j = 0; j < count && j < accepted_count; j++) {
|
|
||||||
printf("%s\n", applications[j]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (count < accepted_count) {
|
|
||||||
printf("Neprijati studenti:");
|
|
||||||
for (; j < i; j++) {
|
|
||||||
printf("%s\n", applications[j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Free allocated memory
|
|
||||||
for (j = 0; j < i; j++) {
|
|
||||||
free(applications[j]);
|
|
||||||
}
|
|
||||||
free(applications);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
#include<stdio.h>
|
|
||||||
|
|
||||||
#define FIELD_SIZE 52
|
|
||||||
|
|
||||||
int main(){
|
|
||||||
int field[FIELD_SIZE] = {0};
|
|
||||||
int count = 0;
|
|
||||||
int max_num = 0;
|
|
||||||
int input;
|
|
||||||
|
|
||||||
while (count < FIELD_SIZE) {
|
|
||||||
if (scanf("%d", &input) != 1) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (input < 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
field[count] = input;
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
if (count < 2) {
|
|
||||||
printf("Chyba: Málo platných hodnôt.\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, field[i]);
|
|
||||||
if (field[i] > max_num) {
|
|
||||||
max_num = field[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
if (field[i] == max_num) {
|
|
||||||
printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n",i+1, max_num);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#define SIZE 100
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
double coefs[SIZE] = {0.0};
|
|
||||||
double x = 0.0;
|
|
||||||
double input = 0.0;
|
|
||||||
int count = 0;
|
|
||||||
int length = 0;
|
|
||||||
double result = 0.0;
|
|
||||||
|
|
||||||
while (count < SIZE) {
|
|
||||||
if (scanf("%lf", &input) != 1) {
|
|
||||||
if (scanf("%c", &input) == 1) {
|
|
||||||
if (count == 0){
|
|
||||||
printf("Nepodarilo sa nacitat zaklad x\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Nepodarilo sa nacitat polynom na %d mieste.\n", count);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
coefs[count] = input;
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
x = coefs[0];
|
|
||||||
length = count;
|
|
||||||
|
|
||||||
for (int i = 1; i < length; i ++){
|
|
||||||
result = result * x + coefs[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Vysledok je: %.2lf\n", result);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
128
cv4/list_ops.c
128
cv4/list_ops.c
@ -1,128 +0,0 @@
|
|||||||
#include "list_ops.h"
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
// constructs a new list
|
|
||||||
list_t *new_list(size_t length, list_element_t elements[]) {
|
|
||||||
list_t *newList = malloc(sizeof(list_t) + length * sizeof(list_element_t));
|
|
||||||
if (newList != NULL) {
|
|
||||||
newList->length = length;
|
|
||||||
if (length > 0 && elements != NULL) {
|
|
||||||
memcpy(newList->elements, elements, length * sizeof(list_element_t));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return newList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// append entries to a list and return the new list
|
|
||||||
list_t *append_list(list_t *list1, list_t *list2) {
|
|
||||||
if (list1 == NULL && list2 == NULL) {
|
|
||||||
return NULL; // Both lists are empty
|
|
||||||
} else if (list1 == NULL) {
|
|
||||||
return list2; // Only list1 is empty, return list2
|
|
||||||
} else if (list2 == NULL) {
|
|
||||||
return list1; // Only list2 is empty, return list1
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t new_length = list1->length + list2->length;
|
|
||||||
list_t *new_list = malloc(sizeof(list_t) + new_length * sizeof(list_element_t));
|
|
||||||
if (new_list == NULL) {
|
|
||||||
return NULL; // Memory allocation failed
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(new_list->elements, list1->elements, list1->length * sizeof(list_element_t));
|
|
||||||
memcpy(new_list->elements + list1->length, list2->elements, list2->length * sizeof(list_element_t));
|
|
||||||
|
|
||||||
new_list->length = new_length;
|
|
||||||
|
|
||||||
return new_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
// filter list returning only values that satisfy the filter function
|
|
||||||
list_t *filter_list(list_t *list, bool (*filter)(list_element_t)) {
|
|
||||||
if (list == NULL) return NULL;
|
|
||||||
|
|
||||||
size_t filteredLength = 0;
|
|
||||||
for (size_t i = 0; i < list->length; ++i) {
|
|
||||||
if (filter(list->elements[i])) {
|
|
||||||
++filteredLength;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
list_t *filtered = malloc(sizeof(list_t) + filteredLength * sizeof(list_element_t));
|
|
||||||
if (filtered != NULL) {
|
|
||||||
filtered->length = filteredLength;
|
|
||||||
for (size_t i = 0; i < list->length; ++i) {
|
|
||||||
if (filter(list->elements[i])) {
|
|
||||||
filtered->elements[i] = list->elements[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return filtered;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// returns the length of the list
|
|
||||||
size_t length_list(list_t *list) {
|
|
||||||
return (list != NULL) ? list->length : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// return a list of elements whose values equal the list value transformed by
|
|
||||||
// the mapping function
|
|
||||||
list_t *map_list(list_t *list, list_element_t (*map)(list_element_t)) {
|
|
||||||
if (list == NULL) return NULL;
|
|
||||||
|
|
||||||
list_t *mappedList = new_list(list->length, list->elements);
|
|
||||||
if (mappedList != NULL) {
|
|
||||||
for (size_t i = 0; i < list->length; ++i) {
|
|
||||||
mappedList->elements[i] = map(list->elements[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mappedList;
|
|
||||||
}
|
|
||||||
|
|
||||||
// folds (reduces) the given list from the left with a function
|
|
||||||
list_element_t foldl_list(list_t *list, list_element_t initial,
|
|
||||||
list_element_t (*foldl)(list_element_t, list_element_t)) {
|
|
||||||
list_element_t accumulator = initial;
|
|
||||||
if (list != NULL) {
|
|
||||||
for (size_t i = 0; i < list->length; ++i) {
|
|
||||||
accumulator = foldl(list->elements[i], accumulator);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return accumulator;
|
|
||||||
}
|
|
||||||
|
|
||||||
// folds (reduces) the given list from the right with a function
|
|
||||||
list_element_t foldr_list(list_t *list, list_element_t initial,
|
|
||||||
list_element_t (*foldr)(list_element_t, list_element_t)) {
|
|
||||||
list_element_t accumulator = initial;
|
|
||||||
if (list != NULL) {
|
|
||||||
for (size_t i = list->length; i > 0; --i) {
|
|
||||||
accumulator = foldr(list->elements[i - 1], accumulator);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return accumulator;
|
|
||||||
}
|
|
||||||
|
|
||||||
// reverse the elements of the list
|
|
||||||
list_t *reverse_list(list_t *list) {
|
|
||||||
if (list == NULL) return NULL;
|
|
||||||
|
|
||||||
list_t *reversedList = new_list(list->length, list->elements);
|
|
||||||
if (reversedList != NULL) {
|
|
||||||
for (size_t i = 0; i < list->length / 2; ++i) {
|
|
||||||
list_element_t temp = reversedList->elements[i];
|
|
||||||
reversedList->elements[i] = reversedList->elements[list->length - i - 1];
|
|
||||||
reversedList->elements[list->length - i - 1] = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return reversedList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// destroy the entire list
|
|
||||||
// list will be a dangling pointer after calling this method on it
|
|
||||||
void delete_list(list_t *list) {
|
|
||||||
free(list);
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
#ifndef LIST_OPS_H
|
|
||||||
#define LIST_OPS_H
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
typedef int list_element_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
size_t length;
|
|
||||||
list_element_t elements[];
|
|
||||||
} list_t;
|
|
||||||
|
|
||||||
// constructs a new list
|
|
||||||
list_t *new_list(size_t length, list_element_t elements[]);
|
|
||||||
|
|
||||||
// append entries to a list and return the new list
|
|
||||||
list_t *append_list(list_t *list1, list_t *list2);
|
|
||||||
|
|
||||||
// filter list returning only values that satisfy the filter function
|
|
||||||
list_t *filter_list(list_t *list, bool (*filter)(list_element_t));
|
|
||||||
|
|
||||||
// returns the length of the list
|
|
||||||
size_t length_list(list_t *list);
|
|
||||||
|
|
||||||
// return a list of elements whose values equal the list value transformed by
|
|
||||||
// the mapping function
|
|
||||||
list_t *map_list(list_t *list, list_element_t (*map)(list_element_t));
|
|
||||||
|
|
||||||
// folds (reduces) the given list from the left with a function
|
|
||||||
list_element_t foldl_list(list_t *list, list_element_t initial,
|
|
||||||
list_element_t (*foldl)(list_element_t,
|
|
||||||
list_element_t));
|
|
||||||
|
|
||||||
// folds (reduces) the given list from the right with a function
|
|
||||||
list_element_t foldr_list(list_t *list, list_element_t initial,
|
|
||||||
list_element_t (*foldr)(list_element_t,
|
|
||||||
list_element_t));
|
|
||||||
|
|
||||||
// reverse the elements of the list
|
|
||||||
list_t *reverse_list(list_t *list);
|
|
||||||
|
|
||||||
// destroy the entire list
|
|
||||||
// list will be a dangling pointer after calling this method on it
|
|
||||||
void delete_list(list_t *list);
|
|
||||||
|
|
||||||
#endif
|
|
37
cv4/makefile
37
cv4/makefile
@ -1,37 +0,0 @@
|
|||||||
### If you wish to use extra libraries (math.h for instance),
|
|
||||||
### add their flags here (-lm in our case) in the "LIBS" variable.
|
|
||||||
|
|
||||||
LIBS = -lm
|
|
||||||
|
|
||||||
###
|
|
||||||
CFLAGS = -std=c99
|
|
||||||
CFLAGS += -g
|
|
||||||
CFLAGS += -Wall
|
|
||||||
CFLAGS += -Wextra
|
|
||||||
CFLAGS += -pedantic
|
|
||||||
CFLAGS += -Werror
|
|
||||||
CFLAGS += -Wmissing-declarations
|
|
||||||
CFLAGS += -DUNITY_SUPPORT_64 -DUNITY_OUTPUT_COLOR
|
|
||||||
|
|
||||||
ASANFLAGS = -fsanitize=address
|
|
||||||
ASANFLAGS += -fno-common
|
|
||||||
ASANFLAGS += -fno-omit-frame-pointer
|
|
||||||
|
|
||||||
.PHONY: test
|
|
||||||
test: tests.out
|
|
||||||
@./tests.out
|
|
||||||
|
|
||||||
.PHONY: memcheck
|
|
||||||
memcheck: ./*.c ./*.h
|
|
||||||
@echo Compiling $@
|
|
||||||
@$(CC) $(ASANFLAGS) $(CFLAGS) test-framework/unity.c ./*.c -o memcheck.out $(LIBS)
|
|
||||||
@./memcheck.out
|
|
||||||
@echo "Memory check passed"
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
|
||||||
rm -rf *.o *.out *.out.dSYM
|
|
||||||
|
|
||||||
tests.out: ./*.c ./*.h
|
|
||||||
@echo Compiling $@
|
|
||||||
@$(CC) $(CFLAGS) test-framework/unity.c ./*.c -o tests.out $(LIBS)
|
|
File diff suppressed because it is too large
Load Diff
@ -1,661 +0,0 @@
|
|||||||
/* ==========================================
|
|
||||||
Unity Project - A Test Framework for C
|
|
||||||
Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams
|
|
||||||
[Released under MIT License. Please refer to license.txt for details]
|
|
||||||
========================================== */
|
|
||||||
|
|
||||||
#ifndef UNITY_FRAMEWORK_H
|
|
||||||
#define UNITY_FRAMEWORK_H
|
|
||||||
#define UNITY
|
|
||||||
|
|
||||||
#define UNITY_VERSION_MAJOR 2
|
|
||||||
#define UNITY_VERSION_MINOR 5
|
|
||||||
#define UNITY_VERSION_BUILD 2
|
|
||||||
#define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | (UNITY_VERSION_MINOR << 8) | UNITY_VERSION_BUILD)
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "unity_internals.h"
|
|
||||||
|
|
||||||
/*-------------------------------------------------------
|
|
||||||
* Test Setup / Teardown
|
|
||||||
*-------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* These functions are intended to be called before and after each test.
|
|
||||||
* If using unity directly, these will need to be provided for each test
|
|
||||||
* executable built. If you are using the test runner generator and/or
|
|
||||||
* Ceedling, these are optional. */
|
|
||||||
void setUp(void);
|
|
||||||
void tearDown(void);
|
|
||||||
|
|
||||||
/* These functions are intended to be called at the beginning and end of an
|
|
||||||
* entire test suite. suiteTearDown() is passed the number of tests that
|
|
||||||
* failed, and its return value becomes the exit code of main(). If using
|
|
||||||
* Unity directly, you're in charge of calling these if they are desired.
|
|
||||||
* If using Ceedling or the test runner generator, these will be called
|
|
||||||
* automatically if they exist. */
|
|
||||||
void suiteSetUp(void);
|
|
||||||
int suiteTearDown(int num_failures);
|
|
||||||
|
|
||||||
/*-------------------------------------------------------
|
|
||||||
* Test Reset and Verify
|
|
||||||
*-------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* These functions are intended to be called before during tests in order
|
|
||||||
* to support complex test loops, etc. Both are NOT built into Unity. Instead
|
|
||||||
* the test runner generator will create them. resetTest will run teardown and
|
|
||||||
* setup again, verifying any end-of-test needs between. verifyTest will only
|
|
||||||
* run the verification. */
|
|
||||||
void resetTest(void);
|
|
||||||
void verifyTest(void);
|
|
||||||
|
|
||||||
/*-------------------------------------------------------
|
|
||||||
* Configuration Options
|
|
||||||
*-------------------------------------------------------
|
|
||||||
* All options described below should be passed as a compiler flag to all files using Unity. If you must add #defines, place them BEFORE the #include above.
|
|
||||||
|
|
||||||
* Integers/longs/pointers
|
|
||||||
* - Unity attempts to automatically discover your integer sizes
|
|
||||||
* - define UNITY_EXCLUDE_STDINT_H to stop attempting to look in <stdint.h>
|
|
||||||
* - define UNITY_EXCLUDE_LIMITS_H to stop attempting to look in <limits.h>
|
|
||||||
* - If you cannot use the automatic methods above, you can force Unity by using these options:
|
|
||||||
* - define UNITY_SUPPORT_64
|
|
||||||
* - set UNITY_INT_WIDTH
|
|
||||||
* - set UNITY_LONG_WIDTH
|
|
||||||
* - set UNITY_POINTER_WIDTH
|
|
||||||
|
|
||||||
* Floats
|
|
||||||
* - define UNITY_EXCLUDE_FLOAT to disallow floating point comparisons
|
|
||||||
* - define UNITY_FLOAT_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_FLOAT
|
|
||||||
* - define UNITY_FLOAT_TYPE to specify doubles instead of single precision floats
|
|
||||||
* - define UNITY_INCLUDE_DOUBLE to allow double floating point comparisons
|
|
||||||
* - define UNITY_EXCLUDE_DOUBLE to disallow double floating point comparisons (default)
|
|
||||||
* - define UNITY_DOUBLE_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_DOUBLE
|
|
||||||
* - define UNITY_DOUBLE_TYPE to specify something other than double
|
|
||||||
* - define UNITY_EXCLUDE_FLOAT_PRINT to trim binary size, won't print floating point values in errors
|
|
||||||
|
|
||||||
* Output
|
|
||||||
* - by default, Unity prints to standard out with putchar. define UNITY_OUTPUT_CHAR(a) with a different function if desired
|
|
||||||
* - define UNITY_DIFFERENTIATE_FINAL_FAIL to print FAILED (vs. FAIL) at test end summary - for automated search for failure
|
|
||||||
|
|
||||||
* Optimization
|
|
||||||
* - by default, line numbers are stored in unsigned shorts. Define UNITY_LINE_TYPE with a different type if your files are huge
|
|
||||||
* - by default, test and failure counters are unsigned shorts. Define UNITY_COUNTER_TYPE with a different type if you want to save space or have more than 65535 Tests.
|
|
||||||
|
|
||||||
* Test Cases
|
|
||||||
* - define UNITY_SUPPORT_TEST_CASES to include the TEST_CASE macro, though really it's mostly about the runner generator script
|
|
||||||
|
|
||||||
* Parameterized Tests
|
|
||||||
* - you'll want to create a define of TEST_CASE(...) which basically evaluates to nothing
|
|
||||||
|
|
||||||
* Tests with Arguments
|
|
||||||
* - you'll want to define UNITY_USE_COMMAND_LINE_ARGS if you have the test runner passing arguments to Unity
|
|
||||||
|
|
||||||
*-------------------------------------------------------
|
|
||||||
* Basic Fail and Ignore
|
|
||||||
*-------------------------------------------------------*/
|
|
||||||
|
|
||||||
#define TEST_FAIL_MESSAGE(message) UNITY_TEST_FAIL(__LINE__, (message))
|
|
||||||
#define TEST_FAIL() UNITY_TEST_FAIL(__LINE__, NULL)
|
|
||||||
#define TEST_IGNORE_MESSAGE(message) UNITY_TEST_IGNORE(__LINE__, (message))
|
|
||||||
#define TEST_IGNORE() UNITY_TEST_IGNORE(__LINE__, NULL)
|
|
||||||
#define TEST_MESSAGE(message) UnityMessage((message), __LINE__)
|
|
||||||
#define TEST_ONLY()
|
|
||||||
#ifdef UNITY_INCLUDE_PRINT_FORMATTED
|
|
||||||
#define TEST_PRINTF(message, ...) UnityPrintF(__LINE__, (message), __VA_ARGS__)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* It is not necessary for you to call PASS. A PASS condition is assumed if nothing fails.
|
|
||||||
* This method allows you to abort a test immediately with a PASS state, ignoring the remainder of the test. */
|
|
||||||
#define TEST_PASS() TEST_ABORT()
|
|
||||||
#define TEST_PASS_MESSAGE(message) do { UnityMessage((message), __LINE__); TEST_ABORT(); } while(0)
|
|
||||||
|
|
||||||
/* This macro does nothing, but it is useful for build tools (like Ceedling) to make use of this to figure out
|
|
||||||
* which files should be linked to in order to perform a test. Use it like TEST_FILE("sandwiches.c") */
|
|
||||||
#define TEST_FILE(a)
|
|
||||||
|
|
||||||
/*-------------------------------------------------------
|
|
||||||
* Test Asserts (simple)
|
|
||||||
*-------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* Boolean */
|
|
||||||
#define TEST_ASSERT(condition) UNITY_TEST_ASSERT( (condition), __LINE__, " Expression Evaluated To FALSE")
|
|
||||||
#define TEST_ASSERT_TRUE(condition) UNITY_TEST_ASSERT( (condition), __LINE__, " Expected TRUE Was FALSE")
|
|
||||||
#define TEST_ASSERT_UNLESS(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expression Evaluated To TRUE")
|
|
||||||
#define TEST_ASSERT_FALSE(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expected FALSE Was TRUE")
|
|
||||||
#define TEST_ASSERT_NULL(pointer) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, " Expected NULL")
|
|
||||||
#define TEST_ASSERT_NOT_NULL(pointer) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, " Expected Non-NULL")
|
|
||||||
#define TEST_ASSERT_EMPTY(pointer) UNITY_TEST_ASSERT_EMPTY( (pointer), __LINE__, " Expected Empty")
|
|
||||||
#define TEST_ASSERT_NOT_EMPTY(pointer) UNITY_TEST_ASSERT_NOT_EMPTY((pointer), __LINE__, " Expected Non-Empty")
|
|
||||||
|
|
||||||
/* Integers (of all sizes) */
|
|
||||||
#define TEST_ASSERT_EQUAL_INT(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_INT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT8((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_INT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_INT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_INT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT32( (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT64( (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_size_t(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX8(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX8( (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX16(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX32(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX64(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_CHAR(expected, actual) UNITY_TEST_ASSERT_EQUAL_CHAR((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_BITS(mask, expected, actual) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_BITS_HIGH(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT)(-1), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_BITS_LOW(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT)(0), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_BIT_HIGH(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT)1 << (bit)), (UNITY_UINT)(-1), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_BIT_LOW(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT)1 << (bit)), (UNITY_UINT)(0), (actual), __LINE__, NULL)
|
|
||||||
|
|
||||||
/* Integer Not Equal To (of all sizes) */
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_size_t(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_CHAR(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_CHAR((threshold), (actual), __LINE__, NULL)
|
|
||||||
|
|
||||||
/* Integer Greater Than/ Less Than (of all sizes) */
|
|
||||||
#define TEST_ASSERT_GREATER_THAN(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_size_t(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_CHAR(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_CHAR((threshold), (actual), __LINE__, NULL)
|
|
||||||
|
|
||||||
#define TEST_ASSERT_LESS_THAN(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_size_t(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_HEX64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_CHAR(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_CHAR((threshold), (actual), __LINE__, NULL)
|
|
||||||
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_size_t(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_CHAR(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, NULL)
|
|
||||||
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_size_t(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_CHAR(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, NULL)
|
|
||||||
|
|
||||||
/* Integer Ranges (of all sizes) */
|
|
||||||
#define TEST_ASSERT_INT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_INT8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT8_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_INT16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT16_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_INT32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT32_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_INT64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT64_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_UINT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_UINT8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT8_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_UINT16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT16_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_UINT32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT32_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_UINT64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT64_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_size_t_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_HEX_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_HEX8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX8_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_HEX16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX16_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_HEX32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_HEX64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX64_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_CHAR_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_CHAR_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
|
|
||||||
/* Integer Array Ranges (of all sizes) */
|
|
||||||
#define TEST_ASSERT_INT_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_INT8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_INT16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_INT32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_INT64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_UINT64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_size_t_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_HEX_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_HEX16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_HEX32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_CHAR_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
|
|
||||||
|
|
||||||
/* Structs and Strings */
|
|
||||||
#define TEST_ASSERT_EQUAL_PTR(expected, actual) UNITY_TEST_ASSERT_EQUAL_PTR((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_STRING(expected, actual) UNITY_TEST_ASSERT_EQUAL_STRING((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len) UNITY_TEST_ASSERT_EQUAL_STRING_LEN((expected), (actual), (len), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_MEMORY(expected, actual, len) UNITY_TEST_ASSERT_EQUAL_MEMORY((expected), (actual), (len), __LINE__, NULL)
|
|
||||||
|
|
||||||
/* Arrays */
|
|
||||||
#define TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_INT16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_INT32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_size_t_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((expected), (actual), (len), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_CHAR_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_CHAR_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
|
|
||||||
/* Arrays Compared To Single Value */
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT8((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT16((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT32((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT64((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT8((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT16((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT32((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT64((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_size_t(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX8((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX16((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX64((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_PTR(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_PTR((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_STRING(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_STRING((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_MEMORY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY((expected), (actual), (len), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_CHAR(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_CHAR((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
|
|
||||||
/* Floating Point (If Enabled) */
|
|
||||||
#define TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_FLOAT_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_FLOAT(expected, actual) UNITY_TEST_ASSERT_EQUAL_FLOAT((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_FLOAT_IS_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_INF((actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_FLOAT_IS_NEG_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF((actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_FLOAT_IS_NAN(actual) UNITY_TEST_ASSERT_FLOAT_IS_NAN((actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_FLOAT_IS_DETERMINATE(actual) UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE((actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_FLOAT_IS_NOT_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF((actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF((actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_FLOAT_IS_NOT_NAN(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN((actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE((actual), __LINE__, NULL)
|
|
||||||
|
|
||||||
/* Double (If Enabled) */
|
|
||||||
#define TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_DOUBLE(expected, actual) UNITY_TEST_ASSERT_EQUAL_DOUBLE((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_DOUBLE_IS_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_INF((actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_DOUBLE_IS_NEG_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF((actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_DOUBLE_IS_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NAN((actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual) UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE((actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_DOUBLE_IS_NOT_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF((actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF((actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN((actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE((actual), __LINE__, NULL)
|
|
||||||
|
|
||||||
/* Shorthand */
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_OLD
|
|
||||||
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal")
|
|
||||||
#endif
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_INT
|
|
||||||
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
|
||||||
#endif
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_MEM
|
|
||||||
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_MEMORY((&expected), (&actual), sizeof(expected), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
|
||||||
#endif
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_RAW
|
|
||||||
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) == (actual)), __LINE__, " Expected Equal")
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal")
|
|
||||||
#endif
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_NONE
|
|
||||||
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*-------------------------------------------------------
|
|
||||||
* Test Asserts (with additional messages)
|
|
||||||
*-------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* Boolean */
|
|
||||||
#define TEST_ASSERT_MESSAGE(condition, message) UNITY_TEST_ASSERT( (condition), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_TRUE_MESSAGE(condition, message) UNITY_TEST_ASSERT( (condition), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_UNLESS_MESSAGE(condition, message) UNITY_TEST_ASSERT( !(condition), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_FALSE_MESSAGE(condition, message) UNITY_TEST_ASSERT( !(condition), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EMPTY_MESSAGE(pointer, message) UNITY_TEST_ASSERT_EMPTY( (pointer), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EMPTY_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NOT_EMPTY((pointer), __LINE__, (message))
|
|
||||||
|
|
||||||
/* Integers (of all sizes) */
|
|
||||||
#define TEST_ASSERT_EQUAL_INT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_INT8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT8((expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_INT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_INT32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_INT64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT32( (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT64( (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_size_t_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX8( (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_BITS_MESSAGE(mask, expected, actual, message) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_BITS_HIGH_MESSAGE(mask, actual, message) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(-1), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_BITS_LOW_MESSAGE(mask, actual, message) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(0), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_BIT_HIGH_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(-1), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_BIT_LOW_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_CHAR_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_CHAR((expected), (actual), __LINE__, (message))
|
|
||||||
|
|
||||||
/* Integer Not Equal To (of all sizes) */
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_CHAR((threshold), (actual), __LINE__, (message))
|
|
||||||
|
|
||||||
|
|
||||||
/* Integer Greater Than/ Less Than (of all sizes) */
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_CHAR((threshold), (actual), __LINE__, (message))
|
|
||||||
|
|
||||||
#define TEST_ASSERT_LESS_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_CHAR((threshold), (actual), __LINE__, (message))
|
|
||||||
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, (message))
|
|
||||||
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, (message))
|
|
||||||
|
|
||||||
/* Integer Ranges (of all sizes) */
|
|
||||||
#define TEST_ASSERT_INT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_INT8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT8_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_INT16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT16_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_INT32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT32_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_INT64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT64_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_UINT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_UINT8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT8_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_UINT16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT16_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_UINT32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT32_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_UINT64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT64_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_size_t_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_HEX_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_HEX8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX8_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_HEX16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX16_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_HEX32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_HEX64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX64_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_CHAR_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_CHAR_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
|
|
||||||
/* Integer Array Ranges (of all sizes) */
|
|
||||||
#define TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_INT32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_UINT32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_size_t_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_HEX_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
|
|
||||||
|
|
||||||
/* Structs and Strings */
|
|
||||||
#define TEST_ASSERT_EQUAL_PTR_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_PTR((expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_STRING((expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(expected, actual, len, message) UNITY_TEST_ASSERT_EQUAL_STRING_LEN((expected), (actual), (len), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_MEMORY_MESSAGE(expected, actual, len, message) UNITY_TEST_ASSERT_EQUAL_MEMORY((expected), (actual), (len), __LINE__, (message))
|
|
||||||
|
|
||||||
/* Arrays */
|
|
||||||
#define TEST_ASSERT_EQUAL_INT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_INT8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_INT16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_INT32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_INT64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_UINT64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_size_t_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_HEX64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_PTR_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_STRING_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_MEMORY_ARRAY_MESSAGE(expected, actual, len, num_elements, message) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((expected), (actual), (len), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_CHAR_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_CHAR_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
|
|
||||||
/* Arrays Compared To Single Value*/
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT8((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT16((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT32((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT64((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT8((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT16((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT32((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT64((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_size_t_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX8((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX16((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX64((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_PTR_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_PTR((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_STRING_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_STRING((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_MEMORY_MESSAGE(expected, actual, len, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY((expected), (actual), (len), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_CHAR_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_CHAR((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
|
|
||||||
/* Floating Point (If Enabled) */
|
|
||||||
#define TEST_ASSERT_FLOAT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_FLOAT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_FLOAT((expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_FLOAT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_FLOAT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_FLOAT_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_INF((actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_FLOAT_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF((actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_FLOAT_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NAN((actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_FLOAT_IS_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE((actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_FLOAT_IS_NOT_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF((actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_FLOAT_IS_NOT_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF((actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_FLOAT_IS_NOT_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN((actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE((actual), __LINE__, (message))
|
|
||||||
|
|
||||||
/* Double (If Enabled) */
|
|
||||||
#define TEST_ASSERT_DOUBLE_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_DOUBLE_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE((expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_DOUBLE_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_DOUBLE_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_DOUBLE_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_INF((actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_DOUBLE_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF((actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_DOUBLE_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NAN((actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_DOUBLE_IS_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE((actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_DOUBLE_IS_NOT_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF((actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF((actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_DOUBLE_IS_NOT_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN((actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE((actual), __LINE__, (message))
|
|
||||||
|
|
||||||
/* Shorthand */
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_OLD
|
|
||||||
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, (message))
|
|
||||||
#endif
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_INT
|
|
||||||
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, message)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
|
||||||
#endif
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_MEM
|
|
||||||
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_MEMORY((&expected), (&actual), sizeof(expected), __LINE__, message)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
|
||||||
#endif
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_RAW
|
|
||||||
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) == (actual)), __LINE__, message)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, message)
|
|
||||||
#endif
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_NONE
|
|
||||||
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* end of UNITY_FRAMEWORK_H */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
File diff suppressed because it is too large
Load Diff
@ -1,396 +0,0 @@
|
|||||||
#include <stdarg.h>
|
|
||||||
#include "list_ops.h"
|
|
||||||
#include "test-framework/unity.h"
|
|
||||||
|
|
||||||
static const int MAX_STRING_LEN = 100;
|
|
||||||
static list_t *list = NULL;
|
|
||||||
static list_t *list2 = NULL;
|
|
||||||
static list_t *actual = NULL;
|
|
||||||
static char *error_message = NULL;
|
|
||||||
|
|
||||||
void setUp(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void release_lists(int count, ...)
|
|
||||||
{
|
|
||||||
va_list ptr;
|
|
||||||
va_start(ptr, count);
|
|
||||||
for (int i = 0; i < count; ++i) {
|
|
||||||
list_t **list = va_arg(ptr, list_t **);
|
|
||||||
if (*list) {
|
|
||||||
free(*list);
|
|
||||||
*list = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
va_end(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tearDown(void)
|
|
||||||
{
|
|
||||||
release_lists(3, &list, &list2, &actual);
|
|
||||||
if (error_message) {
|
|
||||||
free(error_message);
|
|
||||||
error_message = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *print_elements(size_t length, list_element_t list_elements[])
|
|
||||||
{
|
|
||||||
char *array = malloc(MAX_STRING_LEN * sizeof(char));
|
|
||||||
char *ptr = array;
|
|
||||||
for (size_t i = 0; i < length; i++) {
|
|
||||||
int printed = snprintf(ptr, MAX_STRING_LEN - (ptr - array), " %d ",
|
|
||||||
(list_elements[i]));
|
|
||||||
ptr += printed;
|
|
||||||
if (ptr - array > MAX_STRING_LEN) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *create_error_message(size_t length,
|
|
||||||
list_element_t expected_elements[],
|
|
||||||
list_element_t actual_elements[])
|
|
||||||
{
|
|
||||||
char *message = malloc(MAX_STRING_LEN * sizeof(char));
|
|
||||||
char *expected_string = print_elements(length, expected_elements);
|
|
||||||
char *actual_string = print_elements(length, actual_elements);
|
|
||||||
snprintf(message, MAX_STRING_LEN, "[%s] != [%s]", expected_string,
|
|
||||||
actual_string);
|
|
||||||
free(expected_string);
|
|
||||||
free(actual_string);
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void check_lists_match(size_t expected_length,
|
|
||||||
list_element_t expected_elements[],
|
|
||||||
list_t *actual)
|
|
||||||
{
|
|
||||||
// check actual list is a valid list
|
|
||||||
TEST_ASSERT_NOT_NULL(actual);
|
|
||||||
|
|
||||||
// check lengths match
|
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(expected_length, actual->length,
|
|
||||||
"List lengths differ");
|
|
||||||
|
|
||||||
// check elements match in non-zero length list
|
|
||||||
if (expected_length) {
|
|
||||||
error_message = create_error_message(expected_length, expected_elements,
|
|
||||||
actual->elements);
|
|
||||||
TEST_ASSERT_EQUAL_MEMORY_ARRAY_MESSAGE(
|
|
||||||
expected_elements, actual->elements, sizeof(list_element_t),
|
|
||||||
expected_length, error_message);
|
|
||||||
free(error_message);
|
|
||||||
error_message = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool filter_modulo(list_element_t element)
|
|
||||||
{
|
|
||||||
return (element % 2 == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static list_element_t map_increment(list_element_t element)
|
|
||||||
{
|
|
||||||
return element + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static list_element_t fold_multiply(list_element_t element,
|
|
||||||
list_element_t accumulator)
|
|
||||||
{
|
|
||||||
return element * accumulator;
|
|
||||||
}
|
|
||||||
|
|
||||||
static list_element_t fold_add(list_element_t element,
|
|
||||||
list_element_t accumulator)
|
|
||||||
{
|
|
||||||
return element + accumulator;
|
|
||||||
}
|
|
||||||
|
|
||||||
static list_element_t fold_divide(list_element_t element,
|
|
||||||
list_element_t accumulator)
|
|
||||||
{
|
|
||||||
return (accumulator == 0) ? 0 : element / accumulator;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void call_delete_list(list_t **list)
|
|
||||||
{
|
|
||||||
delete_list(*list);
|
|
||||||
*list = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_append_empty_lists(void)
|
|
||||||
{
|
|
||||||
list = new_list(0, NULL);
|
|
||||||
list2 = new_list(0, NULL);
|
|
||||||
|
|
||||||
actual = append_list(list, list2);
|
|
||||||
check_lists_match(0, NULL, actual);
|
|
||||||
|
|
||||||
call_delete_list(&list);
|
|
||||||
call_delete_list(&list2);
|
|
||||||
call_delete_list(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_append_list_to_empty_list(void)
|
|
||||||
{
|
|
||||||
TEST_IGNORE(); // delete this line to run test
|
|
||||||
list = new_list(0, NULL);
|
|
||||||
list2 = new_list(3, (list_element_t[]){ 1, 3, 4 });
|
|
||||||
size_t expected_length = 3;
|
|
||||||
list_element_t expected_elements[] = { 1, 3, 4 };
|
|
||||||
|
|
||||||
actual = append_list(list, list2);
|
|
||||||
check_lists_match(expected_length, expected_elements, actual);
|
|
||||||
|
|
||||||
call_delete_list(&list);
|
|
||||||
call_delete_list(&list2);
|
|
||||||
call_delete_list(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_append_empty_list_to_list(void)
|
|
||||||
{
|
|
||||||
TEST_IGNORE();
|
|
||||||
list = new_list(4, (list_element_t[]){ 1, 2, 3, 4 });
|
|
||||||
list2 = new_list(0, NULL);
|
|
||||||
size_t expected_length = 4;
|
|
||||||
list_element_t expected_elements[] = { 1, 2, 3, 4 };
|
|
||||||
|
|
||||||
actual = append_list(list, list2);
|
|
||||||
check_lists_match(expected_length, expected_elements, actual);
|
|
||||||
|
|
||||||
call_delete_list(&list);
|
|
||||||
call_delete_list(&list2);
|
|
||||||
call_delete_list(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_append_non_empty_lists(void)
|
|
||||||
{
|
|
||||||
TEST_IGNORE();
|
|
||||||
list = new_list(2, (list_element_t[]){ 1, 2 });
|
|
||||||
list2 = new_list(4, (list_element_t[]){ 2, 3, 4, 5 });
|
|
||||||
size_t expected_length = 6;
|
|
||||||
list_element_t expected_elements[] = { 1, 2, 2, 3, 4, 5 };
|
|
||||||
|
|
||||||
actual = append_list(list, list2);
|
|
||||||
check_lists_match(expected_length, expected_elements, actual);
|
|
||||||
|
|
||||||
call_delete_list(&list);
|
|
||||||
call_delete_list(&list2);
|
|
||||||
call_delete_list(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_filter_empty_list(void)
|
|
||||||
{
|
|
||||||
TEST_IGNORE();
|
|
||||||
list = new_list(0, NULL);
|
|
||||||
|
|
||||||
actual = filter_list(list, filter_modulo);
|
|
||||||
check_lists_match(0, NULL, actual);
|
|
||||||
|
|
||||||
call_delete_list(&list);
|
|
||||||
call_delete_list(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_filter_non_empty_list(void)
|
|
||||||
{
|
|
||||||
TEST_IGNORE();
|
|
||||||
list = new_list(5, (list_element_t[]){ 1, 2, 3, 4, 5 });
|
|
||||||
size_t expected_length = 3;
|
|
||||||
list_element_t expected_elements[] = { 1, 3, 5 };
|
|
||||||
|
|
||||||
actual = filter_list(list, filter_modulo);
|
|
||||||
check_lists_match(expected_length, expected_elements, actual);
|
|
||||||
|
|
||||||
call_delete_list(&list);
|
|
||||||
call_delete_list(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_length_empty_list(void)
|
|
||||||
{
|
|
||||||
TEST_IGNORE();
|
|
||||||
list = new_list(0, NULL);
|
|
||||||
size_t expected = 0;
|
|
||||||
|
|
||||||
size_t actual = length_list(list);
|
|
||||||
TEST_ASSERT_EQUAL(expected, actual);
|
|
||||||
|
|
||||||
call_delete_list(&list);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_length_non_empty_list(void)
|
|
||||||
{
|
|
||||||
TEST_IGNORE();
|
|
||||||
list = new_list(4, (list_element_t[]){ 1, 2, 3, 4 });
|
|
||||||
size_t expected = 4;
|
|
||||||
|
|
||||||
size_t actual = length_list(list);
|
|
||||||
TEST_ASSERT_EQUAL(expected, actual);
|
|
||||||
|
|
||||||
call_delete_list(&list);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_map_empty_list(void)
|
|
||||||
{
|
|
||||||
TEST_IGNORE();
|
|
||||||
list = new_list(0, NULL);
|
|
||||||
|
|
||||||
actual = map_list(list, map_increment);
|
|
||||||
check_lists_match(0, NULL, actual);
|
|
||||||
|
|
||||||
call_delete_list(&list);
|
|
||||||
call_delete_list(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_map_non_empty_list(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
TEST_IGNORE();
|
|
||||||
list = new_list(4, (list_element_t[]){ 1, 3, 5, 7 });
|
|
||||||
size_t expected_length = 4;
|
|
||||||
list_element_t expected_elements[] = { 2, 4, 6, 8 };
|
|
||||||
|
|
||||||
actual = map_list(list, map_increment);
|
|
||||||
check_lists_match(expected_length, expected_elements, actual);
|
|
||||||
|
|
||||||
call_delete_list(&list);
|
|
||||||
call_delete_list(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_foldl_empty_list(void)
|
|
||||||
{
|
|
||||||
TEST_IGNORE();
|
|
||||||
list = new_list(0, NULL);
|
|
||||||
list_element_t initial = 2;
|
|
||||||
list_element_t expected = 2;
|
|
||||||
|
|
||||||
list_element_t actual = foldl_list(list, initial, fold_divide);
|
|
||||||
TEST_ASSERT_EQUAL(expected, actual);
|
|
||||||
|
|
||||||
call_delete_list(&list);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_foldl_direction_independent_function_applied_to_non_empty_list(void)
|
|
||||||
{
|
|
||||||
TEST_IGNORE();
|
|
||||||
list = new_list(4, (list_element_t[]){ 1, 2, 3, 4 });
|
|
||||||
list_element_t initial = 5;
|
|
||||||
list_element_t expected = 15;
|
|
||||||
|
|
||||||
list_element_t actual = foldl_list(list, initial, fold_add);
|
|
||||||
TEST_ASSERT_EQUAL(expected, actual);
|
|
||||||
|
|
||||||
call_delete_list(&list);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_foldl_direction_dependent_function_applied_to_non_empty_list(void)
|
|
||||||
{
|
|
||||||
TEST_IGNORE();
|
|
||||||
list = new_list(2, (list_element_t[]){ 2, 5 });
|
|
||||||
list_element_t initial = 5;
|
|
||||||
list_element_t expected = 0;
|
|
||||||
|
|
||||||
list_element_t actual = foldl_list(list, initial, fold_divide);
|
|
||||||
TEST_ASSERT_EQUAL(expected, actual);
|
|
||||||
|
|
||||||
call_delete_list(&list);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_foldr_empty_list(void)
|
|
||||||
{
|
|
||||||
TEST_IGNORE();
|
|
||||||
list = new_list(0, NULL);
|
|
||||||
list_element_t initial = 2;
|
|
||||||
list_element_t expected = 2;
|
|
||||||
|
|
||||||
list_element_t actual = foldr_list(list, initial, fold_multiply);
|
|
||||||
TEST_ASSERT_EQUAL(expected, actual);
|
|
||||||
|
|
||||||
call_delete_list(&list);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_foldr_direction_independent_function_applied_to_non_empty_list(void)
|
|
||||||
{
|
|
||||||
TEST_IGNORE();
|
|
||||||
list = new_list(4, (list_element_t[]){ 1, 2, 3, 4 });
|
|
||||||
list_element_t initial = 5;
|
|
||||||
list_element_t expected = 15;
|
|
||||||
|
|
||||||
list_element_t actual = foldr_list(list, initial, fold_add);
|
|
||||||
TEST_ASSERT_EQUAL(expected, actual);
|
|
||||||
|
|
||||||
call_delete_list(&list);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_foldr_direction_dependent_function_applied_to_non_empty_list(void)
|
|
||||||
{
|
|
||||||
TEST_IGNORE();
|
|
||||||
list = new_list(2, (list_element_t[]){ 2, 5 });
|
|
||||||
list_element_t initial = 5;
|
|
||||||
list_element_t expected = 2;
|
|
||||||
|
|
||||||
list_element_t actual = foldr_list(list, initial, fold_divide);
|
|
||||||
TEST_ASSERT_EQUAL(expected, actual);
|
|
||||||
|
|
||||||
call_delete_list(&list);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_reverse_empty_list(void)
|
|
||||||
{
|
|
||||||
TEST_IGNORE();
|
|
||||||
list = new_list(0, NULL);
|
|
||||||
|
|
||||||
actual = reverse_list(list);
|
|
||||||
check_lists_match(0, NULL, actual);
|
|
||||||
|
|
||||||
call_delete_list(&list);
|
|
||||||
call_delete_list(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_reverse_non_empty_list(void)
|
|
||||||
{
|
|
||||||
TEST_IGNORE();
|
|
||||||
list = new_list(4, (list_element_t[]){ 1, 3, 5, 7 });
|
|
||||||
size_t expected_length = 4;
|
|
||||||
list_element_t expected_elements[] = { 7, 5, 3, 1 };
|
|
||||||
|
|
||||||
actual = reverse_list(list);
|
|
||||||
check_lists_match(expected_length, expected_elements, actual);
|
|
||||||
|
|
||||||
call_delete_list(&list);
|
|
||||||
call_delete_list(&actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
UNITY_BEGIN();
|
|
||||||
|
|
||||||
RUN_TEST(test_append_empty_lists);
|
|
||||||
RUN_TEST(test_append_list_to_empty_list);
|
|
||||||
RUN_TEST(test_append_empty_list_to_list);
|
|
||||||
RUN_TEST(test_append_non_empty_lists);
|
|
||||||
RUN_TEST(test_filter_empty_list);
|
|
||||||
RUN_TEST(test_filter_non_empty_list);
|
|
||||||
RUN_TEST(test_length_empty_list);
|
|
||||||
RUN_TEST(test_length_non_empty_list);
|
|
||||||
RUN_TEST(test_map_empty_list);
|
|
||||||
RUN_TEST(test_map_non_empty_list);
|
|
||||||
RUN_TEST(test_foldl_empty_list);
|
|
||||||
RUN_TEST(
|
|
||||||
test_foldl_direction_independent_function_applied_to_non_empty_list);
|
|
||||||
RUN_TEST(test_foldl_direction_dependent_function_applied_to_non_empty_list);
|
|
||||||
RUN_TEST(test_foldr_empty_list);
|
|
||||||
RUN_TEST(
|
|
||||||
test_foldr_direction_independent_function_applied_to_non_empty_list);
|
|
||||||
RUN_TEST(test_foldr_direction_dependent_function_applied_to_non_empty_list);
|
|
||||||
RUN_TEST(test_reverse_empty_list);
|
|
||||||
RUN_TEST(test_reverse_non_empty_list);
|
|
||||||
|
|
||||||
return UNITY_END();
|
|
||||||
}
|
|
@ -1,93 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define SIZE 100
|
|
||||||
|
|
||||||
struct student {
|
|
||||||
char name[SIZE];
|
|
||||||
int votes;
|
|
||||||
};
|
|
||||||
|
|
||||||
// comparison function for sorting students
|
|
||||||
int compare(const void *a, const void *b) {
|
|
||||||
struct student *student_a = (struct student *) a;
|
|
||||||
struct student *student_b = (struct student *) b;
|
|
||||||
|
|
||||||
if (student_a->votes > student_b->votes) {
|
|
||||||
return -1;
|
|
||||||
} else if (student_a->votes < student_b->votes) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
// if votes are the same, compare names
|
|
||||||
return strcmp(student_a->name, student_b->name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
struct student students[SIZE];
|
|
||||||
int size = 0;
|
|
||||||
int successful_lines = 0; // Counter for successful lines read
|
|
||||||
|
|
||||||
// read student data from standard input
|
|
||||||
while (1) {
|
|
||||||
char line[SIZE];
|
|
||||||
memset(line, 0, SIZE);
|
|
||||||
char *r = fgets(line, SIZE, stdin);
|
|
||||||
|
|
||||||
// check if the line is empty
|
|
||||||
if (r == NULL || (r[0] == '\n' && strlen(r) == 1)) {
|
|
||||||
// end of input
|
|
||||||
if (successful_lines == 0) {
|
|
||||||
printf("Nepodarilo nacitat nic\n");
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// parse the string and extract number of votes and student name
|
|
||||||
int votes;
|
|
||||||
char name[SIZE];
|
|
||||||
if (sscanf(line, "%d %[^\n]", &votes, name) != 2) {
|
|
||||||
if (successful_lines >= 1){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
printf("Nepodarilo nacitat nic\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
successful_lines++;
|
|
||||||
|
|
||||||
// check if this student already exists
|
|
||||||
int found = 0;
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
if (strcmp(students[i].name, name) == 0) {
|
|
||||||
// add votes to existing student
|
|
||||||
students[i].votes += votes;
|
|
||||||
found = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the student was not found, add a new student
|
|
||||||
if (!found) {
|
|
||||||
strcpy(students[size].name, name);
|
|
||||||
students[size].votes = votes;
|
|
||||||
size++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// sort students based on their votes
|
|
||||||
qsort(students, size, sizeof(struct student), compare);
|
|
||||||
|
|
||||||
// print the results
|
|
||||||
printf("Vysledky:\n");
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
printf("%d %s\n", students[i].votes, students[i].name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
58
cv9/snake.c
58
cv9/snake.c
@ -1,58 +0,0 @@
|
|||||||
#include "snake.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
struct snake* add_snake(struct snake* snake,int x,int y){
|
|
||||||
struct snake* head = calloc(1,sizeof(struct snake));
|
|
||||||
head->x = x;
|
|
||||||
head->y = y;
|
|
||||||
head->next = snake;
|
|
||||||
return head;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct snake* remove_snake(struct snake* snake) {
|
|
||||||
if (snake == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (snake->next == NULL) {
|
|
||||||
free(snake);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct snake* current = snake;
|
|
||||||
while (current->next->next != NULL) {
|
|
||||||
current = current->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(current->next);
|
|
||||||
current->next = NULL;
|
|
||||||
|
|
||||||
return snake;
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_snake(struct snake* sn) {
|
|
||||||
struct snake* current = sn;
|
|
||||||
struct snake* next;
|
|
||||||
|
|
||||||
while (current!= NULL) {
|
|
||||||
next = current->next;
|
|
||||||
free(current);
|
|
||||||
current = next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int is_snake(struct snake* snake,int x,int y){
|
|
||||||
while (snake != NULL) {
|
|
||||||
if (snake->x == x && snake->y == y) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
snake = snake->next;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int step_state(struct state* st){
|
|
||||||
int nx = (st->snake->x + st->sx);
|
|
||||||
int ny = (st->snake->y + st->sy);
|
|
||||||
return END_CONTINUE;
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
CFLAGS=-std=c99 -Wall -g
|
|
||||||
|
|
||||||
all: game
|
|
||||||
|
|
||||||
%.o: %.c
|
|
||||||
gcc $(CFLAGS) -c $< -o $@
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm *.o
|
|
||||||
rm game
|
|
||||||
|
|
||||||
game: main.o world.o snake.o
|
|
||||||
gcc -rdynamic -g main.o world.o snake.o -lcurses -lm -o game
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
|||||||
# Snake Master
|
|
||||||
|
|
||||||
Implement Snake game.
|
|
||||||
|
|
||||||
Make the game to pass the automatic tests and make the game to be nice.
|
|
||||||
|
|
||||||
## Files
|
|
||||||
|
|
||||||
Please do not change file names.
|
|
||||||
|
|
||||||
- `snake.h`: you implementation should follow this header.
|
|
||||||
- `snake.c`: implemement the game according to the documentation in header file in this file to pass automatic tests.
|
|
||||||
- `Makefile`: rules to build the game.
|
|
||||||
- `main.c`: trivial main function that runs the game, modify this file to change the appereance of the game and the initial state.
|
|
||||||
- `world.c`: world game loop and ASCII graphics library (do not change).
|
|
||||||
- `world.h`: world library interface (do not change).
|
|
110
cv9/snake/main.c
110
cv9/snake/main.c
@ -1,110 +0,0 @@
|
|||||||
#include "world.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <curses.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "snake.h"
|
|
||||||
// This file contains functions for drawing the the game and changing the state
|
|
||||||
|
|
||||||
// Start is called one in the beginning
|
|
||||||
void* init_game(){
|
|
||||||
// Allocate memory for the state
|
|
||||||
struct state* st = calloc(1,(sizeof(struct state)));
|
|
||||||
return st;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The first event
|
|
||||||
// Initialize game state
|
|
||||||
// - borders
|
|
||||||
// - snake position
|
|
||||||
// - food position
|
|
||||||
void init_snake(struct event* world, struct state* st){
|
|
||||||
int cy = world->height/2;
|
|
||||||
int cx = world->width/2 - 5;
|
|
||||||
for (int i = 0; i < 5; i++){
|
|
||||||
st->snake = add_snake(st->snake,cx + i ,cy);
|
|
||||||
}
|
|
||||||
|
|
||||||
int h = world->height;
|
|
||||||
int w = world->width;
|
|
||||||
for (int i = 0; i < 5; i++){
|
|
||||||
st->foodx[i] = rand() % w;
|
|
||||||
st->foody[i] = rand() % h;
|
|
||||||
}
|
|
||||||
// Initial game vector
|
|
||||||
st->sx = 1;
|
|
||||||
st->sy = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step is called in a loop once in interval.
|
|
||||||
// It should modify the state and draw it.
|
|
||||||
int world_event(struct event* w,void* game){
|
|
||||||
// Get state pointer
|
|
||||||
struct state* st = game;
|
|
||||||
if (w->type == EVENT_START){
|
|
||||||
// Called on beginning
|
|
||||||
init_snake(w,st);
|
|
||||||
}
|
|
||||||
// Called on key press
|
|
||||||
else if (w->type == EVENT_KEY){
|
|
||||||
int key = w->key;
|
|
||||||
// Modifies vector of snake movement
|
|
||||||
if (key == KEY_RIGHT){
|
|
||||||
st->sx = 1;
|
|
||||||
st->sy = 0;
|
|
||||||
}
|
|
||||||
else if (key == KEY_LEFT){
|
|
||||||
st->sx = -1;
|
|
||||||
st->sy = 0;
|
|
||||||
}
|
|
||||||
else if (key == KEY_DOWN){
|
|
||||||
st->sx = 0;
|
|
||||||
st->sy = 1;
|
|
||||||
}
|
|
||||||
else if (key == KEY_UP){
|
|
||||||
st->sx = 0;
|
|
||||||
st->sy = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Called on esc key
|
|
||||||
else if (w->type == EVENT_ESC){
|
|
||||||
// Non zero means finish the loop and stop the game.
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
// Called on interval timeout
|
|
||||||
else if (w->type == EVENT_TIMEOUT){
|
|
||||||
clear_screen();
|
|
||||||
// Copy screen size
|
|
||||||
st->width = w->width;
|
|
||||||
st->height = w->height;
|
|
||||||
// Change game state
|
|
||||||
int r = step_state(st);
|
|
||||||
char ms[200];
|
|
||||||
sprintf(ms,"r %d\n",r);
|
|
||||||
set_message(ms,9,9);
|
|
||||||
// Draw snake
|
|
||||||
struct snake* sn = st->snake;
|
|
||||||
while (sn != NULL){
|
|
||||||
set_cell('x',sn->x,sn->y);
|
|
||||||
sn = sn->next;
|
|
||||||
}
|
|
||||||
// Draw food
|
|
||||||
for (int i = 0 ; i < FOOD_COUNT; i++){
|
|
||||||
if (st->foodx[i] >= 0 && st->foody[i] >= 0){
|
|
||||||
set_cell('*',st->foodx[i],st->foody[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Stop the game
|
|
||||||
if (r){
|
|
||||||
char message[] = "Koniec";
|
|
||||||
set_message(message,10,10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv){
|
|
||||||
start_world(init_game,world_event,free);
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
#include "snake.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
struct snake* add_snake(struct snake* snake,int x,int y){
|
|
||||||
struct snake* head = calloc(1,sizeof(struct snake));
|
|
||||||
head->x = x;
|
|
||||||
head->y = y;
|
|
||||||
head->next = snake;
|
|
||||||
return head;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct snake* remove_snake(struct snake* snake) {
|
|
||||||
if (snake == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (snake->next == NULL) {
|
|
||||||
free(snake);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct snake* current = snake;
|
|
||||||
while (current->next->next != NULL) {
|
|
||||||
current = current->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(current->next);
|
|
||||||
current->next = NULL;
|
|
||||||
|
|
||||||
return snake;
|
|
||||||
}
|
|
||||||
|
|
||||||
void free_snake(struct snake* sn) {
|
|
||||||
struct snake* current = sn;
|
|
||||||
struct snake* next;
|
|
||||||
|
|
||||||
while (current!= NULL) {
|
|
||||||
next = current->next;
|
|
||||||
free(current);
|
|
||||||
current = next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int is_snake(struct snake* snake,int x,int y){
|
|
||||||
while (snake != NULL) {
|
|
||||||
if (snake->x == x && snake->y == y) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
snake = snake->next;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int step_state(struct state* st){
|
|
||||||
int nx = (st->snake->x + st->sx);
|
|
||||||
int ny = (st->snake->y + st->sy);
|
|
||||||
return END_CONTINUE;
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
#ifndef snake_h_INCLUDED
|
|
||||||
#define snake_h_INCLUDED
|
|
||||||
|
|
||||||
// Number of food items on the plane
|
|
||||||
#define FOOD_COUNT 5
|
|
||||||
|
|
||||||
/**
|
|
||||||
* One part of the snake;
|
|
||||||
*
|
|
||||||
* The snake is a linked list;
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct snake {
|
|
||||||
// x position of the snake part
|
|
||||||
int x;
|
|
||||||
// y position of the snake part
|
|
||||||
int y;
|
|
||||||
// Pointer to the next snake part.
|
|
||||||
// The last part of the snake has NULL pointer to the next part.
|
|
||||||
struct snake* next;
|
|
||||||
};
|
|
||||||
|
|
||||||
// End game reason constants, return value of step_state
|
|
||||||
enum endgame {
|
|
||||||
// Continue the game
|
|
||||||
END_CONTINUE = 0,
|
|
||||||
// Snake hit a wall
|
|
||||||
END_WALL,
|
|
||||||
// Snake hit itself
|
|
||||||
END_SNAKE,
|
|
||||||
// No food left
|
|
||||||
END_FOOD,
|
|
||||||
// Other reason to end
|
|
||||||
END_USER
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* State of the game.
|
|
||||||
*
|
|
||||||
* The state consists of the snake, its speed and food on the plane.
|
|
||||||
*
|
|
||||||
* The snake is a linked list of snake parts.
|
|
||||||
*
|
|
||||||
* Speed vector is a vector added to the last head position to create a new head.
|
|
||||||
*
|
|
||||||
* Food are points on the plane. Food with negative coordinates meads food is already eaten.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct state {
|
|
||||||
// Snake as a linked list
|
|
||||||
struct snake* snake;
|
|
||||||
// X of the food positions
|
|
||||||
int foodx[FOOD_COUNT];
|
|
||||||
// Y of the food positions
|
|
||||||
int foody[FOOD_COUNT];
|
|
||||||
int sx;
|
|
||||||
int sy;
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a new snake part with given position. The new snake part becomes the new head.
|
|
||||||
*
|
|
||||||
* @param head of the snake.
|
|
||||||
* @param x coordinate of the new head;
|
|
||||||
* @param y coordinate of the new head.
|
|
||||||
* @return new head of the snake.
|
|
||||||
*/
|
|
||||||
struct snake* add_snake(struct snake* snake,int x,int y);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove the last snake part.
|
|
||||||
* The last snake part should always have NULL next pointer.
|
|
||||||
*
|
|
||||||
* @param head of the snake.
|
|
||||||
* @return new head of the snake.
|
|
||||||
*/
|
|
||||||
struct snake* remove_snake(struct snake* snake);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds out if given coordinates are part of the snake.
|
|
||||||
* @param snake
|
|
||||||
* @param x coordinate to search in snake
|
|
||||||
* @param y coordinate to search in snake
|
|
||||||
* @return True, if there is a snake part with coordinates x,y. False otherwise
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
int is_snake(struct snake* snake,int x, int y);
|
|
||||||
/**
|
|
||||||
* Remove and free each snake part;
|
|
||||||
* @param head of the snake.
|
|
||||||
*/
|
|
||||||
void free_snake(struct snake* sn);
|
|
||||||
/**
|
|
||||||
* Change game state.
|
|
||||||
*
|
|
||||||
* The function shoud calculate new posision of the snake head
|
|
||||||
* from the current position and speed vector.
|
|
||||||
* Then it should modify snake parst or food coordinates according to the rules:
|
|
||||||
*
|
|
||||||
* - If the new position is on the snake, end the game, return END_SNAKE.
|
|
||||||
* - If the new position is on the food, mark food as eaten
|
|
||||||
* (set its coordinates to -1) and add new snake part on the position of the food. If there is no food left, return END_FOOD. else return END_CONTINUE.
|
|
||||||
* - If the new position is on the plane, add new snake part on the new position and remove the last part of the snake, return END_CONTINUE.
|
|
||||||
*
|
|
||||||
* @param current state of the game
|
|
||||||
* @return reason to end the game according to enum endgame.
|
|
||||||
*/
|
|
||||||
int step_state(struct state* state);
|
|
||||||
|
|
||||||
|
|
||||||
#endif // snake_h_INCLUDED
|
|
||||||
|
|
@ -1,198 +0,0 @@
|
|||||||
#include "world.h"
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
int TIMEOUT;
|
|
||||||
|
|
||||||
void abort_game(const char* message){
|
|
||||||
endwin();
|
|
||||||
puts(message);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void check_bounds(const char* source,int x, int y){
|
|
||||||
char msg[200];
|
|
||||||
if (x < 0 || x >= COLS){
|
|
||||||
sprintf(msg,"%s:: width %d is out of bounds (0,%d)",source,x,COLS);
|
|
||||||
abort_game(msg);
|
|
||||||
}
|
|
||||||
if (y < 0 || y >= LINES){
|
|
||||||
sprintf(msg,"%s:: height %d is out of bounds (0,%d)",source,y,LINES);
|
|
||||||
abort_game(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear_screen(){
|
|
||||||
// Clear screen
|
|
||||||
mvaddch(0,0,' ');
|
|
||||||
int screenchars = LINES*COLS;
|
|
||||||
for (int j = 1; j < screenchars;j++ ){
|
|
||||||
addch(' ');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void game_speed(int value){
|
|
||||||
if (value < 0){
|
|
||||||
abort_game("world_seed:: cannot be negative\n");
|
|
||||||
}
|
|
||||||
TIMEOUT =value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_message(const char* message,int x,int y) {
|
|
||||||
int l = strlen(message);
|
|
||||||
for (int i = 0; i < l; i++){
|
|
||||||
check_bounds("set_message",x+i,y);
|
|
||||||
set_cell(message[i],x+i,y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void assert_message(int event,const char* message){
|
|
||||||
if (event == 0){
|
|
||||||
abort_game(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void set_cell(int character,int x,int y) {
|
|
||||||
check_bounds("set_cell",x,y);
|
|
||||||
set_color_cell(character,x,y,COLOR_WHITE,COLOR_BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_color_cell(int character,int x,int y,short front_color,short back_color){
|
|
||||||
check_bounds("set_color_cell",x,y);
|
|
||||||
if (has_colors()){
|
|
||||||
int pair = COLOR_COUNT * front_color + back_color;
|
|
||||||
attron(COLOR_PAIR(pair));
|
|
||||||
mvaddch(y,x,character);
|
|
||||||
attroff(COLOR_PAIR(pair));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
mvaddch(y,x,character);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int start_world(void* (*init_game)(),int (*world_event)(struct event* event,void* game),void (*destroy_game)(void*)){
|
|
||||||
srand(time(NULL));
|
|
||||||
int r = 1;
|
|
||||||
// Speed global variable
|
|
||||||
TIMEOUT = 100;
|
|
||||||
if (initscr() == NULL){
|
|
||||||
// TODO Which Error?
|
|
||||||
puts("Curses Error.");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
noecho(); // Nevypisuj vstup na obrazovku
|
|
||||||
cbreak(); // Zabudni starý vstup
|
|
||||||
nodelay(stdscr,TRUE); // Nečakaj na stlačenie
|
|
||||||
keypad(stdscr,TRUE); // Aktivuje šípky
|
|
||||||
curs_set(FALSE); // Neviditeľný kurzor
|
|
||||||
/* Get all the mouse events */
|
|
||||||
mousemask(ALL_MOUSE_EVENTS, NULL);
|
|
||||||
MEVENT mouse_event;
|
|
||||||
if (has_colors()){ // Zistenie či terminál podporuje farby
|
|
||||||
start_color();
|
|
||||||
for (int i = 0; i < COLOR_COUNT;i++){
|
|
||||||
for (int j = 0; j < COLOR_COUNT;j++){
|
|
||||||
init_pair(i * COLOR_COUNT + j, i,j);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
puts("No colors!\n");
|
|
||||||
}
|
|
||||||
void* game = NULL;
|
|
||||||
if (init_game != NULL){
|
|
||||||
game = init_game();
|
|
||||||
assert_message(game != NULL,"init_game:: should return non null pointer");
|
|
||||||
}
|
|
||||||
timeout(TIMEOUT);
|
|
||||||
// Initial step
|
|
||||||
struct event event;
|
|
||||||
memset(&event,0,sizeof(struct event));
|
|
||||||
event.height = LINES;
|
|
||||||
event.width = COLS;
|
|
||||||
event.type = EVENT_START;
|
|
||||||
clock_t start_time = clock();
|
|
||||||
clock_t last_timeout = start_time;
|
|
||||||
clock_t next_timeout = last_timeout + TIMEOUT;
|
|
||||||
event.time_ms = start_time;
|
|
||||||
// Start event
|
|
||||||
r = world_event(&event,game);
|
|
||||||
refresh();
|
|
||||||
while (!r) {
|
|
||||||
memset(&event,0,sizeof(struct event));
|
|
||||||
event.height = LINES;
|
|
||||||
event.width = COLS;
|
|
||||||
event.key = getch();
|
|
||||||
// No key was pressed
|
|
||||||
if (event.key == ERR){
|
|
||||||
event.type = EVENT_TIMEOUT;
|
|
||||||
last_timeout = clock();
|
|
||||||
next_timeout = last_timeout + TIMEOUT;
|
|
||||||
}
|
|
||||||
// Mouse event
|
|
||||||
else if (event.key == KEY_MOUSE ){
|
|
||||||
event.type = EVENT_MOUSE;
|
|
||||||
if(getmouse(&mouse_event) == OK){
|
|
||||||
event.mouse_x = mouse_event.x;
|
|
||||||
event.mouse_y = mouse_event.y;
|
|
||||||
if(mouse_event.bstate & BUTTON1_PRESSED){
|
|
||||||
event.mouse_left = 1;
|
|
||||||
}
|
|
||||||
if(mouse_event.bstate & BUTTON2_PRESSED){
|
|
||||||
event.mouse_middle = 1;
|
|
||||||
}
|
|
||||||
if(mouse_event.bstate & BUTTON3_PRESSED){
|
|
||||||
event.mouse_right = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (event.key == KEY_RESIZE) {
|
|
||||||
event.type = EVENT_RESIZE;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
event.type = EVENT_KEY;
|
|
||||||
if (event.key == 27){
|
|
||||||
int k = getch();
|
|
||||||
if (k == -1){
|
|
||||||
// Esc Was pressed
|
|
||||||
event.type = EVENT_ESC;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Alt was pressed
|
|
||||||
event.key = k;
|
|
||||||
event.alt_key = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Draw new world
|
|
||||||
event.time_ms = clock();
|
|
||||||
r = world_event(&event,game);
|
|
||||||
refresh();
|
|
||||||
event.time_ms = clock();
|
|
||||||
// set new timeout
|
|
||||||
int nt = next_timeout - event.time_ms;
|
|
||||||
//printf("%d\n",nt);
|
|
||||||
if (nt > 0){
|
|
||||||
timeout(nt);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
timeout(TIMEOUT);
|
|
||||||
next_timeout = event.time_ms + TIMEOUT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
memset(&event,0,sizeof(struct event));
|
|
||||||
event.height = LINES;
|
|
||||||
event.width = COLS;
|
|
||||||
event.type = EVENT_END;
|
|
||||||
event.time_ms = clock();
|
|
||||||
world_event(&event,game);
|
|
||||||
if (destroy_game != NULL){
|
|
||||||
destroy_game(game);
|
|
||||||
}
|
|
||||||
endwin();
|
|
||||||
return r;
|
|
||||||
};
|
|
@ -1,122 +0,0 @@
|
|||||||
#ifndef _WORLD_H_
|
|
||||||
#define _WORLD_H_
|
|
||||||
|
|
||||||
#include <curses.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* World represented as a rectangular matrix of colorful characters.
|
|
||||||
*
|
|
||||||
* Point [0,0] is displayed the upper left corner of the screen.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum event_type {
|
|
||||||
EVENT_START,
|
|
||||||
EVENT_TIMEOUT,
|
|
||||||
EVENT_KEY,
|
|
||||||
EVENT_MOUSE,
|
|
||||||
EVENT_RESIZE,
|
|
||||||
EVENT_ESC,
|
|
||||||
EVENT_END,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct event {
|
|
||||||
/**
|
|
||||||
* Last width of the screen.
|
|
||||||
*/
|
|
||||||
int width;
|
|
||||||
/**
|
|
||||||
* Last height of the screen.
|
|
||||||
*/
|
|
||||||
int height;
|
|
||||||
/**
|
|
||||||
* Last pressed key or Curses event.
|
|
||||||
*
|
|
||||||
* Special event values:
|
|
||||||
* ERR if timeout,
|
|
||||||
* KEY_RESIZE if screen resize
|
|
||||||
* KEY_EVENT, other event,
|
|
||||||
* KEY_MOUSE, mouse clicked
|
|
||||||
*
|
|
||||||
* Key values:
|
|
||||||
*
|
|
||||||
* ' ' Space
|
|
||||||
* KEY_DOWN Arrow down
|
|
||||||
* KEY_UP Arrow up
|
|
||||||
* KEY_LEFT Arrow left
|
|
||||||
* KEY_RIGHT Arrow right
|
|
||||||
* KEY_A1 Upper left of keypad
|
|
||||||
* KEY_A3 Upper right of keypad
|
|
||||||
* KEY_B2 Center of keypad
|
|
||||||
* KEY_C1 Lower left of keypad
|
|
||||||
* KEY_C3 Lower right of keypad
|
|
||||||
*
|
|
||||||
* KEY_ENTER
|
|
||||||
* KEY_BACKSPACE
|
|
||||||
*/
|
|
||||||
int key;
|
|
||||||
int alt_key;
|
|
||||||
enum event_type type;
|
|
||||||
int mouse_x;
|
|
||||||
int mouse_y;
|
|
||||||
int mouse_left;
|
|
||||||
int mouse_right;
|
|
||||||
int mouse_middle;
|
|
||||||
long int time_ms;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets cell to a state.
|
|
||||||
* @param event
|
|
||||||
* @param x coordinate of cell
|
|
||||||
* @param y coordinate of cell
|
|
||||||
* @param new state of the cell
|
|
||||||
*/
|
|
||||||
void set_cell(int character,int x,int y);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* COLOR_BLACK 0
|
|
||||||
* COLOR_RED 1
|
|
||||||
* COLOR_GREEN 2
|
|
||||||
* COLOR_YELLOW 3
|
|
||||||
* COLOR_BLUE 4
|
|
||||||
* COLOR_MAGENTA 5
|
|
||||||
* COLOR_CYAN 6
|
|
||||||
* COLOR_WHITE 7
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define COLOR_COUNT 8
|
|
||||||
|
|
||||||
void set_color_cell(int character,int x,int y,short front_color,short back_color);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param event
|
|
||||||
* @param number of commandline arguments
|
|
||||||
* @param init_world
|
|
||||||
* @param destroy_world
|
|
||||||
*
|
|
||||||
* void init_world(struct event* w);
|
|
||||||
* Initializes user state.
|
|
||||||
* Free user state.
|
|
||||||
* @param event
|
|
||||||
*/
|
|
||||||
|
|
||||||
int start_world(void* (*init_game)(),int (*world_event)(struct event* event,void* game),void (*destroy_game)(void* game));
|
|
||||||
/**
|
|
||||||
* Set timeout interval in miliseconds
|
|
||||||
*/
|
|
||||||
void game_speed(int value);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Prints a message in screen on a position x,y
|
|
||||||
*/
|
|
||||||
|
|
||||||
void set_message(const char* message,int x,int y);
|
|
||||||
/*
|
|
||||||
* Clears screen
|
|
||||||
*/
|
|
||||||
void clear_screen();
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue
Block a user