Compare commits
351 Commits
ad8f6f8093
...
master
Author | SHA1 | Date | |
---|---|---|---|
995af98378 | |||
04c0ba0717 | |||
2aee6b72f0 | |||
65f1c89f27 | |||
bcf92ad070 | |||
a2f279f2e3 | |||
a171e83985 | |||
8876568a45 | |||
e58d893b96 | |||
ecccc275dc | |||
e24567e7ff | |||
f7d3b9a17e | |||
c41cfff2f5 | |||
bb0777b808 | |||
0f1648868d | |||
d0a41edb74 | |||
44131bdffb | |||
19f7d1fe4c | |||
8696372af4 | |||
a8733cfb24 | |||
bfa4d74cc2 | |||
360cce8497 | |||
52bd69853a | |||
48626506a9 | |||
fca69bf590 | |||
84019f597a | |||
45ef9682bb | |||
004c383792 | |||
05094126c3 | |||
275e0c10d1 | |||
abbbb56cf0 | |||
46c39bd603 | |||
48511b4cc8 | |||
d97efb1f8e | |||
4c61369996 | |||
bbd3453d97 | |||
0c6b56eb39 | |||
6083688b7e | |||
c5a533ebc2 | |||
52ce942162 | |||
ed42221d74 | |||
a2e49258b7 | |||
a56e7176ad | |||
68af96e75f | |||
78ce6b4670 | |||
7760084e5a | |||
3ed02a3922 | |||
24404e1283 | |||
78a5063753 | |||
60e9f19220 | |||
c81050d011 | |||
314ce71c49 | |||
0f678a08bc | |||
131968a488 | |||
107d2b702a | |||
bb61811d78 | |||
fe12ce5b37 | |||
7936ed630f | |||
d8ba05a4bf | |||
bde6cd82c6 | |||
61fef6bdeb | |||
a976bea8f5 | |||
745c70843a | |||
1b2674b560 | |||
ac50e1467a | |||
29ca99a838 | |||
212c9690a2 | |||
549752d5ca | |||
9cef985af2 | |||
b5a6d7ece8 | |||
7576de98d7 | |||
ebd2341fdf | |||
deb63e4614 | |||
2d6971997a | |||
77eea37bb6 | |||
d48b60a0fb | |||
b3f28e8016 | |||
81ca9d6d44 | |||
525ad77cc3 | |||
6527362089 | |||
286056678a | |||
9fdb2f3d35 | |||
415b874983 | |||
6c24ae9803 | |||
f06f7126b3 | |||
08fef112f0 | |||
5b8ab43104 | |||
23dc469d67 | |||
06701bbaee | |||
37b488a493 | |||
d9f4958390 | |||
fd6728dca9 | |||
c84eed26e6 | |||
c430a567d7 | |||
2484f0f10d | |||
6df932dde0 | |||
2dd1308057 | |||
3705b17f77 | |||
42acfb719a | |||
4203df9d14 | |||
157e14f370 | |||
3183d86052 | |||
1c66d96c82 | |||
70ce17da57 | |||
134344fe10 | |||
d9ee7802d1 | |||
bf02cedc37 | |||
541b4c92fa | |||
87f8055ada | |||
67dad58059 | |||
25fd4de705 | |||
7d46dd0253 | |||
5685c0e1ad | |||
6874137ac4 | |||
3b4e295c1e | |||
bae377a353 | |||
33387e35b1 | |||
9df41d91f7 | |||
2d1dead1b9 | |||
cc5cf12df7 | |||
50f4be2f43 | |||
f458f07805 | |||
a4f6ef7cd2 | |||
50d70aa5de | |||
f34a09b2b6 | |||
3842dfd920 | |||
3765a6ef48 | |||
4d6b5938c9 | |||
8e02dfdaf5 | |||
9f09c56775 | |||
01ea5cc510 | |||
9bb83fabba | |||
f3cfad99f8 | |||
6343d2b6ab | |||
be69143eec | |||
a243f41ade | |||
e1caca1f23 | |||
bc679d629c | |||
dc81195d36 | |||
2af7bc6708 | |||
71ce33da73 | |||
272be6c4b2 | |||
a7e68d397f | |||
f4b893568a | |||
3cc550a97b | |||
ddb74790ad | |||
3ea86f6735 | |||
41c80d8829 | |||
373fd7fbeb | |||
05e3c06320 | |||
1937637125 | |||
f23cadc47a | |||
e8c5562217 | |||
3c8d18c1d0 | |||
d091201320 | |||
63d0ca3727 | |||
c12528480b | |||
c1417f0744 | |||
fcac30a233 | |||
b721c84406 | |||
fbd20929dd | |||
b48b1f925d | |||
00c0b044b6 | |||
b07dd7c0a0 | |||
ae1b4851e9 | |||
a339ad8387 | |||
fa0f26fda1 | |||
863b933c07 | |||
f3cbe0dccf | |||
24629b5422 | |||
851703535e | |||
7a9d54c8c9 | |||
2c59b0295e | |||
11340969ad | |||
9927d7645b | |||
98369fd5cf | |||
4d5fe17da0 | |||
2e3044609b | |||
ac2453328d | |||
ba9ddade4f | |||
e51eb9632c | |||
9686ff02d0 | |||
2ba582a802 | |||
0d86eb7020 | |||
367d68de43 | |||
bdfbea9a90 | |||
da83f98e46 | |||
80a32abf09 | |||
a2b7fa9c8e | |||
1d489bff98 | |||
b32d54791f | |||
8a9a37a2a6 | |||
d19df926cb | |||
2c00dc1d86 | |||
d7de3a0eb3 | |||
a0ccc0b00a | |||
fca78a4887 | |||
53206c8a63 | |||
0ab2d2e3be | |||
b899236c04 | |||
ed04c7a0b2 | |||
ab30942118 | |||
fa83d0a9a5 | |||
c655f32716 | |||
a04d2b1d39 | |||
0b4e1647e5 | |||
6d21528e78 | |||
74332063ea | |||
ab717d9b36 | |||
bd9e81973a | |||
3e2f9826e2 | |||
d9b91d4804 | |||
26e5008d4b | |||
b72675d53d | |||
6926cea8e8 | |||
684b4d8b81 | |||
be9051addf | |||
ae457ca468 | |||
5b6b36cfb7 | |||
d871b55947 | |||
c0a94b5b63 | |||
09aedc967c | |||
dfa083a309 | |||
5dcf86b44b | |||
abf36e5838 | |||
2347edd3ac | |||
0005449303 | |||
7a0a97a848 | |||
3c152db64c | |||
124f50dbfe | |||
37cee1e6f2 | |||
d36ee683ff | |||
8a4fdaf01b | |||
018c286d3a | |||
7b16b9b829 | |||
c198ce2caa | |||
ca04f8b787 | |||
b1050e2100 | |||
da37d9a68d | |||
2b765f2bdd | |||
86add3568e | |||
3aea0e5196 | |||
3313bef9a4 | |||
32c42e2558 | |||
9a492ea9a4 | |||
c0345647f3 | |||
dd67962395 | |||
6fe00d4b47 | |||
b2b446cdf2 | |||
af9736b2e7 | |||
19d013941d | |||
3b5b67b952 | |||
80ce63f15b | |||
bcabea44b3 | |||
bccfad46ac | |||
1f690d3b47 | |||
b2baebf423 | |||
dda5a20078 | |||
f862318693 | |||
85ddf927f7 | |||
6247b2169c | |||
577da2e684 | |||
aa6dacfac2 | |||
c7ef54ba95 | |||
bff9910943 | |||
2ea40c87cb | |||
3c5d5c043c | |||
27928fe9e1 | |||
6c0365db8a | |||
5a6fab927f | |||
ab1ac589a8 | |||
4d2fb827b0 | |||
6daf21a50d | |||
f8a88cc358 | |||
c3e03f53cc | |||
03b16331e0 | |||
e616e463e2 | |||
f6c9d505be | |||
3a438d64d1 | |||
2d0d040f02 | |||
7796d526c3 | |||
2c4dbb4e9b | |||
b816cdc120 | |||
8f7129fca9 | |||
c97976e478 | |||
fa26c73e71 | |||
9256a5504a | |||
d7650f3e0f | |||
aafef3075f | |||
4fc410c322 | |||
09d3c1fe2b | |||
16384ed62b | |||
4d047a9925 | |||
cc6216b464 | |||
01738cdcfa | |||
1f31eaaf18 | |||
21c2ce23d0 | |||
eaa9c36182 | |||
18464f8c57 | |||
c2d2b6016a | |||
eaaaf293f1 | |||
461465d796 | |||
bfab18e60c | |||
e36f30eac8 | |||
3a35ff3bd4 | |||
6e52173049 | |||
47d607adf0 | |||
9bdff7d0ad | |||
3de30c9468 | |||
16ba1cb4f4 | |||
09d4f14580 | |||
ddaf699a07 | |||
817eaed43f | |||
6fcf84b4ff | |||
58628dc497 | |||
a9eb7f112e | |||
bd08c000f2 | |||
cb589d0eac | |||
c8bc3e152b | |||
cf1436966a | |||
45a1dc21e6 | |||
21898694d9 | |||
9839168322 | |||
4973232eb6 | |||
b86fc2c524 | |||
56a3bc2560 | |||
fb665f5abc | |||
e9a30cfa6a | |||
f99756d796 | |||
f839851118 | |||
fa1a95fe65 | |||
1cf6bf3953 | |||
f4afeeecb0 | |||
d55b76206f | |||
55136fc05d | |||
3573df2b7e | |||
9d68d38748 | |||
76e74118e5 | |||
410b0d7fed | |||
efe6ff46fe | |||
70b6a0a5be | |||
0dde70472e | |||
58ba5f9446 | |||
85438c0586 | |||
00448b4845 | |||
ea6ab59fa8 | |||
19257ee4a1 | |||
c104dd62dd | |||
d7fb98d79d | |||
a3cc4110d2 | |||
9559499fba |
82
a1/program.c
Normal file
82
a1/program.c
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
#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
Normal file
86
a2/snake.c
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
#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;
|
||||||
|
}
|
84
a3/binary_search_tree.c
Normal file
84
a3/binary_search_tree.c
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
#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);
|
||||||
|
}
|
30
cv1/program.c
Normal file
30
cv1/program.c
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#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;
|
||||||
|
}
|
74
cv10/program.c
Normal file
74
cv10/program.c
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#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;
|
||||||
|
}
|
41
cv2/program.c
Normal file
41
cv2/program.c
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
41
cv3/program.c
Normal file
41
cv3/program.c
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#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
Normal file
128
cv4/list_ops.c
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
#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);
|
||||||
|
}
|
47
cv4/list_ops.h
Normal file
47
cv4/list_ops.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#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
Normal file
37
cv4/makefile
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
### 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)
|
2110
cv4/test-framework/unity.c
Normal file
2110
cv4/test-framework/unity.c
Normal file
File diff suppressed because it is too large
Load Diff
661
cv4/test-framework/unity.h
Normal file
661
cv4/test-framework/unity.h
Normal file
@ -0,0 +1,661 @@
|
|||||||
|
/* ==========================================
|
||||||
|
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
|
1039
cv4/test-framework/unity_internals.h
Normal file
1039
cv4/test-framework/unity_internals.h
Normal file
File diff suppressed because it is too large
Load Diff
396
cv4/test_list_ops.c
Normal file
396
cv4/test_list_ops.c
Normal file
@ -0,0 +1,396 @@
|
|||||||
|
#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();
|
||||||
|
}
|
93
cv5/program.c
Normal file
93
cv5/program.c
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
#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
Normal file
58
cv9/snake.c
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#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;
|
||||||
|
}
|
14
cv9/snake/Makefile
Normal file
14
cv9/snake/Makefile
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
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
|
||||||
|
|
16
cv9/snake/README.md
Normal file
16
cv9/snake/README.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# 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
Normal file
110
cv9/snake/main.c
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
#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;
|
||||||
|
}
|
58
cv9/snake/snake.c
Normal file
58
cv9/snake/snake.c
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#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;
|
||||||
|
}
|
114
cv9/snake/snake.h
Normal file
114
cv9/snake/snake.h
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
#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
|
||||||
|
|
198
cv9/snake/world.c
Normal file
198
cv9/snake/world.c
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
#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;
|
||||||
|
};
|
122
cv9/snake/world.h
Normal file
122
cv9/snake/world.h
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
#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