mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-30 12:50:58 +00:00
Add mip test
This commit is contained in:
1 parent
32782bab0e
commit
1c181e091e
5 files changed
+69
-20
No files matched your search
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user