int VBoxMainDriveInfo::updateDVDs () { LogFlowThisFunc(("entered\n")); int rc = VINF_SUCCESS; bool success = false; /* Have we succeeded in finding anything yet? */ try { mDVDList.clear (); /* Always allow the user to override our auto-detection using an * environment variable. */ if (RT_SUCCESS(rc) && (!success || testing())) rc = getDriveInfoFromEnv ("VBOX_CDROM", &mDVDList, true /* isDVD */, &success); setNoProbe(false); if (RT_SUCCESS(rc) && (!success | testing())) rc = getDriveInfoFromSysfs(&mDVDList, true /* isDVD */, &success); if (RT_SUCCESS(rc) && testing()) { setNoProbe(true); rc = getDriveInfoFromSysfs(&mDVDList, true /* isDVD */, &success); } /* Walk through the /dev subtree if nothing else has helped. */ if (RT_SUCCESS(rc) && (!success | testing())) rc = getDriveInfoFromDev(&mDVDList, true /* isDVD */, &success); } catch(std::bad_alloc &e) { rc = VERR_NO_MEMORY; } LogFlowThisFunc(("rc=%Rrc\n", rc)); return rc; }
int VBoxMainDriveInfo::updateFloppies () { LogFlowThisFunc(("entered\n")); int rc = VINF_SUCCESS; bool success = false; /* Have we succeeded in finding anything yet? */ try { mFloppyList.clear (); if (RT_SUCCESS(rc) && (!success || testing())) rc = getDriveInfoFromEnv("VBOX_FLOPPY", &mFloppyList, false /* isDVD */, &success); setNoProbe(false); if ( RT_SUCCESS(rc) && (!success || testing())) rc = getDriveInfoFromSysfs(&mFloppyList, false /* isDVD */, &success); if (RT_SUCCESS(rc) && testing()) { setNoProbe(true); rc = getDriveInfoFromSysfs(&mFloppyList, false /* isDVD */, &success); } /* Walk through the /dev subtree if nothing else has helped. */ if ( RT_SUCCESS(rc) && (!success || testing())) rc = getDriveInfoFromDev(&mFloppyList, false /* isDVD */, &success); } catch(std::bad_alloc &e) { rc = VERR_NO_MEMORY; } LogFlowThisFunc(("rc=%Rrc\n", rc)); return rc; }
int VBoxMainUSBDeviceInfo::UpdateDevices () { LogFlowThisFunc(("entered\n")); int rc = VINF_SUCCESS; bool success = false; /* Have we succeeded in finding anything yet? */ try { bool halSuccess = false; mDeviceList.clear(); #if defined(RT_OS_LINUX) #ifdef VBOX_WITH_DBUS if ( RT_SUCCESS(rc) && RT_SUCCESS(RTDBusLoadLib()) && (!success || testing())) rc = getUSBDeviceInfoFromHal(&mDeviceList, &halSuccess); /* Try the old API if the new one *succeeded* as only one of them will * pick up devices anyway. */ if (RT_SUCCESS(rc) && halSuccess && (!success || testing())) rc = getOldUSBDeviceInfoFromHal(&mDeviceList, &halSuccess); if (!success) success = halSuccess; #endif /* VBOX_WITH_DBUS defined */ #endif /* RT_OS_LINUX */ } catch(std::bad_alloc &e) { rc = VERR_NO_MEMORY; } LogFlowThisFunc(("rc=%Rrc\n", rc)); return rc; }
int main(void) { // make an array of test data int testArray1[6] = {1252,24623,31241,41242,55633,60059}; int testArray2[3] = {-1, -2, -3}; printf("Test #1:\n"); testing(testArray1, 6); printf("\n\n\nTest #2:\n"); testing(testArray2, 3); return(0); }
nemo_main() { testing(getparam("name"), getparam("mode"), getparam("text"), getbparam("delete")); if(hasvalue("name2")) testing(getparam("name2"), getparam("mode2"), getparam("text2"), getbparam("delete2")); }
int main(int argc, char * argv[]) { if (argc != 2) { printf("ERROR: NO INPUT FILE, QUITTING\n"); exit(1); } int ** numberArray; numberArray = parser(argv); testing(numberArray,100); testing(numberArray,200); testing(numberArray,250); free(numberArray); return(0); }
int main(int argc, char* argv[]) { Exampler test; int i; // parse options -- no option so far for(i=1;i<argc;i++) { if(argv[i][0] != '-') break; ++i; switch(argv[i-1][1]) { default: fprintf(stderr,"unknown option\n"); } } // determine filenames if(i>=(argc - 2)) exit_with_help(); std::cout << "Loading Test Data" << std::endl; test.libsvm_load_data(argv[i], false); std::cout << "\nLoading Model" << std::endl; char* model_file = argv[i+1]; Machine* svm_load = load_model(model_file); char* pred_file = argv[i+2]; testing(svm_load, test, pred_file); delete svm_load; return 0; }
test<REACTOR_IMPL>::test (int ignore_nested_upcalls, int require_event_loop_thread) { for (int i = 0; i < (int) (sizeof test_configs / (sizeof (int) * number_of_options)); i++) { if ((make_invocations == -1 || make_invocations == test_configs[i][0]) && (run_event_loop_thread == -1 || run_event_loop_thread == test_configs[i][1]) && (run_purger_thread == -1 || run_purger_thread == test_configs[i][2]) && (run_receiver_thread == -1 || run_receiver_thread == test_configs[i][3]) && (nested_upcalls == -1 || nested_upcalls == test_configs[i][4])) { #if 0 // defined (linux) // @@ I am not sure why but when <make_invocations> is 0 and // there is no purger thread, the receiver thread does not // notice that the connection has been closed. if (!test_configs[i][0] && !test_configs[i][2]) continue; // @@ Linux also does not work correctly in the following // case: Invocation thread starts and sends messages filling // the socket buffer. It then blocks in write(). In the // meantime, the close connection thread closes the socket // used by invocation thread. However, the invocation thread // does not notice this as it does not return from write(). // Meanwhile, the event loop thread notices that a socket in // it's wait set has been closed, and starts to spin in // handle_events() since the invocation thread is not taking // out the closed handle from the Reactor's wait set. if (test_configs[i][0] && test_configs[i][1] && !test_configs[i][3]) continue; #endif /* linux */ if (test_configs[i][4] && ignore_nested_upcalls) continue; if (!test_configs[i][1] && require_event_loop_thread) continue; ACE_Reactor reactor (new REACTOR_IMPL, 1); testing (&reactor, test_configs[i][0], test_configs[i][1], test_configs[i][2], test_configs[i][3], test_configs[i][4]); } } }
bool test_note_number() { testing("note_number"); test_int_equal(-3, musictheory_note_number("A-2")); test_int_equal(-2, musictheory_note_number("Bb-2")); test_int_equal(-1, musictheory_note_number("B-2")); test_int_equal(0, musictheory_note_number("B#-2")); test_int_equal(0, musictheory_note_number("C-1")); test_int_equal(12, musictheory_note_number("C0")); test_int_equal(21, musictheory_note_number("A0")); test_int_equal(24, musictheory_note_number("C1")); test_int_equal(27, musictheory_note_number("Eb1")); test_int_equal(36, musictheory_note_number("C2")); test_int_equal(48, musictheory_note_number("C3")); test_int_equal(60, musictheory_note_number("B#3")); test_int_equal(60, musictheory_note_number("C4")); test_int_equal(60, musictheory_note_number("Dbb4")); test_int_equal(61, musictheory_note_number("C#4")); test_int_equal(61, musictheory_note_number("Db4")); test_int_equal(62, musictheory_note_number("C##4")); test_int_equal(62, musictheory_note_number("D4")); test_int_equal(62, musictheory_note_number("Ebb4")); test_int_equal(63, musictheory_note_number("Eb4")); test_int_equal(64, musictheory_note_number("D##4")); test_int_equal(64, musictheory_note_number("E4")); test_int_equal(69, musictheory_note_number("A4")); test_int_equal(72, musictheory_note_number("C5")); test_int_equal(127, musictheory_note_number("G9")); test_int_equal(128, musictheory_note_number("G#9")); test_int_equal(129, musictheory_note_number("A9")); return passed; }
int main(int argc, char *argv[]) { if (argc == 1){ testing(); } else if (argc > 1){ QString data; QList<Vertex> vl; QList<Vertex> poligon; if (readFile(argv[1], data)){ if (parseVertexList(data, vl)){ graham(vl, poligon); if (argc == 2){ if (!writeVertexList("OUT.TXT", poligon)) qDebug() << "Can not open file: OUT.TXT"; } else { if (!writeVertexList(argv[2], poligon)) qDebug() << "Can not open file: " << argv[2]; } } qDebug() << "Invalid input data!"; } qDebug() << "Cannot open file: " << argv[1]; } return 0; }
void test_list() { int actuals[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; const char* test_name = "linked list"; testing(); int i = 0; list_t* list = list_create(); if (!list) test_failed("null list"); for (i = 0; i < 10; i++) { int* val = kmalloc(sizeof(int)); *val = i + 1; list_push(list, val); } int* val = NULL; for (i = 9; i >= 0; i--) { val = (int*)list_pop(list); if (!val) test_failed("null value"); if (*val != actuals[i]) { kprintf("*val == %d, actuals[%d] == %d\n", *val, i, actuals[i]); test_failed("bad value"); } } list_destroy(list); }
matrixsectassign(const M1 &a, const M2 &b) { int i,j; E c,e(n,n); testing(nameof(e),"operator &=("+nameof(a)+","+nameof(b)+")"); if(!tested()) { for(i=1;i<=n;i++) for(j=1;j<=n;j++) a[i][j]= 23-i+j,b[i][j]=1023-2*i-3*j,e[i][j]=(123-i+j)&(1023-2*i-3*j); c=(a&=b); int err=0; for(i=1;i<=n;i++) { //cout << c[i][j] << " " << a[i][j] << " " << e[i][j] << endl; for(j=1;j<=n;j++) if(c[i][j]!=e[i][j] || a[i][j]!=e[i][j]) err=1; } if(err) error(); else ok(); } }
TEST(LockingSharedObject, TestPassAccessor){ int a = 1; LockingSharedObject<int> testing(a); SharedObject<int>::Accessor acc(testing); std::thread first(PassAccessorThread, std::ref(acc)); first.join(); }
matrixsect(const M1 &a, const M2 &b) { int i,j; E c,e(n,n); testing(nameof(e),"operator &("+nameof(a)+","+nameof(b)+")"); if(!tested()) { for(i=1;i<=n;i++) for(j=1;j<=n;j++) a[i][j]= 23-i+j,b[i][j]=1023-2*i-3*j,e[i][j]=(23-i+j)&(1023-2*i-3*j); int err=0; c=a&b; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) if(!(c[i][j]==e[i][j] && !(c[i][j]!=e[i][j]))) err=1; } if(err) error(); else ok(); } testing(nameof(e),"operator &("+nameof(b)+","+nameof(a)+")"); if(!tested()) { for(i=1;i<=n;i++) for(j=1;j<=n;j++) a[i][j]= 23-i+j,b[i][j]=1023-2*i-3*j,e[i][j]=(23-i+j)&(1023-2*i-3*j); int err=0; c=b&a; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) if(!(c[i][j]==e[i][j] && !(c[i][j]!=e[i][j]))) err=1; } if(err) error(); else ok(); } }
TEST(LockingSharedObject, TestAccessor){ int a = 1; LockingSharedObject<int> testing(a); std::thread first(AccessThreadOne, std::ref(testing)); std::thread second(AccessThreadTwo, std::ref(testing)); first.join(); second.join(); }
int main() { running("hash table"); testing("new"); size_t size = 4; struct hasht *t = test_hasht_new(size); char *k = strdup("foo"); char *v = strdup("bar"); testing("insert"); test_hasht_insert(t, k, v); testing("search"); test_hasht_search(t, k, v); testing("insert duplicate"); test_hasht_insert_duplicate(t, k, v); testing("size"); char *k2 = strdup("the answer?"); char *v2 = strdup("42"); test_hasht_insert(t, k2, v2); test_hasht_used(t, 2); testing("resize"); test_hasht_resize(t, size); testing("remove"); test_hasht_delete(t, k, v); hasht_free(t); }
void compareStr(const T1& param1, const T2& param2) { T1 val1 = param1; T2 str1 = param2; RDOValue value1(val1); RDOValue value2(str1); testing(value1, value2); }
void testInstanceOf() { Human* h = new Human(); testing("InstanceOf"); assertEqual(h->instanceOf(Human), true, "Same class"); assertEqual(h->instanceOf(Alive), true, "Inherited"); assertEqual(h->instanceOf(Base), true, "Base class"); assertEqual(h->instanceOf(Inventory), false, "Different class"); }
main() { b = 9898; __transaction_relaxed { z = c; a = 888; testing(); } return 0; }
/* * This function prints the Averages from the tests after running through all the tests. * * Worst-Case Time Complexity: Θ(n) */ int main(){ // seed time. srand(time(NULL)); // starting size of 10000 instances const int& start_size = 10000; // set minimum size const int& min_size = 0; // set string array of Sorting algorithms to perform string* tests = new string[5]; tests[0] = "quickSort"; tests[1] = "mergeSort"; tests[2] = "insertionSort"; tests[3] = "bubbleSort"; tests[4] = "selectionSort"; // run each one of the Sorting algorithms for (int i = 0; i < 3; i++) { if(tests[i] == "quickSort"){ std::cout << "Now running isRandomPivot is false." << std::endl; isRandomPivot = false; testing(min_size, start_size, tests[i]); std::cout << "Now running isRandomPivot is true." << std::endl; isRandomPivot = true; } testing(min_size, start_size, tests[i]); } // run program again? for (int i = 0; i < 5; i++){ string answer; std::cout << "\nWould you like to run the program again? (yes or no)" << std::endl; cin >> answer; if (answer == "y" || answer == "Y" || answer == "YES" || answer == "yes"){ std::cout << " " << std::endl; main(); } break; } return 0; }
int main() { TestClass Test; Matrix A("test.txt"); Matrix B("test2.txt"); Matrix C; C = Test.Mul(A,B); for (auto i = 0; i < B.getSizeRow(); i++) { for (auto j = 0; j< A.getSizeCol() * 2; j++) std::cout << " "; std::cout << "\t"; std::cout << B.getRowToPrint(i) << std::endl; } std::cout << std::endl; for (auto i = 0; i < A.getSizeRow(); i++) { std::cout << A.getRowToPrint(i) << "\t"; std::cout << C.getRowToPrint(i) << std::endl; } C.saveMatrix("c"); /////////////////////////////////////////// Matrix testing(5, 5); testing.random(); Matrix wynik; wynik = Test.Mul(testing,A); /////////////////////////////////////////// Matrix D("c.txt"); D = Test.AddToMatrix(D,5); Matrix E; E = Test.AddMatrix(C,D); for (auto i = 0; i < C.getSizeRow();i++) std::cout << C.getRowToPrint(i) << "\t" << D.getRowToPrint(i) << "\t"<< E.getRowToPrint(i) << std::endl; /////////////////////////////////////////// Matrix test2; test2 = Test.AddMatrix(A,B); /////////////////////////////////////////// system("PAUSE"); return 0; }
TEST(LockingSharedObject, ChangeObjectValue){ int start = 1; LockingSharedObject<int> testing(start); SharedObject<int>::Accessor acc(testing); ASSERT_EQ(1, acc.access()); acc.access() = 2; ASSERT_EQ(2, acc.access()); acc.access() = 59; ASSERT_EQ(59, acc.access()); }
bool test_note_number_plus_interval() { testing("note_number_plus_interval"); test_int_equal(65, musictheory_note_number_plus_interval(60, "P4")); test_int_equal(63, musictheory_note_number_plus_interval(60, "m3")); test_int_equal(72, musictheory_note_number_plus_interval(60, "P8")); test_int_equal(69, musictheory_note_number_plus_interval(60, "M6")); return passed; }
TEST(StringPieceTest, PiecesHaveCorrectSortOrder) { std::u16string testing(u"testing"); std::u16string banana(u"banana"); std::u16string car(u"car"); EXPECT_TRUE(StringPiece16(testing) > banana); EXPECT_TRUE(StringPiece16(testing) > car); EXPECT_TRUE(StringPiece16(banana) < testing); EXPECT_TRUE(StringPiece16(banana) < car); EXPECT_TRUE(StringPiece16(car) < testing); EXPECT_TRUE(StringPiece16(car) > banana); }
TEST(StringPieceTest, PiecesHaveCorrectSortOrderUtf8) { std::string testing("testing"); std::string banana("banana"); std::string car("car"); EXPECT_TRUE(StringPiece(testing) > banana); EXPECT_TRUE(StringPiece(testing) > car); EXPECT_TRUE(StringPiece(banana) < testing); EXPECT_TRUE(StringPiece(banana) < car); EXPECT_TRUE(StringPiece(car) < testing); EXPECT_TRUE(StringPiece(car) > banana); }
void testCloner() { testing("Cloner"); GameManager* gm = new GameManager(); Item* i = new Item("Testing Item"); gm->insertObject(i); i->setName("Test name")->setDescription("Some going to be cloned item"); Cloner cl = Cloner(i); ObjectPointer other = cl.getShallowClone(); Item* j = other.safeCast<Item>(); assertEqual<string>(i->getName(), j->getName(), "Name is different"); assertEqual<string>(i->getDescription(), j->getDescription(), "Description is different"); }
void ADHighAccuracy::InitialiseHWLibraries() { QPluginLoader loaderApp("libPTApplicationcardInterface.so", this); IAppCard = qobject_cast<IApplicationCardInterface*> (loaderApp.instance()); qDebug() << "Appcard" << IAppCard; IAppCard->setDeviceName(SLOT0); IAppCard->enumerateAPPCard(); IAppCard->setSPIAppendBit(0xC000); qDebug()<<"Code ID:"<<hex<<IAppCard->readAppCardCodeId(); m_objAD7190 = new AD7190Component(IAppCard); QPluginLoader testing("libAppBckPsoc.so", this); test = qobject_cast<IPTAppBckPsocInterface*> (testing.instance()); }
void testRandomString() { testing("Random string"); RandomString rand; rand << "Test message 1" << endr << "Test message 2" << endr; assertEqual<string>(((string) rand).substr(0, 4), "Test", "String operator"); string r = RandomString::get() << "Test message 1" << endr << "Test message 2" << endr; assertEqual<string>(r.substr(0, 4), "Test", "Static use operator"); }
// Training input vectors until all input vectors have been learned void CounterpropNetwork::training( vector<vector<double>> vvd_trainingInputVector, vector<vector<double>> vvd_trainingOutputVector ) { DWORD dw_winningHiddenIndex, dwTrainingInputVectorSize; unsigned int i; vector<double> res; int x = 0; int epochs = EPOCHS; double error = 0.0; bool bFirst = TRUE; dwTrainingInputVectorSize = vvd_trainingInputVector.size(); while( epochs && ( error > PRECISION || bFirst ) ) { error = 0.0; bFirst = FALSE; for( i = 0; i < dwTrainingInputVectorSize; i++ ) { dw_winningHiddenIndex = trainingVector( vvd_trainingInputVector[i] ); m_viNumberOfWins[dw_winningHiddenIndex]++; updateGrossbergWeights( dw_winningHiddenIndex, 0, vvd_trainingOutputVector[i] ); res = testing(vvd_trainingInputVector[i]); for( x = 0; x < OUTPUT; ++x ) { error += pow( res[x] - vvd_trainingOutputVector[i][x], 2 ); } } error /= OUTPUT; epochs--; } }
ShortLocater::ShortLocater(QWidget *parent) : QWidget(parent) { ui.setupUi(this); qDebug()<<"----------------------------SHORT LOCATER START----------------------------"; //DISPLAY dis=new DISPLAY(ui.displayPanel); dis->selectGeometry(150,30); ui.units->setFont(QFont("DejaVu Sans", 85, 50, false)); QPluginLoader loader2("libBackPlaneInterface.so",this); IBackPlane = qobject_cast<IntefaceBackPlane*>(loader2.instance()); IBackPlane->InitializeBpObject(); QPluginLoader loader3("libPTPsocInterface2.so",this); IPsoc = qobject_cast<IPSOCCOMMUNICATION*>(loader3.instance()); IPsoc->openSerial(); QPluginLoader loader4("libPTDMMLibInterface2.so",this); IDMMLib = qobject_cast<IDMMLibInterface*>(loader4.instance()); QPluginLoader loader5("libGPIOEventInterface.so",this); IGPIOEvent = qobject_cast<PTGPIOEventInterface*>(loader5.instance()); QPluginLoader loader6("libPTKeyEventInterfaces.so",this); IPTKeyEvent = qobject_cast<PTEventInterface*>(loader6.instance()); QPluginLoader loader8("libPTGPIOPinInterface.so",this); IGPIOPin = qobject_cast<InterfaceGPIOPins*>(loader8.instance()); QPluginLoader testing("libAppBckPsoc.so",this); test = qobject_cast<IPTAppBckPsocInterface*>(testing.instance()); QPluginLoader loaderhaadc("libADCHighAccuracy.so", this); HAADC = qobject_cast<IHACADCTestJigInterface*> (loaderhaadc.instance()); HAADC->setHACADC(ui.HAADC_WIDGET); ui.HAADC_WIDGET->setWindowFlags(Qt::Dialog); HAADC->showWidget(); // // toolboxFlag=false; // ToolBox(toolboxFlag); Initializations(); connect(m_nADCtimer,SIGNAL(timeout()),this,SLOT(Measure())); }