Advertisement
Guest User

Untitled

a guest
Nov 28th, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. #define TEST_CASE_COUNT 3
  5.  
  6. int inuti(double x, double y, double x1, double y1, double x2, double y2) {
  7. int x_inuti;
  8. int y_inuti;
  9.  
  10. if (x1 < x2)
  11. x_inuti = x > x1 && x < x2;
  12. else
  13. x_inuti = x > x2 && x < x1;
  14. if (y1 < y2)
  15. y_inuti = y > y1 && y < y2;
  16. else
  17. y_inuti = y > y2 && y < y1;
  18. return x_inuti && y_inuti;
  19. }
  20.  
  21. int main(void) {
  22. double x[TEST_CASE_COUNT] = { x, x1, x2 };
  23. double y[TEST_CASE_COUNT] = { y, y1, y2 };
  24. double rect[TEST_CASE_COUNT][6][3] =
  25. {
  26. { 1, 3, -1.5, 2, 5, 4.9 },
  27. { 1, 3, 5, 4.9, -1.5, 2 },
  28. { 2, 0.5, 5, 4.9, -1.5, 2 }
  29. };
  30. int expectedResults[TEST_CASE_COUNT] = { 1, 1, 0 };
  31.  
  32. int i;
  33. int resultat;
  34.  
  35. for (i = 0; i < TEST_CASE_COUNT; ++i)
  36. {
  37. resultat = inuti(x[i], y[i], rect[i][0], rect[i][1], rect[i][2], rect[i][3]);
  38.  
  39. if (resultat != expectedResults[i]) printf("Unexpected return from function");
  40.  
  41. printf("\n");
  42.  
  43. }
  44.  
  45. return 0;
  46. }
  47. # bara något test skit.
  48.  
  49. |x = 1, y = 1, x1 = 1, y1 = 2, x2 = 3, y2 = 4|
  50. |x = 2, y = 2, x1 = 5, y1 = 6, x2 = 7, y2 = 8|
  51. |x = 3, y = 3, x1 = 9, y1 = 10, x2 = 11, y2 = 12|
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement