int main() { CIMClient client; try { client.connectLocal(); } catch (Exception& e) { PEGASUS_STD (cerr) << "Exception: " << e.getMessage() << PEGASUS_STD (endl); PEGASUS_STD (cerr) << "connectLocal failed" << PEGASUS_STD (endl); return -1; } String query1="SELECT MethodName FROM Test_IndicationProviderClass"; // Note that CQL expects single quote around string literals, // while WQL expects double quote. // Note that CQL use <> for the inequality operator. String query2wql = "SELECT MethodName FROM Test_IndicationProviderClass " "WHERE IndicationIdentifier != \"x\""; String query2cql = "SELECT MethodName FROM Test_IndicationProviderClass " "WHERE IndicationIdentifier <> 'x'"; String wql("WQL"); String cql("DMTF:CQL"); PEGASUS_STD (cout) << "+++++ start wql test" << PEGASUS_STD (endl); int rc; rc = _test(client, wql, query1, query2wql); if (rc != 0) return rc; PEGASUS_STD (cout) << "+++++ start dupliacte subscription test" << PEGASUS_STD (endl); _testDuplicate(client); PEGASUS_STD (cout) << "+++++ duplicate subscription test completed" << PEGASUS_STD (endl); PEGASUS_STD (cout) << "+++++ start concurrent subscription test" << PEGASUS_STD (endl); _testConcurrent(client); PEGASUS_STD (cout) << "+++++ concurrent subscription test completed" << PEGASUS_STD (endl); #ifdef PEGASUS_ENABLE_CQL PEGASUS_STD (cout) << "+++++ start cql test" << PEGASUS_STD (endl); return _test(client, cql, query1, query2cql); #else PEGASUS_STD (cout) << "+++++ cql test disabled" << PEGASUS_STD (endl); return 0; #endif }
int main(int argc, char* argv[]) { if (argc != 2) { err_quit("usage: ls dir_name"); } _test(); struct point pt; pt.x = 100; pt.y = 200; struct point* p2pt = &pt; p2pt->x = 300; p2pt->y = 400; printf("point value: %d, %d", pt.x, p2pt->y); int sum = add(100, 200); DIR* dir; struct dirent* dirp; if ((dir = opendir(argv[1])) == NULL) { err_sys("can't open %s", argv[1]); } while ((dirp= readdir(dir)) != NULL) { printf("%s\n", dirp->d_name); } closedir(dir); exit(0); }
void test_quotes() { GList *seps = g_list_new("\n", " ", NULL); GList *quotes = g_list_new("{", "}", NULL); Scanner *scn = scanner_new2(seps, quotes); _test("quotes test", scn, "tq", "tq_out", "tq_ver"); }
void test_same_quote() { GList *seps = g_list_new("\n", " ", "-", ":", NULL); GList *quotes = g_list_new("\"", NULL); Scanner *scn = scanner_new2(seps, quotes); _test("same quote test", scn, "sq", "sq_out", "sq_ver"); }
inline SceneZoneCullingState::CullingTestResult SceneCullingState::_test( const T& bounds, const U32* zones, U32 numZones ) const { // If zone culling is disabled, only test against // the root frustum. if( disableZoneCulling() ) { if( !OCCLUDERS_ONLY && !getCullingFrustum().isCulled( bounds ) ) return SceneZoneCullingState::CullingTestPositiveByInclusion; return SceneZoneCullingState::CullingTestNegative; } // Otherwise test each of the zones. if( OCCLUDERS_ONLY ) { return _testOccludersOnly( bounds, ZoneArrayIterator( zones, numZones ) ); } else { const PlaneF* frustumPlanes = getCullingFrustum().getPlanes(); return _test( bounds, ZoneArrayIterator( zones, numZones ), frustumPlanes[ Frustum::PlaneNear ], frustumPlanes[ Frustum::PlaneFar ] ); } }
int main (int argc, char** argv) { CIMClient client; try { client.connectLocal (); } catch (Exception & e) { PEGASUS_STD (cerr) << e.getMessage () << PEGASUS_STD (endl); return -1; } if (argc != 3) { _usage (); return 1; } const char* opt = argv[1]; const char* optLang = argv[2]; String qlang(optLang); #ifndef PEGASUS_ENABLE_CQL if (qlang == "DMTF:CQL") { PEGASUS_STD(cout) << "+++++ cql test disabled" << PEGASUS_STD(endl); return 0; } #endif return _test(client, opt, qlang); }
void test_varlen_seps() { GList *seps = g_list_new("\n", " ", "--", "###", "=", "~~~", NULL); GList *quotes = g_list_new("%{", "}", NULL); Scanner *scn = scanner_new2(seps, quotes); _test("string test", scn, "tvl", "tvl_out", "tvl_ver"); }
void test_string() { GList *seps = g_list_new("-", " ", NULL); GList *quotes = g_list_new("{", "}", NULL); Scanner *scn = scanner_new2(seps, quotes); scanner_set_str_stream(scn, "how do y{ou sleep at{ ni}ght you he}-athen beast?"); _test("string test", scn, NULL, "ts_out", "ts_ver"); }
void test_vector_init() { char *seps[5] = {"\n", " ", "-", ":", NULL}; GList *quotes = g_list_new("\"", NULL); Scanner *scn = scanner_new_v(seps); scanner_set_quotes(scn, quotes); _test("same quote test", scn, "sq", "sq_out", "sq_ver"); }
void TestStatistics::testAll() { std::vector<double> data; data.push_back(20.48); data.push_back(20.32); data.push_back(20.57); data.push_back(19.73); _test( closeEnough(Statistics::sum(data), 81.1, 0.0001)); _test( closeEnough(Statistics::average(data), 20.275, 0.0001)); _test( closeEnough(Statistics::sumOfSquares(data,20.275), 0.4281, 0.0001)); std::cout << Statistics::sumOfSquares(data, 20.275) << std::endl; _test( closeEnough(Statistics::variance(data), 0.1427, 0.0001)); }
int main() { int i; cucon_init(); for (i = 1; i < 400; ++i) _test(i); return 2*!!cu_test_bug_count(); }
TEST(Thread, contextTest) { int32_t newval = 4; ThreadTest _test(newval); { capu::Thread thread; thread.start(_test); } EXPECT_EQ(newval, ThreadTest::variable); }
// Representation invariant bool TestNode::OK() const { EmptyListNode empty; assert (CallNode::OK()); // Check if argument is 3-element list assert (arg() && arg()->isListNode()); assert (_test() && _test()->tail() && _test()->tail()->isListNode()); assert (_true() && _true()->tail() && _true()->tail()->isListNode()); assert (_false() && _false()->tail() && *(_false()->tail()) == empty); // Check if list elements exist assert (test()); assert (thetrue()); assert (thefalse()); return true; }
TEST(Thread, startAndDestructorTest) { int32_t newval = 6; ThreadTest _test(newval); capu::Thread* CAPU_thread = new capu::Thread(); CAPU_thread->start(_test); delete CAPU_thread; EXPECT_EQ(newval, ThreadTest::variable); }
TEST(Thread, sleepTest) { int32_t newval = 5; ThreadTest _test(newval); //CREATE THREAD capu::Thread* CAPU_thread = new capu::Thread(); CAPU_thread->start(_test); //WAIT UNTIL IT FINISH EXPECT_EQ(capu::CAPU_OK, CAPU_thread->join()); EXPECT_EQ(newval, ThreadTest::variable); delete CAPU_thread; }
void TestPseudoRandom::testSetSeed() { /* first number should be 0 */ PseudoRandomTestsOnly x; double number = x.getPseudoRandom(); _test(number == 0.0); /* 2nd number should be 0.001 */ number = x.getPseudoRandom(); _test(fabs(number-0.001) < 0.0001); /* new number should be 0.500 */ x.setSeed(500); number = x.getPseudoRandom(); _test(fabs(number - 0.500) < 0.0001); /* 2nd number should be 0.501 */ number = x.getPseudoRandom(); _test(fabs(number-.501) < 0.0001); /* new number should be 0.999 */ x.setSeed(999); number = x.getPseudoRandom(); _test(fabs(number - 0.999) < 0.0001); /* 2nd number should be 0.000 */ number = x.getPseudoRandom(); _test(fabs(number - 0.0) < 0.0001); }
void TestPseudoRandom::testGetPseudoRandom(){ /* first number should be 0 */ PseudoRandomTestsOnly x; double number = x.getPseudoRandom(); _test(number == 0.0); /* 2nd number should be 0.001 */ number = x.getPseudoRandom(); _test(fabs(number-0.001) < 0.0001); /* 3rd number should be 0.002 */ number = x.getPseudoRandom(); _test(fabs(number-0.002) < 0.0001); /* 4th number should be 0.003 */ number = x.getPseudoRandom(); _test(fabs(number-0.003) < 0.0001); /* new number should be 0.998 */ x.setSeed(998); number = x.getPseudoRandom(); _test(fabs(number-0.998) < 0.0001); /* 2nd number should be 0.999 */ number = x.getPseudoRandom(); _test(fabs(number-0.999) < 0.0001); /* 3rd number should be 0.0 */ number = x.getPseudoRandom(); _test(fabs(number-0.0) < 0.0001); /* 4th number should be 0.001 */ number = x.getPseudoRandom(); _test(fabs(number-0.001) < 0.0001); /* 5th number should be 0.002 */ number = x.getPseudoRandom(); _test(fabs(number-0.002) < 0.0001); }
int main() { cu_init(); _the_const_type = cuoo_type_new_opaque_hcs( cuoo_impl_none, sizeof(struct _const) - CUOO_HCOBJ_SHIFT); _the_tuple1_type = cuoo_type_new_opaque_hcs( cuoo_impl_none, sizeof(struct _tuple1) - CUOO_HCOBJ_SHIFT); _the_tuple2_type = cuoo_type_new_opaque_hcs( cuoo_impl_none, sizeof(struct _tuple2) - CUOO_HCOBJ_SHIFT); _the_tuple3_type = cuoo_type_new_opaque_hcs( cuoo_impl_none, sizeof(struct _tuple3) - CUOO_HCOBJ_SHIFT); _test(); return 2*!!cu_test_bug_count(); }
int main() { verbose = (getenv ("PEGASUS_TEST_VERBOSE")) ? true : false; CIMClient client; try { client.connectLocal (); } catch (Exception & e) { cerr << e.getMessage () << endl; return -1; } _test(client); return 0; }
char *z_init(void *getext, void *setext, char *args) { int argc; char *argv[16]; *(void **)(&z_getext) = getext; *(void **)(&z_setext) = setext; argc = _argsep(args, 16, argv); void (*_test)(); *(void **)(&_test) = z_getext("test"); _test(); return 0; }
int main (int argc, char **argv) { verbose = (getenv ("PEGASUS_TEST_VERBOSE")) ? true : false; CIMClient client; try { client.connectLocal (); client.setTimeout(400000); } catch (Exception & e) { cerr << e.getMessage () << endl; return -1; } if (argc != 2) { _usage (); return 1; } else { const char *opt = argv[1]; if (String::equalNoCase (opt, "test")) { _test (client); } else if (String::equalNoCase (opt, "cleanup")) { _cleanup (client); } else { cerr << "Invalid option: " << opt << endl; _usage (); return -1; } } return 0; }
int main (int argc, char **argv) { verbose = (getenv ("PEGASUS_TEST_VERBOSE")) ? true : false; useDefaultMsg = (getenv("PEGASUS_USE_DEFAULT_MESSAGES")) ? true : false; CIMClient client; try { client.connectLocal (); } catch (Exception & e) { cerr << e.getMessage () << endl; return -1; } if (argc != 3) { _usage (); return 1; } else { const char *opt = argv[1]; if (String::equalNoCase (opt, "test")) { providerNamespace = CIMNamespaceName (argv[2]); _test (client); } else { cerr << "Invalid option: " << opt << endl; _usage (); return -1; } } cout << argv[0] << " +++++ completed" << endl; return 0; }
TEST(Thread, startAndJoinTest) { ThreadTest _test(6); ThreadTest2 _test2; //CREATE THREAD capu::Thread* CAPU_thread = new capu::Thread(); CAPU_thread->start(_test); //WAIT UNTIL IT FINISH EXPECT_EQ(capu::CAPU_OK, CAPU_thread->join()); //CHECK THE VALUE CALCULATED IN THREAD EXPECT_EQ(6, ThreadTest::variable); delete CAPU_thread; capu::Thread* CAPU_thread2 = new capu::Thread(); CAPU_thread2->start(_test2); EXPECT_EQ(capu::CAPU_OK, CAPU_thread2->join()); // multiple join is not ok EXPECT_EQ(capu::CAPU_ERROR, CAPU_thread2->join()); delete CAPU_thread2; }
int main(int argc, char ** argv) { htparser * p = htparser_new(); htparse_hooks hooks = { .on_msg_begin = _on_msg_start, .method = _method, .scheme = NULL, .host = NULL, .port = NULL, .path = _path, .args = _args, .uri = _uri, .on_hdrs_begin = _hdrs_start, .hdr_key = _hdr_key, .hdr_val = _hdr_val, .on_hdrs_complete = _hdrs_end, .on_new_chunk = _on_new_chunk, .on_chunk_complete = NULL, .on_chunks_complete = NULL, .body = _read_body, .on_msg_complete = _on_msg_end }; const char * test_1 = "GET / HTTP/1.0\r\n\r\n"; const char * test_2 = "GET /hi?a=b&c=d HTTP/1.1\r\n\r\n"; const char * test_3 = "GET /hi/die/?a=b&c=d HTTP/1.1\r\n\r\n"; const char * test_4 = "POST /fjdls HTTP/1.0\r\n" "Content-Length: 4\r\n" "\r\n" "abcd"; const char * test_7 = "POST /derp HTTP/1.1\r\n" "Transfer-Encoding: chunked\r\n\r\n" "1e\r\nall your base are belong to us\r\n" "0\r\n" "\r\n\0"; const char * test_8 = "GET /DIE HTTP/1.1\r\n" "HERP: DE\r\n" "\tRP\r\nthings:stuff\r\n\r\n"; const char * test_9 = "GET /big_content_len HTTP/1.1\r\n" "Content-Length: 18446744073709551615\r\n\r\n"; const char * test_fail = "GET /JF HfD]\r\n\r\n"; const char * test_resp_1 = "HTTP/1.0 200 OK\r\n" "Stuff: junk\r\n\r\n"; const char * test_empty_header = "GET /blah HTTP/1.1\r\n" "Empty: \r\n" "Stuff: junk\r\n\r\n"; const char * test_resp_empty_header = "HTTP/1.1 200 OK\r\n" "Empty: \r\n" "Things: junk\r\n\r\n"; const char * test_no_cr = "GET / HTTP/1.1\n" "Host: stuff\n" "Things: blah\n\n"; const char * test_no_hdr_cr = "GET / HTTP/1.1\r\n" "Host: things\n" "Stuff: blah\n\n"; const char * test_no_hdr_cr_end = "GET / HTTP/1.1\r\n" "Host: blah\r\n" "things: stuff\n\n\r\n"; _test(p, &hooks, test_resp_1, htp_type_response); _test(p, &hooks, test_1, htp_type_request); _test(p, &hooks, test_2, htp_type_request); _test(p, &hooks, test_3, htp_type_request); _test(p, &hooks, test_4, htp_type_request); _test(p, &hooks, test_7, htp_type_request); _test(p, &hooks, test_8, htp_type_request); _test(p, &hooks, test_9, htp_type_request); _test(p, &hooks, test_fail, htp_type_request); _test(p, &hooks, test_empty_header, htp_type_request); _test(p, &hooks, test_resp_empty_header, htp_type_response); _test(p, &hooks, test_no_cr, htp_type_request); _test(p, &hooks, test_no_hdr_cr, htp_type_request); _test(p, &hooks, test_no_hdr_cr_end, htp_type_request); _test_fragments(p, &hooks, test_fragment_1, htp_type_request); _test_fragments(p, &hooks, test_fragment_2, htp_type_request); _test_fragments(p, &hooks, test_chunk_fragment_1, htp_type_request); _test_fragments(p, &hooks, test_chunk_fragment_2, htp_type_request); return 0; } /* main */
U32 SceneCullingState::cullObjects( SceneObject** objects, U32 numObjects, U32 cullOptions ) const { PROFILE_SCOPE( SceneCullingState_cullObjects ); U32 numRemainingObjects = 0; // We test near and far planes separately in order to not do the tests // repeatedly, so fetch the planes now. const PlaneF& nearPlane = getCullingFrustum().getPlanes()[ Frustum::PlaneNear ]; const PlaneF& farPlane = getCullingFrustum().getPlanes()[ Frustum::PlaneFar ]; for( U32 i = 0; i < numObjects; ++ i ) { SceneObject* object = objects[ i ]; bool isCulled = true; // If we should respect editor overrides, test that now. if( !( cullOptions & CullEditorOverrides ) && gEditingMission && ( ( object->isCullingDisabledInEditor() && object->isRenderEnabled() ) || object->isSelected() ) ) { isCulled = false; } // If the object is render-disabled, it gets culled. The only // way around this is the editor override above. else if( !( cullOptions & DontCullRenderDisabled ) && !object->isRenderEnabled() ) { isCulled = true; } // Global bounds objects are never culled. Note that this means // that if these objects are to respect zoning, they need to manually // trigger the respective culling checks for whatever they want to // batch. else if( object->isGlobalBounds() ) isCulled = false; // If terrain occlusion checks are enabled, run them now. else if( !mDisableTerrainOcclusion && object->getWorldBox().minExtents.x > -1e5 && isOccludedByTerrain( object ) ) { // Occluded by terrain. isCulled = true; } // If the object shouldn't be subjected to more fine-grained culling // or if zone culling is disabled, just test against the root frustum. else if( !( object->getTypeMask() & CULLING_INCLUDE_TYPEMASK ) || ( object->getTypeMask() & CULLING_EXCLUDE_TYPEMASK ) || disableZoneCulling() ) { isCulled = getCullingFrustum().isCulled( object->getWorldBox() ); } // Go through the zones that the object is assigned to and // test the object against the frustums of each of the zones. else { CullingTestResult result = _test( object->getWorldBox(), SceneObject::ObjectZonesIterator( object ), nearPlane, farPlane ); isCulled = ( result == SceneZoneCullingState::CullingTestNegative || result == SceneZoneCullingState::CullingTestPositiveByOcclusion ); } if( !isCulled ) isCulled = isOccludedWithExtraPlanesCull( object->getWorldBox() ); if( !isCulled ) objects[ numRemainingObjects ++ ] = object; } return numRemainingObjects; }
void TestDDaceArraySampler::testDDaceSamplePoint() { /* create a sampler */ /* In this example, our sampler is storing */ /* our data samples or measurments. */ std::vector < std::vector < double > > array(3,std::vector<double>(2)); array[0][0] = 1.0; array[0][1] = 2.0; array[1][0] = 11.0; array[1][1] = 12.0; array[2][0] = 21.0; array[2][1] = 22.0; DDaceSampler sampler = DDaceArraySampler(array); /* The input values should be 1, 2, 11, 12, 21, 22 */ std::vector< DDaceSamplePoint > data; sampler.getSamples(data); _test(data[0][0]==1.0); _test(data[0][1]==2.0); _test(data[1][0]==11.0); _test(data[1][1]==12.0); _test(data[2][0]==21.0); _test(data[2][1]==22.0); /* get the lower and upper bounds of each input variable */ std::vector < double > lowerBounds; lowerBounds = sampler.lowerBounds(); std::vector < double > upperBounds; upperBounds = sampler.upperBounds(); /* The lower bound for the first variable should be 1.0 */ /* The upper bound for the first variable should be 21.0 */ _test(lowerBounds[0]==1.0); _test(upperBounds[0]==21.0); /* The lower bound for the 2nd variable should be 2.0 */ /* The upper bound for the 2nd variable should be 22.0 */ _test(lowerBounds[1]==2.0); _test(upperBounds[1]==22.0); /* Create a name for every input variable in our samples */ std::vector<std::string> variableNames(2); variableNames[0] = "x1"; variableNames[1] = "x2"; /* Create a name for every output variable in our samples */ std::vector<std::string> outputNames(1, "y(x1,x2)"); // /* encapsulate everything into a DDace object */ // DDace ddace // (sampler, //contains (x,y) pair of input data // variableNames, //names of all variables // outputNames, //name of all user-defined functions // "userInputArchive.xml"); //name of output file // // PMachine::synchronize(PWorld()); // // /* extract the input data */ // Array< DDaceSamplePoint > dataInput; // Array< Array < double > > dataOutput; // ddace.getResults(dataInput, dataOutput); // // PMachine::synchronize(PWorld()); // // /* The input data should have 3 samples or runs */ // if (PMachine::getRank()==0) { // int numberOfSamples = dataInput.length(); // _test(numberOfSamples==3); // } // // PMachine::synchronize(PWorld()); // // /* Each sample or run should contain values for 2 input variables */ // if (PMachine::getRank()==0) { // int numberOfSamples = dataInput.length(); // int numberOfInputVariables = 0; // if (numberOfSamples > 0) // numberOfInputVariables = dataInput[0].length(); // // _test(numberOfInputVariables==2); // _test(dataInput[0][0]==1.0); // _test(dataInput[0][1]==2.0); // _test(dataInput[1][0]==11.0); // _test(dataInput[1][1]==12.0); // _test(dataInput[2][0]==21.0); // _test(dataInput[2][1]==22.0); // } /* The name of the sampler should be a DDaceArraySampler */ // PMachine::synchronize(PWorld()); _test(!sampler.typeName().compare("DDaceArraySampler")); // /* Get the sampler from the ddace object */ // PMachine::synchronize(PWorld()); // if (PMachine::getRank()==0) { // DDaceSampler ddaceSampler; // ddace.getSampler(ddaceSampler); // // // /* The input values should be 1, 2, 11, 12, 21, 22 */ // ddaceSampler.getSamples(data); // _test(data[0][0]==1.0); // _test(data[0][1]==2.0); // _test(data[1][0]==11.0); // _test(data[1][1]==12.0); // _test(data[2][0]==21.0); // _test(data[2][1]==22.0); // } // PMachine::synchronize(PWorld()); }
int all_tests(){ _test(square_01); return 0; }
int main(int argc, char *argv[]) { _test(); return 0; }
/// Spawn the join sync test. static int _test_allreduce_join_sync_handler(void) { return _test(_join_sync_leaf); }
/// Spawn the set-get test. static int _test_allreduce_set_get_handler(void) { return _test(_set_get_leaf); }