Driver code updated

This commit is contained in:
Imbus 2024-07-02 06:27:39 +02:00
parent 68af34c428
commit c06bb51cdc

View file

@ -16,16 +16,31 @@ main(void)
int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int ok = WriteOk; // Assume we can write
for(int i = 0; i < 10 && ok == WriteOk; i++) {
ok = rb_push_back(&rb, &arr[i], memcpy);
}
ok = rb_push_many(&rb, arr, memcpy, 8);
int d;
while(rb_pop_front(&rb, &d) == ReadOk) {
while(rb_pop_front(&rb, &d, memcpy) == ReadOk) {
printf("Data: %d\n", d);
}
// Test wrap around
rb_push_many(&rb, arr, memcpy, 10);
while(rb_pop_front(&rb, &d, memcpy) == ReadOk) {
printf("Data: %d\n", d);
}
// Test clear
rb_clear(&rb);
if(rb_pop_front(&rb, &d, memcpy) != Empty) {
printf("Buffer is not empty after clear...\n");
}
rb_destroy(&rb, free);
enum WriteResult wr = WriteOk;
enum ReadResult rr = ReadOk;
printf("Size of wr: %lu bytes.\n", sizeof(wr));
printf("Size of rr: %lu bytes.\n", sizeof(rr));
return 0;
}