BufferTests.c 692 B

123456789101112131415161718192021222324
  1. #include "../Tests.h"
  2. #include "core/Buffer.h"
  3. static const size_t SIZE_TYPES =
  4. sizeof(int) + sizeof(long) + sizeof(float) + sizeof(double);
  5. void testBuffer(bool light) {
  6. Buffer buffer;
  7. initBuffer(&buffer);
  8. size_t limit = light ? 1000 : 100000;
  9. for(size_t i = 0; i < limit; i++) {
  10. addTypedBufferData(&buffer, int, 5);
  11. addTypedBufferData(&buffer, long, 51);
  12. addTypedBufferData(&buffer, float, 5.0f);
  13. addTypedBufferData(&buffer, double, 5.0);
  14. }
  15. TEST_SIZE(SIZE_TYPES * limit, buffer.size);
  16. clearBuffer(&buffer);
  17. addTypedBufferData(&buffer, long, 20);
  18. TEST_SIZE(sizeof(long), buffer.size);
  19. destroyBuffer(&buffer);
  20. }