Exemple #1
0
double test4() {
	long long p0 = 12399ll;
	long long p1 = 45699ll;
//	long long p0 = 1234567LL;
//	long long p1 = 89101112LL;
	EllysXors * obj = new EllysXors();
	clock_t start = clock();
	long long my_answer = obj->getXor(p0, p1);
	clock_t end = clock();
	delete obj;
	cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
	long long p2 = 89998783LL;
	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;
	}
}
// BEGIN KAWIGIEDIT TESTING
// Generated by KawigiEdit 2.1.4 (beta) modified by pivanof
bool KawigiEdit_RunTest(int testNum, long long p0, long long p1, bool hasAnswer, long long p2) {
	cout << "Test " << testNum << ": [" << p0 << "," << p1;
	cout << "]" << endl;
	EllysXors *obj;
	long long answer;
	obj = new EllysXors();
	clock_t startTime = clock();
	answer = obj->getXor(p0, p1);
	clock_t endTime = clock();
	delete obj;
	bool res;
	res = true;
	cout << "Time: " << double(endTime - startTime) / CLOCKS_PER_SEC << " seconds" << endl;
	if (hasAnswer) {
		cout << "Desired answer:" << endl;
		cout << "\t" << p2 << endl;
	}
	cout << "Your answer:" << endl;
	cout << "\t" << answer << endl;
	if (hasAnswer) {
		res = answer == p2;
	}
	if (!res) {
		cout << "DOESN'T MATCH!!!!" << endl;
	} else if (double(endTime - startTime) / CLOCKS_PER_SEC >= 2) {
		cout << "FAIL the timeout" << endl;
		res = false;
	} else if (hasAnswer) {
		cout << "Match :-)" << endl;
	} else {
		cout << "OK, but is it right?" << endl;
	}
	cout << "" << endl;
	return res;
}
Exemple #3
0
int main(int argc, char *argv[])
{
  
  EllysXors test;

  if(argc == 1) {
    test.run_test(-1);
  }else {
    std::string arg(argv[1]);
    if(arg[0] != '-') {
      test.run_test(arg[0] - '0');
    }else {
      test.debug();
    }
  }
  
  return 0;
}
    void testCase4() {
		long long L = 1234567LL;
		long long R = 89101112LL;
		long long expected_ = 89998783LL;
        assertEquals(4, expected_, solution.getXor(L, R));
    }
    void testCase3() {
		long long L = 666LL;
		long long R = 1337LL;
		long long expected_ = 0LL;
        assertEquals(3, expected_, solution.getXor(L, R));
    }
    void testCase2() {
		long long L = 13LL;
		long long R = 42LL;
		long long expected_ = 39LL;
        assertEquals(2, expected_, solution.getXor(L, R));
    }
    void testCase1() {
		long long L = 5LL;
		long long R = 5LL;
		long long expected_ = 5LL;
        assertEquals(1, expected_, solution.getXor(L, R));
    }
    void testCase0() {
		long long L = 3LL;
		long long R = 10LL;
		long long expected_ = 8LL;
        assertEquals(0, expected_, solution.getXor(L, R));
    }