Exemplo n.º 1
0
double test1() {
	int t0[] = {10000,-10000};
	vector <int> p0(t0, t0+sizeof(t0)/sizeof(int));
	int t1[] = {-10000,10000};
	vector <int> p1(t1, t1+sizeof(t1)/sizeof(int));
	Intersect * obj = new Intersect();
	clock_t start = clock();
	int my_answer = obj->area(p0, p1);
	clock_t end = clock();
	delete obj;
	cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
	int p2 = 400000000;
	cout <<"Desired answer: " <<endl;
	cout <<"\t" << p2 <<endl;
	cout <<"Your answer: " <<endl;
	cout <<"\t" << my_answer <<endl;
	if (p2 != my_answer) {
		cout <<"DOESN'T MATCH!!!!" <<endl <<endl;
		return -1;
	}
	else {
		cout <<"Match :-)" <<endl <<endl;
		return (double)(end-start)/CLOCKS_PER_SEC;
	}
}
Exemplo n.º 2
0
//{{3, 8, 6, 12, 10, 15}, {7, 17, 7, 17, 7, 17}}
    //  {{3, 8, 6, 12, 10, 15}, {7, 17, 7, 17, 7, 17}}
    void testCase6() {
        int x_[] = {3, 8, 6, 12, 10, 15};
        vector<int> x(x_, x_ + (sizeof(x_) / sizeof(x_[0])));
        int y_[] = {7, 17, 7, 17, 7, 17};
        vector<int> y(y_, y_ + (sizeof(y_) / sizeof(y_[0])));
        int expected_ = 0;
        assertEquals(6, expected_, solution.area(x, y));
    }
Exemplo n.º 3
0
 void testCase5() {
     int x_[] = {1, 7, 12, 3, 16, 8, 3, 12};
     vector<int> x(x_, x_ + (sizeof(x_) / sizeof(x_[0])));
     int y_[] = {-90, -60, -70, 3, -60, -90, -80, -100};
     vector<int> y(y_, y_ + (sizeof(y_) / sizeof(y_[0])));
     int expected_ = 0;
     assertEquals(5, expected_, solution.area(x, y));
 }
Exemplo n.º 4
0
 void testCase4() {
     int x_[] = {2, 100, 5, 32, 1000, -20, 47, 12};
     vector<int> x(x_, x_ + (sizeof(x_) / sizeof(x_[0])));
     int y_[] = {29, -1000, -800, -200, -900, 300, -600, -650};
     vector<int> y(y_, y_ + (sizeof(y_) / sizeof(y_[0])));
     int expected_ = 1000;
     assertEquals(4, expected_, solution.area(x, y));
 }
Exemplo n.º 5
0
 void testCase3() {
     int x_[] = {0, 0, 0, 0, 0, 0, 0, 0};
     vector<int> x(x_, x_ + (sizeof(x_) / sizeof(x_[0])));
     int y_[] = {5, 5, 5, 5, 5, 5, 5, 5};
     vector<int> y(y_, y_ + (sizeof(y_) / sizeof(y_[0])));
     int expected_ = 0;
     assertEquals(3, expected_, solution.area(x, y));
 }
Exemplo n.º 6
0
 void testCase1() {
     int x_[] = {10000, -10000};
     vector<int> x(x_, x_ + (sizeof(x_) / sizeof(x_[0])));
     int y_[] = {-10000, 10000};
     vector<int> y(y_, y_ + (sizeof(y_) / sizeof(y_[0])));
     int expected_ = 400000000;
     assertEquals(1, expected_, solution.area(x, y));
 }
Exemplo n.º 7
0
 void testCase0() {
     int x_[] = {0, 2, 3, -4};
     vector<int> x(x_, x_ + (sizeof(x_) / sizeof(x_[0])));
     int y_[] = {17, 1000, 18, 6};
     vector<int> y(y_, y_ + (sizeof(y_) / sizeof(y_[0])));
     int expected_ = 2;
     assertEquals(0, expected_, solution.area(x, y));
 }