BufferTests.c 712 B

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