test_vector.c 540 B

123456789101112131415161718192021222324
  1. #include <assert.h>
  2. #include <stdio.h>
  3. #include "vector.h"
  4. #include "gc_prelude.h"
  5. int main() {
  6. Vector v = new_Vector();
  7. Double n = new_Double(42.42);
  8. Vector_pushBack(v, n);
  9. assert(*(Double)Vector_get(v, 0) == 42.42);
  10. v = new_Vector();
  11. for (int i = 0; i < 10000; i++) {
  12. Integer x = new_Integer(i);
  13. Vector_pushBack(v, x);
  14. assert(Vector_size(v) == i + 1);
  15. }
  16. for (int i = 0; i < 10000; i++) {
  17. assert(*(Integer)Vector_get(v, i) == i);
  18. }
  19. printf("[PASSED] Vector\n");
  20. }