Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #define TEST_CASE_COUNT 3
- int inuti(double x, double y, double x1, double y1, double x2, double y2) {
- int x_inuti;
- int y_inuti;
- if (x1 < x2)
- x_inuti = x > x1 && x < x2;
- else
- x_inuti = x > x2 && x < x1;
- if (y1 < y2)
- y_inuti = y > y1 && y < y2;
- else
- y_inuti = y > y2 && y < y1;
- return x_inuti && y_inuti;
- }
- int main(void) {
- double x[TEST_CASE_COUNT] = { x, x1, x2 };
- double y[TEST_CASE_COUNT] = { y, y1, y2 };
- double rect[TEST_CASE_COUNT][6][3] =
- {
- { 1, 3, -1.5, 2, 5, 4.9 },
- { 1, 3, 5, 4.9, -1.5, 2 },
- { 2, 0.5, 5, 4.9, -1.5, 2 }
- };
- int expectedResults[TEST_CASE_COUNT] = { 1, 1, 0 };
- int i;
- int resultat;
- for (i = 0; i < TEST_CASE_COUNT; ++i)
- {
- resultat = inuti(x[i], y[i], rect[i][0], rect[i][1], rect[i][2], rect[i][3]);
- if (resultat != expectedResults[i]) printf("Unexpected return from function");
- printf("\n");
- }
- return 0;
- }
- # bara något test skit.
- |x = 1, y = 1, x1 = 1, y1 = 2, x2 = 3, y2 = 4|
- |x = 2, y = 2, x1 = 5, y1 = 6, x2 = 7, y2 = 8|
- |x = 3, y = 3, x1 = 9, y1 = 10, x2 = 11, y2 = 12|
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement