void single_check(const char *device, const char *connection, const char *model, GSM_Error expected) { GSM_Config *smcfg; GSM_Error error; GSM_Debug_Info *debug_info; /* Allocates state machine */ s = GSM_AllocStateMachine(); test_result(s != NULL); debug_info = GSM_GetDebug(s); GSM_SetDebugGlobal(TRUE, debug_info); smcfg = GSM_GetConfig(s, 0); strcpy(smcfg->Model, model); smcfg->Device = strdup(device); smcfg->UseGlobalDebugFile = TRUE; smcfg->Connection = strdup(connection); smcfg->PhoneFeatures[0] = F_PBK_ENCODENUMBER; smcfg->PhoneFeatures[1] = 0; GSM_SetConfigNum(s, 1); error = GSM_InitConnection(s, 1); test_result(error == expected); /* Free state machine */ GSM_FreeStateMachine(s); }
int _tmain(int argc, _TCHAR* argv[]) { Crypto crypto; BYTE salt[CRYPTO_KDF_SALT_LEN]; BYTE master_key[16], db_key[16]; int pass= 0; int tests= 4; pass+= test_result( test_salt(&crypto, (PBYTE) salt) ); pass+= test_result( test_db_key(&crypto, db_key) ); pass+= test_result( test_kdf(&crypto, (PBYTE) PASSPHRASE, sizeof(PASSPHRASE), salt, master_key) ); pass+= test_result( test_key_encryption(&crypto, db_key, master_key) ); if ( tests == pass ) { wprintf(L"\n===> ALL TESTS PASSED <===\n\n"); Exit(0); } wprintf(L"%d OF %d TESTS PASSING\n\n", pass, tests); Exit(1); }
int main(void) { test_package_begin("hash", "Externally linked hash table data structure with operations"); hash_init(); test_begin("Hash allocation"); { Hash *a; a = hash_new(int_hash, int_key_eq); test_result(a != NULL); hash_destroy(a); } test_end(); test_begin("Multiple allocs"); { Hash *a, *b; a = hash_new(int_hash, int_key_eq); b = hash_new(int_hash, int_key_eq); test_result(a != NULL && b != NULL && a != b); hash_destroy(b); hash_destroy(a); } test_end(); test_begin("Insert/lookup"); { Hash *a; const char *t; a = hash_new(int_hash, int_key_eq); hash_insert(a, (const void *) 17, "foo"); test_result((t = hash_lookup(a, (const void *) 17)) != NULL && strcmp(t, "foo") == 0); hash_destroy(a); } test_end(); test_begin("Resize"); { Hash *a; const char *t; unsigned int i; a = hash_new(int_hash, int_key_eq); hash_insert(a, (const void *) 4711, "foo"); for(i = 0; i < 100; i++) hash_insert(a, (const void *) (3519 + i), "test-data"); test_result((t = hash_lookup(a, (const void *) 4711)) != NULL && strcmp(t, "foo") == 0); hash_destroy(a); } test_end(); return test_package_end(); }
void test_set_var() /* {{{ */ { /* test the ability to set a variable */ char *teststr = strdup(" set \t task_version 0.6.9 "); char *testint = strdup(" set \t nc_timeout \t 6969\t\t \n "); stdout = devnull; handle_command(teststr); handle_command(testint); stdout = out; test_result("set string var", strcmp(cfg.version, "0.6.9")==0); test_result("set int var", cfg.nc_timeout==6969); } /* }}} */
int main() { test(1000); test_comp(1000); test_proj(1000); test_move_only(1000); { int const N = 1000; S* ia = new S[N]; int* ib = new int[N]; for (int i = 0; i < N; ++i) ia[i].i = i; std::shuffle(ia, ia+N, gen); for (int i = 0; i <= N; ++i) { CHECK(ranges::push_heap(ranges::make_iterator_range(ia, ia+i), std::greater<int>(), &S::i).get_unsafe() == ia+i); std::transform(ia, ia+i, ib, std::mem_fn(&S::i)); CHECK(std::is_heap(ib, ib+i, std::greater<int>())); } delete[] ia; delete[] ib; } return test_result(); }
}END_TEST static void test_searcher_overflow_to_64bit( int search_type ) { init_constant_scores( 127, -1 ); init_symbol_translation( AMINOACID, FORWARD_STRAND, 3, 3 ); p_query query = query_read_from_file( "./tests/testdata/NP_009305.1.fas" ); s_init( search_type, BIT_WIDTH_8, query ); ssa_db_init( "./tests/testdata/NP_009305.1.fas" ); gapO = -1; gapE = -1; size_t hit_count = 1; adp_init( hit_count ); p_search_result res = s_search( &hit_count ); minheap_sort( res->heap ); query_free( query ); ck_assert_int_eq( hit_count, res->heap->count ); ck_assert_int_eq( 1, res->overflow_8_bit_count ); ck_assert_int_eq( 1, res->overflow_16_bit_count ); int result[2] = { 67818, 0 }; test_result( res, result, 2 ); }
void check_log(FILE * f, gboolean match, const char *test_name) { char buff[100]; char test_message[] = "T3ST M3S5AG3"; char cleaner[] = "XXXXXXXXXXXXXXXXX"; int result; rewind(f); GSM_LogError(s, test_message, ERR_MOREMEMORY); rewind(f); result = fread(buff, 1, sizeof(test_message), f); if (match && result != sizeof(test_message)) { printf("%s: Read failed (%d)!\n", test_name, result); fail(10); } if (!match && result != sizeof(test_message)) { goto done; } result = strncmp(test_message, buff, sizeof(test_message) - 1); if (match && result != 0) { printf("%s: Match failed!\n", test_name); fail(11); } if (!match && result == 0) { printf("%s: Matched but should not!\n", test_name); fail(12); } done: rewind(f); result = fwrite(cleaner, 1, sizeof(cleaner), f); test_result(result == sizeof(cleaner)); rewind(f); }
int main() { test_iter<forward_iterator<const int*> >(); test_iter<bidirectional_iterator<const int*> >(); test_iter<random_access_iterator<const int*> >(); test_iter<const int*>(); test_iter<forward_iterator<const int*>, sentinel<const int*>>(); test_iter<bidirectional_iterator<const int*>, sentinel<const int*>>(); test_iter<random_access_iterator<const int*>, sentinel<const int*>>(); test_iter<forward_iterator<const int*> >(); test_iter<bidirectional_iterator<const int*> >(); test_iter<random_access_iterator<const int*> >(); test_iter<const int*>(); test_iter<forward_iterator<const int*>, sentinel<const int*>>(); test_iter<bidirectional_iterator<const int*>, sentinel<const int*>>(); test_iter<random_access_iterator<const int*>, sentinel<const int*>>(); // Works with projections? S s[] = {S{1},S{2},S{3},S{4},S{-4},S{5},S{6},S{40},S{7},S{8},S{9}}; std::pair<S const *, S const *> ps = ranges::minmax_element(s, std::less<int>{}, &S::i); CHECK(ps.first->i == -4); CHECK(ps.second->i == 40); return test_result(); }
int main() { int d = 0; ranges::nth_element(&d, &d, &d); CHECK(d == 0); test(256); test(257); test(499); test(500); test(997); test(1000); test(1009); // Works with projections? const int N = 257; const int M = 56; S ia[N]; for(int i = 0; i < N; ++i) ia[i].i = ia[i].j = i; std::shuffle(ia, ia+N, gen); ranges::nth_element(ia, ia+M, std::less<int>(), &S::i); CHECK(ia[M].i == M); CHECK(ia[M].j == M); return test_result(); }
int main() { test_iter<input_iterator<const int*> >(); test_iter<forward_iterator<const int*> >(); test_iter<bidirectional_iterator<const int*> >(); test_iter<random_access_iterator<const int*> >(); test_iter<const int*>(); test_iter<input_iterator<const int*>, sentinel<const int*>>(); test_iter<forward_iterator<const int*>, sentinel<const int*>>(); test_iter<bidirectional_iterator<const int*>, sentinel<const int*>>(); test_iter<random_access_iterator<const int*>, sentinel<const int*>>(); test_iter_comp<input_iterator<const int*> >(); test_iter_comp<forward_iterator<const int*> >(); test_iter_comp<bidirectional_iterator<const int*> >(); test_iter_comp<random_access_iterator<const int*> >(); test_iter_comp<const int*>(); test_iter_comp<input_iterator<const int*>, sentinel<const int*>>(); test_iter_comp<forward_iterator<const int*>, sentinel<const int*>>(); test_iter_comp<bidirectional_iterator<const int*>, sentinel<const int*>>(); test_iter_comp<random_access_iterator<const int*>, sentinel<const int*>>(); // Works with projections? S s[] = {S{1},S{2},S{3},S{4},S{40},S{5},S{6},S{7},S{8},S{9}}; S v = ranges::max(s, std::less<int>{}, &S::i); CHECK(v.i == 40); return test_result(); }
int main() { // Test for constant generator functions { int i = 0, j = 1; auto fib = view::generate_n([&]()->int{int tmp = i; i += j; std::swap(i, j); return tmp;}, 10); CONCEPT_ASSERT(ranges::InputRange<decltype(fib)>()); check_equal(fib, {0,1,1,2,3,5,8,13,21,34}); auto const &cfib = fib; auto it = fib.begin(); auto cit = cfib.begin(); CONCEPT_ASSERT(ranges::Same<decltype(it), decltype(cit)>()); } // Test for mutable-only generator functions { int i = 0, j = 1; auto fib = view::generate_n([=]()mutable->int{int tmp = i; i += j; std::swap(i, j); return tmp;}, 10); CONCEPT_ASSERT(ranges::InputRange<decltype(fib)>()); check_equal(fib, {0,1,1,2,3,5,8,13,21,34}); // The generator cannot be called when it's const-qualified, so "fib const" // does not model Range. CONCEPT_ASSERT(!ranges::Range<decltype(fib) const>()); } return test_result(); }
int main() { test_iter(); test_iter_comp(); return test_result(); }
int main(int argc, char *argv[]) { if (argc>1 && argv[1][0]=='-' && argv[1][1]=='h') { cout << "usage: " << argv[0] << " < result-file " <<endl; cout << " result-file format: true-label predicted-score" <<endl; exit(-1); } Target y_type("BINARY"); int loss=TrainLoss::str2loss(string("LS")); BinaryTestStat test_result(y_type,loss); int nl=0; while(true) { bool label; double y; double score; cin >> y >> score; label=y_type.binary_label(y); if (cin.eof()) break; test_result.update(label,0,score); nl++; } cout << "auc=" << test_result.auc() <<endl; }
int tau_ex(double *rmax, int nx, double *ip, int ni, long *nrad, int nr, double alpha, char *str) { int status=0,i; double (*analres)(); test_result("\nTesting OPTICAL DEPTH for extinction %s, alpha=%g\n",str,alpha); if(alpha==0.0) analres=&const_ex_anal; else if(alpha<0) analres=&incin_ex_anal; else analres=&incout_ex_anal; for(i=0;i<nr;i++) status += tau_rad(rmax[i],ip,ni,nrad,nr,alpha,analres); return status; }
int tau_dens(double rm, double ip, long nrad, double alpha, double res) { int status=0,i; double rad[nrad],ex[nrad],refr[nrad]; double dr=rm/nrad; test_result(" Using %li layers, an interspacing of %g\n",nrad,dr); if(outp) fprintf(outp, "\n#rad extinction refrac\n"); for(i=0;i<nrad;i++){ rad[i]=(i+1)*dr; ex[i]=calcex(alpha, rm, rad[i]); refr[i]=1; if(outp) fprintf(outp, "%12.9g%12.9g%12.9g\n" ,rad[i],ex[i],refr[i]); } status+=tau_now(ip,rad,refr,ex,nrad,res,1,"RefIdx constant technique"); status+=tau_now(ip,rad,refr,ex,nrad,res,2,"Ray bending technique"); return status; }
int main(int argc, char** argv) { char* mpi_inbuf; char* mpi_outbuf; char* farc_inbuf; char* farc_outbuf; MPI_Init(&argc, &argv); test_start("pack(1, hvector[[int], count=2, blklen=2, stride=-5*sizeof(int)])"); init_buffers(20*sizeof(int), &mpi_inbuf, &farc_inbuf, &mpi_outbuf, &farc_outbuf); farc::DDT_Init(); farc::Datatype* t1 = new farc::PrimitiveDatatype(farc::PrimitiveDatatype::INT); farc::Datatype* t2 = new farc::HVectorDatatype(2, 2, -5*sizeof(int), t1); farc::DDT_Commit(t2); farc::DDT_Pack(farc_inbuf+10*sizeof(int), farc_outbuf, t2, 1); MPI_Datatype newtype; MPI_Type_hvector(2, 2, -5*sizeof(int), MPI_INT, &newtype); MPI_Type_commit(&newtype); int position = 0; MPI_Pack(mpi_inbuf+10*sizeof(int), 1, newtype, mpi_outbuf, 20*sizeof(int), &position, MPI_COMM_WORLD); int res = compare_ddt_info(newtype, t2); res = compare_buffers(20*sizeof(int), &mpi_inbuf, &farc_inbuf, &mpi_outbuf, &farc_outbuf); // inspect_buffers(20*sizeof(int), &mpi_inbuf, &farc_inbuf, &mpi_outbuf, &farc_outbuf); free_buffers(&mpi_inbuf, &farc_inbuf, &mpi_outbuf, &farc_outbuf); test_result(res); MPI_Finalize(); return 0; }
int main(int argc, char** argv) { char* mpi_inbuf; char* mpi_outbuf; char* farc_inbuf; char* farc_outbuf; MPI_Init(&argc, &argv); test_start("pack(2, [MPI_INT])"); init_buffers(20*sizeof(int), &mpi_inbuf, &farc_inbuf, &mpi_outbuf, &farc_outbuf); farc::DDT_Init(); farc::Datatype* t1 = new farc::PrimitiveDatatype(farc::PrimitiveDatatype::INT); int res = compare_ddt_info(MPI_INT, t1); farc::DDT_Commit(t1); farc::DDT_Pack(farc_inbuf, farc_outbuf, t1, 2); int position = 0; MPI_Pack(mpi_inbuf, 2, MPI_INT, mpi_outbuf, 20*sizeof(int), &position, MPI_COMM_WORLD); res += compare_buffers(20*sizeof(int), &mpi_inbuf, &farc_inbuf, &mpi_outbuf, &farc_outbuf); free_buffers(&mpi_inbuf, &farc_inbuf, &mpi_outbuf, &farc_outbuf); test_result(res); MPI_Finalize(); return 0; }
int main() { test_iter<input_iterator<const int*> >(); test_iter<forward_iterator<const int*> >(); test_iter<bidirectional_iterator<const int*> >(); test_iter<random_access_iterator<const int*> >(); test_iter<const int*>(); test_iter<input_iterator<const int*>, sentinel<const int*>>(); test_iter<forward_iterator<const int*>, sentinel<const int*>>(); test_iter<bidirectional_iterator<const int*>, sentinel<const int*>>(); test_iter<random_access_iterator<const int*>, sentinel<const int*>>(); test_iter<input_iterator<const int*> >(); test_iter<forward_iterator<const int*> >(); test_iter<bidirectional_iterator<const int*> >(); test_iter<random_access_iterator<const int*> >(); test_iter<const int*>(); test_iter<input_iterator<const int*>, sentinel<const int*>>(); test_iter<forward_iterator<const int*>, sentinel<const int*>>(); test_iter<bidirectional_iterator<const int*>, sentinel<const int*>>(); test_iter<random_access_iterator<const int*>, sentinel<const int*>>(); // Works with projections? S s[] = {S{1,0},S{2,1},S{3,2},S{4,3},S{-4,4},S{40,5},S{-4,6},S{40,7},S{7,8},S{8,9},S{9,10}}; auto res = ranges::minmax(s, std::less<int>{}, &S::value); CHECK(res.first.value == -4); CHECK(res.first.index == 4); CHECK(res.second.value == 40); CHECK(res.second.index == 7); return test_result(); }
int main() { test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >(); test<bidirectional_iterator<const int*>, random_access_iterator<int*> >(); test<bidirectional_iterator<const int*>, int*>(); test<random_access_iterator<const int*>, bidirectional_iterator<int*> >(); test<random_access_iterator<const int*>, random_access_iterator<int*> >(); test<random_access_iterator<const int*>, int*>(); test<const int*, bidirectional_iterator<int*> >(); test<const int*, random_access_iterator<int*> >(); test<const int*, int*>(); test1<bidirectional_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >(); test1<bidirectional_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >(); test1<bidirectional_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>(); test1<random_access_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >(); test1<random_access_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >(); test1<random_access_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>(); test1<std::unique_ptr<int>*, bidirectional_iterator<std::unique_ptr<int>*> >(); test1<std::unique_ptr<int>*, random_access_iterator<std::unique_ptr<int>*> >(); test1<std::unique_ptr<int>*, std::unique_ptr<int>*>(); return test_result(); }
void test_regex_iterator(boost::basic_regex<charT, traits>& r) { typedef typename std::basic_string<charT>::const_iterator const_iterator; typedef boost::regex_iterator<const_iterator, charT, traits> test_iterator; const std::basic_string<charT>& search_text = test_info<charT>::search_text(); boost::regex_constants::match_flag_type opts = test_info<charT>::match_options(); const int* answer_table = test_info<charT>::answer_table(); test_iterator start(search_text.begin(), search_text.end(), r, opts), end; test_iterator copy(start); const_iterator last_end = search_text.begin(); while(start != end) { if(start != copy) { BOOST_REGEX_TEST_ERROR("Failed iterator != comparison.", charT); } if(!(start == copy)) { BOOST_REGEX_TEST_ERROR("Failed iterator == comparison.", charT); } test_result(*start, search_text.begin(), answer_table); // test $` and $' : if(start->prefix().first != last_end) { BOOST_REGEX_TEST_ERROR("Incorrect position for start of $`", charT); } if(start->prefix().second != (*start)[0].first) { BOOST_REGEX_TEST_ERROR("Incorrect position for end of $`", charT); } if(start->prefix().matched != (start->prefix().first != start->prefix().second)) { BOOST_REGEX_TEST_ERROR("Incorrect position for matched member of $`", charT); } if(start->suffix().first != (*start)[0].second) { BOOST_REGEX_TEST_ERROR("Incorrect position for start of $'", charT); } if(start->suffix().second != search_text.end()) { BOOST_REGEX_TEST_ERROR("Incorrect position for end of $'", charT); } if(start->suffix().matched != (start->suffix().first != start->suffix().second)) { BOOST_REGEX_TEST_ERROR("Incorrect position for matched member of $'", charT); } last_end = (*start)[0].second; ++start; ++copy; // move on the answer table to next set of answers; if(*answer_table != -2) while(*answer_table++ != -2){} } if(answer_table[0] >= 0) { // we should have had a match but didn't: BOOST_REGEX_TEST_ERROR("Expected match was not found.", charT); } }
bool operator()(const boost::match_results<test_iter>& what) { test_result(what, m_base, m_table); // move on the answer table to next set of answers; if(*m_table != -2) while(*m_table++ != -2){} return true; }
void test_idle(void) { /* both task must run exactly TEST_CYCLES times, different value means OS * scheduling bug */ test_assert(TEST_CYCLES == task_data[0].loop); test_assert(TEST_CYCLES == task_data[1].loop); test_result(0); }
void test_idle(void) { /* check if both task was run to the end */ test_assert(TEST_CYCLES == cnt1); test_assert(TEST_CYCLES == cnt2); test_result(0); }
void OK(test_batch_runner *runner, int cond, const char *msg, ...) { va_list ap; va_start(ap, msg); test_result(runner, cond, msg, ap); va_end(ap); }
int main(void) { test_package_begin("xmlnode", "XML parser"); test_begin("Non-creation"); { XmlNode *root; root = xmlnode_new(NULL); test_result(root == NULL); } test_end(); test_begin("Single node creation"); { XmlNode *root; root = xmlnode_new("<test/>"); test_result(root != NULL && strcmp(xmlnode_get_name(root), "test") == 0); xmlnode_destroy(root); } test_end(); test_begin("Attribute access"); { XmlNode *root; root = xmlnode_new("<test foo='bar'/>"); test_result(strcmp(xmlnode_attrib_get_value(root, "foo"), "bar") == 0); xmlnode_destroy(root); } test_end(); test_begin("Path evaluation"); { XmlNode *root; root = xmlnode_new("<parent><child name='foo'/><child name='bar'/><child name='baz'/></parent>"); test_result(strcmp(xmlnode_eval_single(root, "parent/child[@NAME]"), "baz") == 0); xmlnode_destroy(root); } test_end(); return test_package_end(); }
int main() { test(1000); test_comp(1000); test_proj(1000); test_move_only(1000); return test_result(); }
}END_TEST START_TEST (test_searcher_AA_BLOSUM_nw_64) { int result[12] = { 82, 0 }; p_search_result res = setup_BLOSUM62_test( BIT_WIDTH_64, NEEDLEMAN_WUNSCH, 1 ); test_result( res, result, 2 ); }END_TEST
}END_TEST START_TEST (test_searcher_AA_BLOSUM_sw_8_avx) { set_max_compute_capability( COMPUTE_ON_AVX2 ); int result[12] = { 103, 0 }; p_search_result res = setup_BLOSUM62_test( BIT_WIDTH_8, SMITH_WATERMAN, 1 ); test_result( res, result, 2 ); }END_TEST
}END_TEST START_TEST (test_searcher_AA_BLOSUM_nw_8) { set_max_compute_capability( COMPUTE_ON_SSE41 ); int result[2] = { 82, 0 }; p_search_result res = setup_BLOSUM62_test( BIT_WIDTH_8, NEEDLEMAN_WUNSCH, 1 ); test_result( res, result, 2 ); }END_TEST
int main() { test(0); test(1); test(2); test(3); test(10); test(1000); test_9(1000); test_10(1000); return test_result(); }