test_camera.c 891 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * This is a test for camera in $package$
  3. */
  4. #include "si_test.h"
  5. #include "camera.h"
  6. TEST_FUNC(camera) {
  7. Camera * camera;
  8. Panner * p1;
  9. Panner * p2;
  10. int count;
  11. Point g1 = { 100, 100 };
  12. Point g2 = { 1000, 700 };
  13. camera = camera_new(0, 0, 640, 480);
  14. TEST_NOTNULL(camera);
  15. p1 = camera_newpanner(camera, g1, 1.0, FALSE);
  16. p2 = camera_newpanner(camera, g2, 1.0, FALSE);
  17. TEST_NOTNULL(p1);
  18. TEST_NOTNULL(p2);
  19. TEST_ASSERT(camera_panning_p(camera));
  20. count = -1000000;
  21. while(camera_panning_p(camera)) {
  22. camera_update(camera);
  23. count++;
  24. if ((count % 10000) == 0) {
  25. printf("%lf %lf\n",
  26. camera_center_x(camera),
  27. camera_center_y(camera)
  28. );
  29. }
  30. if (count >= 0) break;
  31. }
  32. TEST_ASSERT(count < 0);
  33. camera_free(camera);
  34. TEST_DONE();
  35. }
  36. int main(void) {
  37. TEST_INIT();
  38. TEST_RUN(camera);
  39. TEST_REPORT();
  40. }