Add mip test

This commit is contained in:
cpq committed 2022-09-05 15:56:03 +01:00
1 parent 32782bab0e
commit 1c181e091e
5 files changed
+69 -20

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
#include <assert.h>
#include "mongoose.c"
static void test_queue(void) {
uint8_t buf[sizeof(size_t) + 5];
uint16_t val = 1234;
struct queue q = {buf, sizeof(buf), 0, 0};
// Write to an empty queue, and read back
assert(q_avail(&q) == 0);
assert(q_write(&q, &val, sizeof(val)) == true);
assert(q_avail(&q) == sizeof(val));
assert(q.head > q.tail);
val = 0;
assert(q_read(&q, &val) == sizeof(val));
assert(val == 1234);
assert(q_avail(&q) == 0);
// Second write - wrap over the buffer boundary
assert(q_write(&q, &val, sizeof(val)) == true);
assert(q_avail(&q) == sizeof(val));
assert(q.head < q.tail);
val = 0;
assert(q_read(&q, &val) == sizeof(val));
assert(val == 1234);
assert(q_avail(&q) == 0);
}
int main(void) {
test_queue();
printf("SUCCESS\n");
return 0;
}