int main() { test (34.0, __builtin_inf()); testf (34.0f, __builtin_inff()); testf (34.0l, __builtin_infl()); return 0; }
int main(int argc, char *argv[]) { printf("1..3\n"); test_invalid(0.0, 0.0); test_invalid(1.0, 0.0); test_invalid(INFINITY, 0.0); test_invalid(INFINITY, 1.0); test_invalid(-INFINITY, 1.0); test_invalid(NAN, 1.0); test_invalid(1.0, NAN); test(4, 4, 0, 1); test(0, 3.0, 0, 0); testd(0x1p-1074, 1, 0x1p-1074, 0); testf(0x1p-149, 1, 0x1p-149, 0); test(3.0, 4, -1, 1); test(3.0, -4, -1, -1); testd(275 * 1193040, 275, 0, 1193040); test(4.5 * 7.5, 4.5, -2.25, 8); /* we should get the even one */ testf(0x1.9044f6p-1, 0x1.ce662ep-1, -0x1.f109cp-4, 1); #if LDBL_MANT_DIG > 53 testl(-0x1.23456789abcdefp-2000L, 0x1.fedcba987654321p-2000L, 0x1.b72ea61d950c862p-2001L, -1); #endif printf("ok 1 - rem\n"); /* * The actual quotient here is 864062210.50000003..., but * double-precision division gets -8.64062210.5, which rounds * the wrong way. This test ensures that remquo() is smart * enough to get the low-order bit right. */ testd(-0x1.98260f22fc6dep-302, 0x1.fb3167c430a13p-332, 0x1.fb3165b82de72p-333, -864062211); /* Even harder cases with greater exponent separation */ test(0x1.fp100, 0x1.ep-40, -0x1.cp-41, 143165577); testd(-0x1.abcdefp120, 0x1.87654321p-120, -0x1.69c78ec4p-121, -63816414); printf("ok 2 - rem\n"); test(0x1.66666cp+120, 0x1p+71, 0.0, 1476395008); testd(-0x1.0000000000003p+0, 0x1.0000000000003p+0, -0.0, -1); testl(-0x1.0000000000003p+0, 0x1.0000000000003p+0, -0.0, -1); testd(-0x1.0000000000001p-749, 0x1.4p-1072, 0x1p-1074, -1288490189); testl(-0x1.0000000000001p-749, 0x1.4p-1072, 0x1p-1074, -1288490189); printf("ok 3 - rem\n"); return (0); }
int main () { test (1.0); testf (1.0f); testl (1.0l); return 0; }
int main() { test(0.0); testf(0.0); testl(0.0); return 0; }
ATF_TC_BODY(t_tls_dlopen, tc) { void *handle; pthread_t t; #ifdef __HAVE_NO___THREAD atf_tc_skip("no TLS support on this platform"); #endif handle = dlopen("h_tls_dlopen.so", RTLD_NOW | RTLD_LOCAL); ATF_REQUIRE(handle != NULL); testf_helper = dlsym(handle, "testf_dso_helper"); ATF_REQUIRE(testf_helper != NULL); testf(NULL); pthread_create(&t, 0, testf, 0); pthread_join(t, NULL); pthread_create(&t, 0, testf, 0); pthread_join(t, NULL); dlclose(handle); }
int main () { int res[6]; testf (f, res); test (d, res); testl (ld, res); return 0; }
int main(int argc, char **argv) { int result = 1; char testString1[] = "the quick brown dog..."; // Basic test. result &= testf(condense_by_removing(testString1, 'o'), "the quick brwn dg..."); // Test that the operation is destructive. result &= testf(testString1, "the quick brwn dg..."); // Test multiple char removals in a row. char testString2[] = "cartoon toon"; result &= testf(condense_by_removing(testString2, 'o'), "cartn tn"); // Test input of nothing but removal chars. char testString3[] = "ooo"; result &= testf(condense_by_removing(testString3, 'o'), ""); // Test input of empty string. char testString4[] = ""; result &= testf(condense_by_removing(testString4, 'o'), ""); printf(result ? "All tests passed.\n" : "Some of the tests failed.\n"); return !result; }
int main() { if (testf (__FLT_MAX__) < 1) abort (); if (test (__DBL_MAX__) < 1) abort (); if (testl (__LDBL_MAX__) < 1) abort (); return 0; }
RCommitLog::RCommitLog(std::string logfile, int firstChar) { logf = 0; seekable = false; success = false; is_dir = false; buffered = false; if(logfile == "-") { //check first char if(checkFirstChar(firstChar, std::cin)) { logf = new StreamLog(); is_dir = false; seekable = false; success = true; } return; } struct stat fileinfo; int rc = stat(logfile.c_str(), &fileinfo); if(rc==0) { is_dir = (fileinfo.st_mode & S_IFDIR) ? true : false; if(!is_dir) { //check first char std::ifstream testf(logfile.c_str()); bool firstOK = checkFirstChar(firstChar, testf); testf.close(); if(firstOK) { logf = new SeekLog(logfile); seekable = true; success = true; } } } }
int main() { testf(3, 0.000030000, "0.000030000"); int i; for (i=0; i<20; i++) { test(i, 3*i+1); test(i, 100); } for (i=0; i<8; i++) { testf(i, 0.000030000, "0.000030000"); testf(i, 0.000030001, "0.000030001"); testf(i, 0.600030000, "0.600030000"); testf(i, 0.600030001, "0.600030001"); testf(i, 1.600030000, "1.600030000"); testf(i, 1.600030001, "1.600030001"); } return 0; }
int main(int argc, char *argv[]) { static const int ex_under = FE_UNDERFLOW | FE_INEXACT; /* shorthand */ static const int ex_over = FE_OVERFLOW | FE_INEXACT; long double ldbl_small, ldbl_eps, ldbl_max; printf("1..5\n"); #ifdef __i386__ fpsetprec(FP_PE); #endif /* * We can't use a compile-time constant here because gcc on * FreeBSD/i386 assumes long doubles are truncated to the * double format. */ ldbl_small = ldexpl(1.0, LDBL_MIN_EXP - LDBL_MANT_DIG); ldbl_eps = LDBL_EPSILON; ldbl_max = ldexpl(1.0 - ldbl_eps / 2, LDBL_MAX_EXP); /* * Special cases involving zeroes. */ #define ztest(prec) \ test##prec(copysign##prec(1.0, nextafter##prec(0.0, -0.0)), -1.0, 0); \ test##prec(copysign##prec(1.0, nextafter##prec(-0.0, 0.0)), 1.0, 0); \ test##prec(copysign##prec(1.0, nexttoward##prec(0.0, -0.0)), -1.0, 0);\ test##prec(copysign##prec(1.0, nexttoward##prec(-0.0, 0.0)), 1.0, 0) ztest(); ztest(f); ztest(l); #undef ztest #define stest(next, eps, prec) \ test##prec(next(-0.0, 42.0), eps, ex_under); \ test##prec(next(0.0, -42.0), -eps, ex_under); \ test##prec(next(0.0, INFINITY), eps, ex_under); \ test##prec(next(-0.0, -INFINITY), -eps, ex_under) stest(nextafter, 0x1p-1074, ); stest(nextafterf, 0x1p-149f, f); stest(nextafterl, ldbl_small, l); stest(nexttoward, 0x1p-1074, ); stest(nexttowardf, 0x1p-149f, f); stest(nexttowardl, ldbl_small, l); #undef stest printf("ok 1 - next\n"); /* * `x == y' and NaN tests */ testall(42.0, 42.0, 42.0, 0); testall(-42.0, -42.0, -42.0, 0); testall(INFINITY, INFINITY, INFINITY, 0); testall(-INFINITY, -INFINITY, -INFINITY, 0); testall(NAN, 42.0, NAN, 0); testall(42.0, NAN, NAN, 0); testall(NAN, NAN, NAN, 0); printf("ok 2 - next\n"); /* * Tests where x is an ordinary normalized number */ testboth(1.0, 2.0, 1.0 + DBL_EPSILON, 0, ); testboth(1.0, -INFINITY, 1.0 - DBL_EPSILON/2, 0, ); testboth(1.0, 2.0, 1.0 + FLT_EPSILON, 0, f); testboth(1.0, -INFINITY, 1.0 - FLT_EPSILON/2, 0, f); testboth(1.0, 2.0, 1.0 + ldbl_eps, 0, l); testboth(1.0, -INFINITY, 1.0 - ldbl_eps/2, 0, l); testboth(-1.0, 2.0, -1.0 + DBL_EPSILON/2, 0, ); testboth(-1.0, -INFINITY, -1.0 - DBL_EPSILON, 0, ); testboth(-1.0, 2.0, -1.0 + FLT_EPSILON/2, 0, f); testboth(-1.0, -INFINITY, -1.0 - FLT_EPSILON, 0, f); testboth(-1.0, 2.0, -1.0 + ldbl_eps/2, 0, l); testboth(-1.0, -INFINITY, -1.0 - ldbl_eps, 0, l); /* Cases where nextafter(...) != nexttoward(...) */ test(nexttoward(1.0, 1.0 + ldbl_eps), 1.0 + DBL_EPSILON, 0); testf(nexttowardf(1.0, 1.0 + ldbl_eps), 1.0 + FLT_EPSILON, 0); testl(nexttowardl(1.0, 1.0 + ldbl_eps), 1.0 + ldbl_eps, 0); printf("ok 3 - next\n"); /* * Tests at word boundaries, normalization boundaries, etc. */ testboth(0x1.87654ffffffffp+0, INFINITY, 0x1.87655p+0, 0, ); testboth(0x1.87655p+0, -INFINITY, 0x1.87654ffffffffp+0, 0, ); testboth(0x1.fffffffffffffp+0, INFINITY, 0x1p1, 0, ); testboth(0x1p1, -INFINITY, 0x1.fffffffffffffp+0, 0, ); testboth(0x0.fffffffffffffp-1022, INFINITY, 0x1p-1022, 0, ); testboth(0x1p-1022, -INFINITY, 0x0.fffffffffffffp-1022, ex_under, ); testboth(0x1.fffffep0f, INFINITY, 0x1p1, 0, f); testboth(0x1p1, -INFINITY, 0x1.fffffep0f, 0, f); testboth(0x0.fffffep-126f, INFINITY, 0x1p-126f, 0, f); testboth(0x1p-126f, -INFINITY, 0x0.fffffep-126f, ex_under, f); #if LDBL_MANT_DIG == 53 testboth(0x1.87654ffffffffp+0L, INFINITY, 0x1.87655p+0L, 0, l); testboth(0x1.87655p+0L, -INFINITY, 0x1.87654ffffffffp+0L, 0, l); testboth(0x1.fffffffffffffp+0L, INFINITY, 0x1p1L, 0, l); testboth(0x1p1L, -INFINITY, 0x1.fffffffffffffp+0L, 0, l); testboth(0x0.fffffffffffffp-1022L, INFINITY, 0x1p-1022L, 0, l); testboth(0x1p-1022L, -INFINITY, 0x0.fffffffffffffp-1022L, ex_under, l); #elif LDBL_MANT_DIG == 64 && !defined(__i386) testboth(0x1.87654321fffffffep+0L, INFINITY, 0x1.87654322p+0L, 0, l); testboth(0x1.87654322p+0L, -INFINITY, 0x1.87654321fffffffep+0L, 0, l); testboth(0x1.fffffffffffffffep0L, INFINITY, 0x1p1L, 0, l); testboth(0x1p1L, -INFINITY, 0x1.fffffffffffffffep0L, 0, l); testboth(0x0.fffffffffffffffep-16382L, INFINITY, 0x1p-16382L, 0, l); testboth(0x1p-16382L, -INFINITY, 0x0.fffffffffffffffep-16382L, ex_under, l); #elif LDBL_MANT_DIG == 113 testboth(0x1.876543210987ffffffffffffffffp+0L, INFINITY, 0x1.876543210988p+0, 0, l); testboth(0x1.876543210988p+0L, -INFINITY, 0x1.876543210987ffffffffffffffffp+0L, 0, l); testboth(0x1.ffffffffffffffffffffffffffffp0L, INFINITY, 0x1p1L, 0, l); testboth(0x1p1L, -INFINITY, 0x1.ffffffffffffffffffffffffffffp0L, 0, l); testboth(0x0.ffffffffffffffffffffffffffffp-16382L, INFINITY, 0x1p-16382L, 0, l); testboth(0x1p-16382L, -INFINITY, 0x0.ffffffffffffffffffffffffffffp-16382L, ex_under, l); #endif printf("ok 4 - next\n"); /* * Overflow tests */ test(idd(nextafter(DBL_MAX, INFINITY)), INFINITY, ex_over); test(idd(nextafter(INFINITY, 0.0)), DBL_MAX, 0); test(idd(nexttoward(DBL_MAX, DBL_MAX * 2.0L)), INFINITY, ex_over); #if LDBL_MANT_DIG > 53 test(idd(nexttoward(INFINITY, DBL_MAX * 2.0L)), DBL_MAX, 0); #endif testf(idf(nextafterf(FLT_MAX, INFINITY)), INFINITY, ex_over); testf(idf(nextafterf(INFINITY, 0.0)), FLT_MAX, 0); testf(idf(nexttowardf(FLT_MAX, FLT_MAX * 2.0)), INFINITY, ex_over); testf(idf(nexttowardf(INFINITY, FLT_MAX * 2.0)), FLT_MAX, 0); testboth(ldbl_max, INFINITY, INFINITY, ex_over, l); testboth(INFINITY, 0.0, ldbl_max, 0, l); printf("ok 5 - next\n"); return (0); }
void TestApp::test_vector2(void) { Console::write_line(" Header: cl_vector.h"); Console::write_line(" Class: Vec2"); Console::write_line(" Function: rotate()"); { Vec2i test_a; Vec2i hotspot(1,3); test_a = Vec2i(4,5); test_a.rotate(hotspot, Angle(0, angle_degrees)); if (test_a != Vec2i(4, 5)) fail(); test_a = Vec2i(4,5); test_a.rotate(hotspot, Angle(90, angle_degrees)); if (test_a != Vec2i(-1, 6)) fail(); test_a = Vec2i(4,5); test_a.rotate(hotspot, Angle(180, angle_degrees)); if (test_a != Vec2i(-2, 1)) fail(); test_a = Vec2i(4,5); test_a.rotate(hotspot, Angle(270, angle_degrees)); if (test_a != Vec2i(3, 0)) fail(); test_a = Vec2i(4,5); test_a.rotate(hotspot, Angle(360, angle_degrees)); if (test_a != Vec2i(4, 5)) fail(); test_a = Vec2i(4,5); test_a.rotate(Vec2i(0,0), Angle(180, angle_degrees)); if (test_a != Vec2i(-4, -5)) fail(); } Console::write_line(" Function: distance()"); { Vec2d test_a(2.0,3.0); Vec2d test_b(3.0,4.0); if (test_a.distance(test_b) != sqrt(1.0 + 1.0 )) fail(); } Console::write_line(" Function: normalize()"); { Vec2d testi(3.0,4.0); testi.normalize(); if (testi != Vec2d(3.0/sqrt(25.0), 4.0/sqrt(25.0))) fail(); } Console::write_line(" Function: static normalize()"); { Vec2d testi(3.0,4.0); if (Vec2d::normalize(testi) != Vec2d(3.0/sqrt(25.0), 4.0/sqrt(25.0))) fail(); } Console::write_line(" Function: length()"); { Vec2d testi(3.0,4.0); if (testi.length() != sqrt(25.0 )) fail(); } Console::write_line(" Function: dot()"); { Vec2d test_a(3.0,4.0); Vec2d test_b(13.0,14.0); if (test_a.dot(test_b) != ((3.0 * 13.0)+ (4.0*14.0))) fail(); } Console::write_line(" Function: operator += (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd += Vec2d(1.0, 2.0); if (testd.x != 3.5) fail(); if (testd.y != 5.5) fail(); Vec2i testi(2, 3); testi += Vec2i(1, 2); if (testi.x != 3) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator += ( Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd += valued; if (testd.x != 4.5) fail(); if (testd.y != 5.5) fail(); Vec2i testi(2, 3); int valuei = 2; testi += valuei; if (testi.x != 4) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator + (Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd = testd + valued; if (testd.x != 4.5) fail(); if (testd.y != 5.5) fail(); Vec2i testi(2, 3); int valuei = 2; testi = testi + valuei; if (testi.x != 4) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator + (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd = testd + Vec2d(1.5, 2.5); if (testd.x != 4.0) fail(); if (testd.y != 6.0) fail(); Vec2i testi(2, 3); testi = testi + Vec2i(1, 2); if (testi.x != 3) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator -= (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd -= Vec2d(1.0, 2.0); if (testd.x != 1.5) fail(); if (testd.y != 1.5) fail(); Vec2i testi(2, 3); testi -= Vec2i(1, 2); if (testi.x != 1) fail(); if (testi.y != 1) fail(); } Console::write_line(" Function: operator -= ( Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd -= valued; if (testd.x != 0.5) fail(); if (testd.y != 1.5) fail(); Vec2i testi(2, 3); int valuei = 2; testi -= valuei; if (testi.x != 0) fail(); if (testi.y != 1) fail(); } Console::write_line(" Function: operator - (Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd = testd - valued; if (testd.x != 0.5) fail(); if (testd.y != 1.5) fail(); Vec2i testi(2, 3); int valuei = 2; testi = testi - valuei; if (testi.x != 0) fail(); if (testi.y != 1) fail(); } Console::write_line(" Function: operator - (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd = testd - Vec2d(1.5, 2.5); if (testd.x != 1.0) fail(); if (testd.y != 1.0) fail(); Vec2i testi(2, 3); testi = testi - Vec2i(1, 2); if (testi.x != 1) fail(); if (testi.y != 1) fail(); } Console::write_line(" Function: operator *= (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd *= Vec2d(1.0, 2.0); if (testd.x != 2.5) fail(); if (testd.y != 7.0) fail(); Vec2i testi(2, 3); testi *= Vec2i(1, 2); if (testi.x != 2) fail(); if (testi.y != 6) fail(); } Console::write_line(" Function: operator *= ( Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd *= valued; if (testd.x != 5.0) fail(); if (testd.y != 7.0) fail(); Vec2i testi(2, 3); int valuei = 2; testi *= valuei; if (testi.x != 4) fail(); if (testi.y != 6) fail(); } Console::write_line(" Function: operator * (Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd = testd * valued; if (testd.x != 5.0) fail(); if (testd.y != 7.0) fail(); Vec2i testi(2, 3); int valuei = 2; testi = testi * valuei; if (testi.x != 4) fail(); if (testi.y != 6) fail(); } Console::write_line(" Function: operator * (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd = testd * Vec2d(1.5, 2.5); if (testd.x != 3.75) fail(); if (testd.y != 8.75) fail(); Vec2i testi(2, 3); testi = testi * Vec2i(1, 2); if (testi.x != 2) fail(); if (testi.y != 6) fail(); } Console::write_line(" Function: operator /= (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd /= Vec2d(1.0, 2.0); if (testd.x != 2.5) fail(); if (testd.y != 1.75) fail(); Vec2i testi(2, 10); testi /= Vec2i(1, 2); if (testi.x != 2) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator /= ( Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd /= valued; if (testd.x != 1.25) fail(); if (testd.y != 1.75) fail(); Vec2i testi(2, 10); int valuei = 2; testi /= valuei; if (testi.x != 1) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator / (Type value)"); { Vec2d testd(2.5, 3.5); double valued = 2.0; testd = testd / valued; if (testd.x != 1.25) fail(); if (testd.y != 1.75) fail(); Vec2i testi(2, 10); int valuei = 2; testi = testi / valuei; if (testi.x != 1) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator / (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd = testd / Vec2d(1.0, 2.5); if (testd.x != 2.5) fail(); if (testd.y != 1.4) fail(); Vec2i testi(2, 10); testi = testi / Vec2i(1, 2); if (testi.x != 2) fail(); if (testi.y != 5) fail(); } Console::write_line(" Function: operator = (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); testd = Vec2d(1.0, 2.0); if (testd.x != 1.0) fail(); if (testd.y != 2.0) fail(); Vec2i testi(2, 3); testi = Vec2i(1, 2); if (testi.x != 1) fail(); if (testi.y != 2) fail(); } Console::write_line(" Function: operator == (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); if (testd == Vec2d(1.0, 2.0)) fail(); if (testd == Vec2d(2.5, 2.0)) fail(); if (!(testd == Vec2d(2.5, 3.5))) fail(); Vec2i testi(2, 3); if (testi == Vec2i(1, 2)) fail(); if (testi == Vec2i(2, 2)) fail(); if (!(testi == Vec2i(2, 3))) fail(); } Console::write_line(" Function: operator != (const Vec2<Type>& vector)"); { Vec2d testd(2.5, 3.5); if (!(testd != Vec2d(1.0, 2.0))) fail(); if (!(testd != Vec2d(2.5, 2.0))) fail(); if ((testd != Vec2d(2.5, 3.5))) fail(); Vec2i testi(2, 3); if (!(testi != Vec2i(1, 2))) fail(); if (!(testi != Vec2i(2, 2))) fail(); if ((testi != Vec2i(2, 3))) fail(); } Console::write_line(" Function: round()"); { Vec2d testd(2.0, 2.5); testd.round(); if (testd.x != 2.0) fail(); if (testd.y != 3.0) fail(); Vec2f testf(2.0f, 2.5f); testf.round(); if (testf.x != 2.0f) fail(); if (testf.y != 3.0f) fail(); } Console::write_line(" Function: static round()"); { Vec2d testd(2.0, 2.5); Vec2d destd = Vec2d::round(testd); if (destd.x != 2.0) fail(); if (destd.y != 3.0) fail(); Vec2f testf(2.0f, 2.5f); Vec2f destf = Vec2f::round(testf); if (destf.x != 2.0f) fail(); if (destf.y != 3.0f) fail(); } }
void TestApp::test_vector3(void) { Console::write_line(" Header: cl_vector.h"); Console::write_line(" Class: Vec3"); Console::write_line(" Function: distance()"); { Vec3d test_a(2.0,3.0,4.0); Vec3d test_b(3.0,4.0,5.0); if (test_a.distance(test_b) != sqrt(1.0 + 1.0 + 1.0 )) fail(); } Console::write_line(" Function: normalize()"); { Vec3d testi(3.0,4.0,5.0); testi.normalize(); if (testi != Vec3d(3.0/sqrt(50.0), 4.0/sqrt(50.0), 5.0/sqrt(50.0))) fail(); } Console::write_line(" Function: static normalize()"); { Vec3d testi(3.0,4.0,5.0); if (Vec3d::normalize(testi) != Vec3d(3.0/sqrt(50.0), 4.0/sqrt(50.0), 5.0/sqrt(50.0))) fail(); } Console::write_line(" Function: length()"); { Vec3d testi(3.0,4.0,5.0); if (testi.length() != sqrt(50.0 )) fail(); } Console::write_line(" Function: dot()"); { Vec3d test_a(3.0,4.0,5.0); Vec3d test_b(13.0,14.0,15.0); if (test_a.dot(test_b) != ((3.0 * 13.0)+ (4.0*14.0) + (5.0 * 15.0))) fail(); } Console::write_line(" Function: operator += (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); testd += Vec3d(1.0, 2.0, 3.0); if (testd.x != 3.5) fail(); if (testd.y != 5.5) fail(); if (testd.z != 7.5) fail(); Vec3i testi(2, 3, 4); testi += Vec3i(1, 2, 3); if (testi.x != 3) fail(); if (testi.y != 5) fail(); if (testi.z != 7) fail(); } Console::write_line(" Function: operator += ( Type value)"); { Vec3d testd(2.5, 3.5, 4.5); double valued = 2.0; testd += valued; if (testd.x != 4.5) fail(); if (testd.y != 5.5) fail(); if (testd.z != 6.5) fail(); Vec3i testi(2, 3, 4); int valuei = 2; testi += valuei; if (testi.x != 4) fail(); if (testi.y != 5) fail(); if (testi.z != 6) fail(); } Console::write_line(" Function: operator + (Type value)"); { Vec3d testd(2.5, 3.5, 4.5); double valued = 2.0; testd = testd + valued; if (testd.x != 4.5) fail(); if (testd.y != 5.5) fail(); if (testd.z != 6.5) fail(); Vec3i testi(2, 3, 4); int valuei = 2; testi = testi + valuei; if (testi.x != 4) fail(); if (testi.y != 5) fail(); if (testi.z != 6) fail(); } Console::write_line(" Function: operator + (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); testd = testd + Vec3d(1.5, 2.5, 3.5); if (testd.x != 4.0) fail(); if (testd.y != 6.0) fail(); if (testd.z != 8.0) fail(); Vec3i testi(2, 3, 4); testi = testi + Vec3i(1, 2, 3); if (testi.x != 3) fail(); if (testi.y != 5) fail(); if (testi.z != 7) fail(); } Console::write_line(" Function: operator -= (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); testd -= Vec3d(1.0, 2.0, 3.0); if (testd.x != 1.5) fail(); if (testd.y != 1.5) fail(); if (testd.z != 1.5) fail(); Vec3i testi(2, 3, 4); testi -= Vec3i(1, 2, 3); if (testi.x != 1) fail(); if (testi.y != 1) fail(); if (testi.z != 1) fail(); } Console::write_line(" Function: operator -= ( Type value)"); { Vec3d testd(2.5, 3.5, 4.5); double valued = 2.0; testd -= valued; if (testd.x != 0.5) fail(); if (testd.y != 1.5) fail(); if (testd.z != 2.5) fail(); Vec3i testi(2, 3, 4); int valuei = 2; testi -= valuei; if (testi.x != 0) fail(); if (testi.y != 1) fail(); if (testi.z != 2) fail(); } Console::write_line(" Function: operator - (Type value)"); { Vec3d testd(2.5, 3.5, 4.5); double valued = 2.0; testd = testd - valued; if (testd.x != 0.5) fail(); if (testd.y != 1.5) fail(); if (testd.z != 2.5) fail(); Vec3i testi(2, 3, 4); int valuei = 2; testi = testi - valuei; if (testi.x != 0) fail(); if (testi.y != 1) fail(); if (testi.z != 2) fail(); } Console::write_line(" Function: operator - (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); testd = testd - Vec3d(1.5, 2.5, 3.5); if (testd.x != 1.0) fail(); if (testd.y != 1.0) fail(); if (testd.z != 1.0) fail(); Vec3i testi(2, 3, 4); testi = testi - Vec3i(1, 2, 3); if (testi.x != 1) fail(); if (testi.y != 1) fail(); if (testi.z != 1) fail(); } Console::write_line(" Function: operator *= (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); testd *= Vec3d(1.0, 2.0, 3.0); if (testd.x != 2.5) fail(); if (testd.y != 7.0) fail(); if (testd.z != 13.5) fail(); Vec3i testi(2, 3, 4); testi *= Vec3i(1, 2, 3); if (testi.x != 2) fail(); if (testi.y != 6) fail(); if (testi.z != 12) fail(); } Console::write_line(" Function: operator *= ( Type value)"); { Vec3d testd(2.5, 3.5, 4.5); double valued = 2.0; testd *= valued; if (testd.x != 5.0) fail(); if (testd.y != 7.0) fail(); if (testd.z != 9.0) fail(); Vec3i testi(2, 3, 4); int valuei = 2; testi *= valuei; if (testi.x != 4) fail(); if (testi.y != 6) fail(); if (testi.z != 8) fail(); } Console::write_line(" Function: operator * (Type value)"); { Vec3d testd(2.5, 3.5, 4.5); double valued = 2.0; testd = testd * valued; if (testd.x != 5.0) fail(); if (testd.y != 7.0) fail(); if (testd.z != 9.0) fail(); Vec3i testi(2, 3, 4); int valuei = 2; testi = testi * valuei; if (testi.x != 4) fail(); if (testi.y != 6) fail(); if (testi.z != 8) fail(); } Console::write_line(" Function: operator * (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); testd = testd * Vec3d(1.5, 2.5, 3.5); if (testd.x != 3.75) fail(); if (testd.y != 8.75) fail(); if (testd.z != 15.75) fail(); Vec3i testi(2, 3, 4); testi = testi * Vec3i(1, 2, 3); if (testi.x != 2) fail(); if (testi.y != 6) fail(); if (testi.z != 12) fail(); } Console::write_line(" Function: operator /= (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); testd /= Vec3d(1.0, 2.0, 3.0); if (testd.x != 2.5) fail(); if (testd.y != 1.75) fail(); if (testd.z != 1.5) fail(); Vec3i testi(2, 10, 20); testi /= Vec3i(1, 2, 3); if (testi.x != 2) fail(); if (testi.y != 5) fail(); if (testi.z != 6) fail(); } Console::write_line(" Function: operator /= ( Type value)"); { Vec3d testd(2.5, 3.5, 4.5); double valued = 2.0; testd /= valued; if (testd.x != 1.25) fail(); if (testd.y != 1.75) fail(); if (testd.z != 2.25) fail(); Vec3i testi(2, 10, 20); int valuei = 2; testi /= valuei; if (testi.x != 1) fail(); if (testi.y != 5) fail(); if (testi.z != 10) fail(); } Console::write_line(" Function: operator / (Type value)"); { Vec3d testd(2.5, 3.5, 4.5); double valued = 2.0; testd = testd / valued; if (testd.x != 1.25) fail(); if (testd.y != 1.75) fail(); if (testd.z != 2.25) fail(); Vec3i testi(2, 10, 20); int valuei = 2; testi = testi / valuei; if (testi.x != 1) fail(); if (testi.y != 5) fail(); if (testi.z != 10) fail(); } Console::write_line(" Function: operator / (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); testd = testd / Vec3d(1.0, 2.5, 4.5); if (testd.x != 2.5) fail(); if (testd.y != 1.4) fail(); if (testd.z != 1.0) fail(); Vec3i testi(2, 10, 20); testi = testi / Vec3i(1, 2, 3); if (testi.x != 2) fail(); if (testi.y != 5) fail(); if (testi.z != 6) fail(); } Console::write_line(" Function: operator = (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); testd = Vec3d(1.0, 2.0, 3.0); if (testd.x != 1.0) fail(); if (testd.y != 2.0) fail(); if (testd.z != 3.0) fail(); Vec3i testi(2, 3, 4); testi = Vec3i(1, 2, 3); if (testi.x != 1) fail(); if (testi.y != 2) fail(); if (testi.z != 3) fail(); } Console::write_line(" Function: operator == (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); if (testd == Vec3d(1.0, 2.0, 3.0)) fail(); if (testd == Vec3d(2.5, 2.0, 3.0)) fail(); if (testd == Vec3d(2.5, 3.5, 3.0)) fail(); if (!(testd == Vec3d(2.5, 3.5, 4.5))) fail(); Vec3i testi(2, 3, 4); if (testi == Vec3i(1, 2, 3)) fail(); if (testi == Vec3i(2, 2, 3)) fail(); if (testi == Vec3i(2, 3, 3)) fail(); if (!(testi == Vec3i(2, 3, 4))) fail(); } Console::write_line(" Function: operator != (const Vec3<Type>& vector)"); { Vec3d testd(2.5, 3.5, 4.5); if (!(testd != Vec3d(1.0, 2.0, 3.0))) fail(); if (!(testd != Vec3d(2.5, 2.0, 3.0))) fail(); if (!(testd != Vec3d(2.5, 3.5, 3.0))) fail(); if ((testd != Vec3d(2.5, 3.5, 4.5))) fail(); Vec3i testi(2, 3, 4); if (!(testi != Vec3i(1, 2, 3))) fail(); if (!(testi != Vec3i(2, 2, 3))) fail(); if (!(testi != Vec3i(2, 3, 3))) fail(); if ((testi != Vec3i(2, 3, 4))) fail(); } Console::write_line(" Function: round()"); { Vec3d testd(2.0, 2.5, -2.0); testd.round(); if (testd.x != 2.0) fail(); if (testd.y != 3.0) fail(); if (testd.z != -2.0) fail(); Vec3f testf(2.0f, 2.5f, -2.0f); testf.round(); if (testf.x != 2.0f) fail(); if (testf.y != 3.0f) fail(); if (testf.z != -2.0f) fail(); } Console::write_line(" Function: static round()"); { Vec3d testd(2.0, 2.5, -2.0); Vec3d destd = Vec3d::round(testd); if (destd.x != 2.0) fail(); if (destd.y != 3.0) fail(); if (destd.z != -2.0) fail(); Vec3f testf(2.0f, 2.5f, -2.0f); Vec3f destf = Vec3f::round(testf); if (destf.x != 2.0f) fail(); if (destf.y != 3.0f) fail(); if (destf.z != -2.0f) fail(); } Console::write_line(" Function: Vec3<Type> operator * (const Mat3<Type>& matrix, const Vec3<Type>& v)"); { /// Matrix is assumed to be in the Column-Major matrix format (opengl native)\n Mat3f matrix(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f); Vec3f vector(1.0f, 2.0f, 3.0f); Vec3f result = matrix * vector; if (result.x != ( (matrix[0 + 3*0] * vector.x) + (matrix[0 + 3*1] * vector.y) + (matrix[0 + 3*2] * vector.z) ) ) fail(); if (result.y != ( (matrix[1 + 3*0] * vector.x) + (matrix[1 + 3*1] * vector.y) + (matrix[1 + 3*2] * vector.z) ) ) fail(); if (result.z != ( (matrix[2 + 3*0] * vector.x) + (matrix[2 + 3*1] * vector.y) + (matrix[2 + 3*2] * vector.z) ) ) fail(); } }
void TestApp::test_vector4(void) { Console::write_line(" Header: cl_vector.h"); Console::write_line(" Class: Vec4"); Console::write_line(" Function: distance3()"); { Vec4d test_a(2.0,3.0,4.0,5.0); Vec4d test_b(3.0,4.0,5.0,6.0); if (test_a.distance3(test_b) != sqrt(1.0 + 1.0 + 1.0 )) fail(); } Console::write_line(" Function: distance4()"); { Vec4d test_a(2.0,3.0,4.0,5.0); Vec4d test_b(3.0,4.0,5.0,6.0); if (test_a.distance4(test_b) != sqrt(1.0 + 1.0 + 1.0 + 1.0 )) fail(); } Console::write_line(" Function: length3()"); { Vec4d testi(3.0,4.0,5.0,6.0); if (testi.length3() != sqrt(50.0 )) fail(); } Console::write_line(" Function: length4()"); { Vec4d testi(3.0,4.0,5.0,6.0); if (testi.length4() != sqrt(86.0 )) fail(); } Console::write_line(" Function: normalize3()"); { Vec4d testi(3.0,4.0,5.0,6.0); testi.normalize3(); if (testi != Vec4d(3.0/sqrt(50.0), 4.0/sqrt(50.0), 5.0/sqrt(50.0), 6.0)) fail(); } Console::write_line(" Function: static normalize3()"); { Vec4d testi(3.0,4.0,5.0,6.0); if (Vec4d::normalize3(testi) != Vec4d(3.0/sqrt(50.0), 4.0/sqrt(50.0), 5.0/sqrt(50.0), 6.0)) fail(); } Console::write_line(" Function: dot3()"); { Vec4d test_a(3.0,4.0,5.0,6.0); Vec4d test_b(13.0,14.0,15.0,16.0); if (test_a.dot3(test_b) != ((3.0 * 13.0)+ (4.0*14.0) + (5.0 * 15.0))) fail(); } Console::write_line(" Function: dot4()"); { Vec4d test_a(3.0,4.0,5.0,6.0); Vec4d test_b(13.0,14.0,15.0,16.0); if (test_a.dot4(test_b) != ((3.0 * 13.0)+ (4.0*14.0) + (5.0 * 15.0) + (6.0 * 16.0))) fail(); } Console::write_line(" Function: normalize4()"); { Vec4d testi(3.0,4.0,5.0,6.0); testi.normalize4(); if (testi != Vec4d(3.0/sqrt(86.0), 4.0/sqrt(86.0), 5.0/sqrt(86.0), 6.0/sqrt(86.0))) fail(); } Console::write_line(" Function: static normalize4()"); { Vec4d testi(3.0,4.0,5.0,6.0); if (Vec4d::normalize4(testi) != Vec4d(3.0/sqrt(86.0), 4.0/sqrt(86.0), 5.0/sqrt(86.0), 6.0/sqrt(86.0))) fail(); } Console::write_line(" Function: operator += (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); testd += Vec4d(1.0, 2.0, 3.0, 4.0); if (testd.x != 3.5) fail(); if (testd.y != 5.5) fail(); if (testd.z != 7.5) fail(); if (testd.w != 9.5) fail(); Vec4i testi(2, 3, 4, 5); testi += Vec4i(1, 2, 3, 4); if (testi.x != 3) fail(); if (testi.y != 5) fail(); if (testi.z != 7) fail(); if (testi.w != 9) fail(); } Console::write_line(" Function: operator += ( Type value)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); double valued = 2.0; testd += valued; if (testd.x != 4.5) fail(); if (testd.y != 5.5) fail(); if (testd.z != 6.5) fail(); if (testd.w != 7.5) fail(); Vec4i testi(2, 3, 4, 5); int valuei = 2; testi += valuei; if (testi.x != 4) fail(); if (testi.y != 5) fail(); if (testi.z != 6) fail(); if (testi.w != 7) fail(); } Console::write_line(" Function: operator + (Type value)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); double valued = 2.0; testd = testd + valued; if (testd.x != 4.5) fail(); if (testd.y != 5.5) fail(); if (testd.z != 6.5) fail(); if (testd.w != 7.5) fail(); Vec4i testi(2, 3, 4, 5); int valuei = 2; testi = testi + valuei; if (testi.x != 4) fail(); if (testi.y != 5) fail(); if (testi.z != 6) fail(); if (testi.w != 7) fail(); } Console::write_line(" Function: operator + (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); testd = testd + Vec4d(1.5, 2.5, 3.5, 4.5); if (testd.x != 4.0) fail(); if (testd.y != 6.0) fail(); if (testd.z != 8.0) fail(); if (testd.w != 10.0) fail(); Vec4i testi(2, 3, 4, 5); testi = testi + Vec4i(1, 2, 3, 4); if (testi.x != 3) fail(); if (testi.y != 5) fail(); if (testi.z != 7) fail(); if (testi.w != 9) fail(); } Console::write_line(" Function: operator -= (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); testd -= Vec4d(1.0, 2.0, 3.0, 4.0); if (testd.x != 1.5) fail(); if (testd.y != 1.5) fail(); if (testd.z != 1.5) fail(); if (testd.w != 1.5) fail(); Vec4i testi(2, 3, 4, 5); testi -= Vec4i(1, 2, 3, 4); if (testi.x != 1) fail(); if (testi.y != 1) fail(); if (testi.z != 1) fail(); if (testi.w != 1) fail(); } Console::write_line(" Function: operator -= ( Type value)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); double valued = 2.0; testd -= valued; if (testd.x != 0.5) fail(); if (testd.y != 1.5) fail(); if (testd.z != 2.5) fail(); if (testd.w != 3.5) fail(); Vec4i testi(2, 3, 4, 5); int valuei = 2; testi -= valuei; if (testi.x != 0) fail(); if (testi.y != 1) fail(); if (testi.z != 2) fail(); if (testi.w != 3) fail(); } Console::write_line(" Function: operator - (Type value)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); double valued = 2.0; testd = testd - valued; if (testd.x != 0.5) fail(); if (testd.y != 1.5) fail(); if (testd.z != 2.5) fail(); if (testd.w != 3.5) fail(); Vec4i testi(2, 3, 4, 5); int valuei = 2; testi = testi - valuei; if (testi.x != 0) fail(); if (testi.y != 1) fail(); if (testi.z != 2) fail(); if (testi.w != 3) fail(); } Console::write_line(" Function: operator - (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); testd = testd - Vec4d(1.5, 2.5, 3.5, 4.5); if (testd.x != 1.0) fail(); if (testd.y != 1.0) fail(); if (testd.z != 1.0) fail(); if (testd.w != 1.0) fail(); Vec4i testi(2, 3, 4, 5); testi = testi - Vec4i(1, 2, 3, 4); if (testi.x != 1) fail(); if (testi.y != 1) fail(); if (testi.z != 1) fail(); if (testi.w != 1) fail(); } Console::write_line(" Function: operator *= (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); testd *= Vec4d(1.0, 2.0, 3.0, 4.0); if (testd.x != 2.5) fail(); if (testd.y != 7.0) fail(); if (testd.z != 13.5) fail(); if (testd.w != 22.0) fail(); Vec4i testi(2, 3, 4, 5); testi *= Vec4i(1, 2, 3, 4); if (testi.x != 2) fail(); if (testi.y != 6) fail(); if (testi.z != 12) fail(); if (testi.w != 20) fail(); } Console::write_line(" Function: operator *= ( Type value)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); double valued = 2.0; testd *= valued; if (testd.x != 5.0) fail(); if (testd.y != 7.0) fail(); if (testd.z != 9.0) fail(); if (testd.w != 11.0) fail(); Vec4i testi(2, 3, 4, 5); int valuei = 2; testi *= valuei; if (testi.x != 4) fail(); if (testi.y != 6) fail(); if (testi.z != 8) fail(); if (testi.w != 10) fail(); } Console::write_line(" Function: operator * (Type value)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); double valued = 2.0; testd = testd * valued; if (testd.x != 5.0) fail(); if (testd.y != 7.0) fail(); if (testd.z != 9.0) fail(); if (testd.w != 11.0) fail(); Vec4i testi(2, 3, 4, 5); int valuei = 2; testi = testi * valuei; if (testi.x != 4) fail(); if (testi.y != 6) fail(); if (testi.z != 8) fail(); if (testi.w != 10) fail(); } Console::write_line(" Function: operator * (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); testd = testd * Vec4d(1.5, 2.5, 3.5, 4.5); if (testd.x != 3.75) fail(); if (testd.y != 8.75) fail(); if (testd.z != 15.75) fail(); if (testd.w != 24.75) fail(); Vec4i testi(2, 3, 4, 5); testi = testi * Vec4i(1, 2, 3, 4); if (testi.x != 2) fail(); if (testi.y != 6) fail(); if (testi.z != 12) fail(); if (testi.w != 20) fail(); } Console::write_line(" Function: operator /= (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); testd /= Vec4d(1.0, 2.0, 3.0, 4.0); if (testd.x != 2.5) fail(); if (testd.y != 1.75) fail(); if (testd.z != 1.5) fail(); if (testd.w != 1.375) fail(); Vec4i testi(2, 10, 20, 5); testi /= Vec4i(1, 2, 3, 4); if (testi.x != 2) fail(); if (testi.y != 5) fail(); if (testi.z != 6) fail(); if (testi.w != 1) fail(); } Console::write_line(" Function: operator /= ( Type value)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); double valued = 2.0; testd /= valued; if (testd.x != 1.25) fail(); if (testd.y != 1.75) fail(); if (testd.z != 2.25) fail(); if (testd.w != 2.75) fail(); Vec4i testi(2, 10, 20, 5); int valuei = 2; testi /= valuei; if (testi.x != 1) fail(); if (testi.y != 5) fail(); if (testi.z != 10) fail(); if (testi.w != 2) fail(); } Console::write_line(" Function: operator / (Type value)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); double valued = 2.0; testd = testd / valued; if (testd.x != 1.25) fail(); if (testd.y != 1.75) fail(); if (testd.z != 2.25) fail(); if (testd.w != 2.75) fail(); Vec4i testi(2, 10, 20, 5); int valuei = 2; testi = testi / valuei; if (testi.x != 1) fail(); if (testi.y != 5) fail(); if (testi.z != 10) fail(); if (testi.w != 2) fail(); } Console::write_line(" Function: operator / (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 10.0); testd = testd / Vec4d(1.0, 2.5, 4.5, 2.0); if (testd.x != 2.5) fail(); if (testd.y != 1.4) fail(); if (testd.z != 1.0) fail(); if (testd.w != 5.0) fail(); Vec4i testi(2, 10, 20, 5); testi = testi / Vec4i(1, 2, 3, 4); if (testi.x != 2) fail(); if (testi.y != 5) fail(); if (testi.z != 6) fail(); if (testi.w != 1) fail(); } Console::write_line(" Function: operator = (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); testd = Vec4d(1.0, 2.0, 3.0, 4.0); if (testd.x != 1.0) fail(); if (testd.y != 2.0) fail(); if (testd.z != 3.0) fail(); if (testd.w != 4.0) fail(); Vec4i testi(2, 3, 4, 5); testi = Vec4i(1, 2, 3, 4); if (testi.x != 1) fail(); if (testi.y != 2) fail(); if (testi.z != 3) fail(); if (testi.w != 4) fail(); } Console::write_line(" Function: operator == (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); if (testd == Vec4d(1.0, 2.0, 3.0, 4.0)) fail(); if (testd == Vec4d(2.5, 2.0, 3.0, 4.0)) fail(); if (testd == Vec4d(2.5, 3.5, 3.0, 4.0)) fail(); if (testd == Vec4d(2.5, 3.5, 4.5, 4.0)) fail(); if (!(testd == Vec4d(2.5, 3.5, 4.5, 5.5))) fail(); Vec4i testi(2, 3, 4, 5); if (testi == Vec4i(1, 2, 3, 4)) fail(); if (testi == Vec4i(2, 2, 3, 4)) fail(); if (testi == Vec4i(2, 3, 3, 4)) fail(); if (testi == Vec4i(2, 3, 4, 4)) fail(); if (!(testi == Vec4i(2, 3, 4, 5))) fail(); } Console::write_line(" Function: operator != (const Vec4<Type>& vector)"); { Vec4d testd(2.5, 3.5, 4.5, 5.5); if (!(testd != Vec4d(1.0, 2.0, 3.0, 4.0))) fail(); if (!(testd != Vec4d(2.5, 2.0, 3.0, 4.0))) fail(); if (!(testd != Vec4d(2.5, 3.5, 3.0, 4.0))) fail(); if (!(testd != Vec4d(2.5, 3.5, 4.5, 4.0))) fail(); if ((testd != Vec4d(2.5, 3.5, 4.5, 5.5))) fail(); Vec4i testi(2, 3, 4, 5); if (!(testi != Vec4i(1, 2, 3, 4))) fail(); if (!(testi != Vec4i(2, 2, 3, 4))) fail(); if (!(testi != Vec4i(2, 3, 3, 4))) fail(); if (!(testi != Vec4i(2, 3, 4, 4))) fail(); if ((testi != Vec4i(2, 3, 4, 5))) fail(); } Console::write_line(" Function: round()"); { Vec4d testd(2.0, 2.5, -2.0, -2.5); testd.round(); if (testd.x != 2.0) fail(); if (testd.y != 3.0) fail(); if (testd.z != -2.0) fail(); if (testd.w != -2.0) fail(); Vec4f testf(2.0f, 2.5f, -2.0f, -2.9f); testf.round(); if (testf.x != 2.0f) fail(); if (testf.y != 3.0f) fail(); if (testf.z != -2.0f) fail(); if (testf.w != -3.0f) fail(); } Console::write_line(" Function: static round()"); { Vec4d testd(2.0, 2.5, -2.0, -2.5); Vec4d destd = Vec4d::round(testd); if (destd.x != 2.0) fail(); if (destd.y != 3.0) fail(); if (destd.z != -2.0) fail(); if (destd.w != -2.0) fail(); Vec4f testf(2.0f, 2.5f, -2.0f, -2.9f); Vec4f destf = Vec4f::round(testf); if (destf.x != 2.0f) fail(); if (destf.y != 3.0f) fail(); if (destf.z != -2.0f) fail(); if (destf.w != -3.0f) fail(); } }
void test2(double (*z)(double a, double b, double (*f)(double x), double t)) { testf(z, stringfunc1, "Method 1: intuitive method"); testf(z, stringfunc2, "Method 2: Taylor expansion"); testf(z, stringfunc3, "Method 3: Horner's rule"); }