/* * Verify replace behavior */ static enum test_result replace_test(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1) { item *it; void *key = "key"; uint64_t prev_cas; uint64_t cas = 0; int ii; item_info item_info; item_info.nvalue = 1; cb_assert(set_test(h, h1) == SUCCESS); cb_assert(h1->allocate(h, NULL, &it, key, strlen(key), sizeof(int), 1, 0, PROTOCOL_BINARY_RAW_BYTES) == ENGINE_SUCCESS); cb_assert(h1->get_item_info(h, NULL, it, &item_info) == true); for (ii = 0; ii < 10; ++ii) { prev_cas = cas; *(int*)(item_info.value[0].iov_base) = ii; cb_assert(h1->store(h, NULL, it, &cas, OPERATION_REPLACE,0) == ENGINE_SUCCESS); cb_assert(cas != prev_cas); } h1->release(h, NULL, it); cb_assert(h1->get(h, NULL, &it, key, (int)strlen(key), 0) == ENGINE_SUCCESS); cb_assert(h1->get_item_info(h, NULL, it, &item_info) == true); cb_assert(item_info.value[0].iov_len == sizeof(int)); cb_assert(*(int*)(item_info.value[0].iov_base) == 9); h1->release(h, NULL, it); return SUCCESS; }
int main(int argc , char ** argv) { create_test(); get_test(); set_test(); load_empty_test(); test_equal(); test_copy(); test_io(); test_update_undefined( ); test_select_matching(); test_count_matching(); exit(0); }
void tester_util::add_test_files( const problem::single::process::Settings &settings, const test::storage::test &test, const boost::filesystem::path &destination, const unistd::access::Id &owner_id, const mode_t mask) { try { set_test(test); for (const problem::single::process::File &file : settings.file()) { add_test_file(file, test, destination, owner_id, mask); } } catch (std::exception &) { BOOST_THROW_EXCEPTION(add_test_files_error() << bunsan::enable_nested_current()); } }
int _tmain(int argc, _TCHAR* argv[]) { //vecAssignTest(); map_test(); vector_member(); set_test(); hash_set_test(); iterator_test2(); example_algorithm(); example_iterator(); list_test(); autoptr_test(); return 0; }
void part_two_describe() { cout<<"******************************************"<<endl; cout<<"* 第二章 C++ STL泛型编程 *"<<endl; cout<<"******************************************"<<endl; cout<<"*(1) 一个简单的测试案例 *"<<endl; cout<<"*(2) vector向量容器 *"<<endl; cout<<"*(3) string基本字符系列容器 *"<<endl; cout<<"*(4) set集合容器 *"<<endl; cout<<"*(5) mutiset多种集合容器 *"<<endl; cout<<"*(6) map映照容器 *"<<endl; cout<<"*(7) mutimap多重映照容器 *"<<endl; cout<<"*(8) deque双端队列容器 *"<<endl; cout<<"*(9) list双向链表容器 *"<<endl; cout<<"*(10)bitset位集合容器 *"<<endl; cout<<"*(11)stack堆栈容器 *"<<endl; cout<<"*(12)queue队列容器 *"<<endl; cout<<"*(13)priority_queue优先队列容器 *"<<endl; cout<<"******************************************"<<endl; cout<<"请输入对应的编号进入相应的题目(返回上级输入0):"<<endl; int num; cin>>num; while(num!=0&&num!=1&&num!=2&&num!=3&&num!=4&&num!=5&&num!=6&&num!=7&&num!=8&&num!=9&&num!=10&&num!=11&&num!=12&&num!=13){ cout<<"编号不存在"<<endl; cout<<"请输入对应的编号进入相应的题目(返回上级输入0):"<<endl; cin>>num; } switch(num){ case 0:total_describe();break; case 1:test();break; case 2:vector_test();break; case 3:string_test();break; case 4:set_test();break; case 5:multiset_test();break; case 6:map_test();break; case 7:multimap_test();break; case 8:deque_test();break; case 9:list_test();break; case 10:bitset_test();break; case 11:stack_test();break; case 12:queue_test();break; case 13:priority_queue_test();break; } }
int main(int argc, char ** argv) { lt_type_init(); array_test(); hash_test(); module_test(); base64_test(); set_test(); object_test(); return 0; }
int main(void) { /* setup the test */ uart_init(); uart_write((uint8_t*)"\r\nSTART\r\n", 9); set_test(3); print_event = Event_Init(); Task_Create(generic_task, 1, RR, A); Task_Create(generic_task, 2, RR, B); Task_Create(generic_task, 3, RR, C); Task_Create(generic_task, 4, RR, D); Task_Create(generic_task, 5, RR, E); Task_Create(generic_task, 6, RR, F); Event_Wait(print_event); print_trace(); }
int main(void) { /* setup the test */ uart_init(); uart_write((uint8_t*)"\r\nSTART\r\n", 9); set_test(2); print_event = Event_Init(); Task_Create(generic_task, A, PERIODIC, A); Task_Create(generic_task, B, PERIODIC, B); Task_Create(generic_task, C, PERIODIC, C); Task_Create(generic_task, D, PERIODIC, D); Task_Create(generic_task, E, PERIODIC, E); Task_Create(generic_task, F, PERIODIC, F); Event_Wait(print_event); print_trace(); }
int main() { int repeat = 500; int size = (1 << 16) / 3; tellmeall(); printf("bitset container benchmarks\n"); bitset_container_t* B = bitset_container_create(); BEST_TIME(set_test(B), 0, repeat, size); int answer = get_test(B); size = 1 << 16; BEST_TIME(get_test(B), answer, repeat, size); BEST_TIME(bitset_container_cardinality(B), answer, repeat, 1); BEST_TIME(bitset_container_compute_cardinality(B), answer, repeat, BITSET_CONTAINER_SIZE_IN_WORDS); size = (1 << 16) / 3; BEST_TIME(unset_test(B), 0, repeat, size); bitset_container_free(B); for (int howmany = 4096; howmany <= (1 << 16); howmany *= 2) { bitset_container_t* Bt = bitset_container_create(); while (bitset_container_cardinality(Bt) < howmany) { bitset_container_set(Bt, (uint16_t)pcg32_random()); } size_t nbrtestvalues = 1024; uint16_t* testvalues = malloc(nbrtestvalues * sizeof(uint16_t)); printf("\n number of values in container = %d\n", bitset_container_cardinality(Bt)); int card = bitset_container_cardinality(Bt); uint32_t* out = malloc(sizeof(uint32_t) * (unsigned)card + 32); BEST_TIME(bitset_container_to_uint32_array(out, Bt, 1234), card, repeat, card); free(out); BEST_TIME_PRE_ARRAY(Bt, bitset_container_get, bitset_cache_prefetch, testvalues, nbrtestvalues); BEST_TIME_PRE_ARRAY(Bt, bitset_container_get, bitset_cache_flush, testvalues, nbrtestvalues); free(testvalues); bitset_container_free(Bt); } printf("\n"); bitset_container_t* B1 = bitset_container_create(); for (int x = 0; x < 1 << 16; x += 3) { bitset_container_set(B1, (uint16_t)x); } bitset_container_t* B2 = bitset_container_create(); for (int x = 0; x < 1 << 16; x += 5) { bitset_container_set(B2, (uint16_t)x); } bitset_container_t* BO = bitset_container_create(); BEST_TIME(bitset_container_or_nocard(B1, B2, BO), -1, repeat, BITSET_CONTAINER_SIZE_IN_WORDS); answer = bitset_container_compute_cardinality(BO); BEST_TIME(bitset_container_or(B1, B2, BO), answer, repeat, BITSET_CONTAINER_SIZE_IN_WORDS); BEST_TIME(bitset_container_cardinality(BO), answer, repeat, 1); BEST_TIME(bitset_container_compute_cardinality(BO), answer, repeat, BITSET_CONTAINER_SIZE_IN_WORDS); BEST_TIME(bitset_container_and_nocard(B1, B2, BO), -1, repeat, BITSET_CONTAINER_SIZE_IN_WORDS); answer = bitset_container_compute_cardinality(BO); BEST_TIME(bitset_container_and(B1, B2, BO), answer, repeat, BITSET_CONTAINER_SIZE_IN_WORDS); BEST_TIME(bitset_container_cardinality(BO), answer, repeat, 1); BEST_TIME(bitset_container_compute_cardinality(BO), answer, repeat, BITSET_CONTAINER_SIZE_IN_WORDS); // next we are going to benchmark conversion from bitset to array (an // important step) bitset_container_clear(B1); for (int k = 0; k < 4096; ++k) { bitset_container_set(B1, (uint16_t)ranged_random(1 << 16)); } answer = get_cardinality_through_conversion_to_array(B1); BEST_TIME(get_cardinality_through_conversion_to_array(B1), answer, repeat, BITSET_CONTAINER_SIZE_IN_WORDS); bitset_container_free(BO); bitset_container_free(B1); bitset_container_free(B2); return 0; }
/* * Verify replace behavior */ static enum test_result replace_test(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1) { item *it; void *key = "key"; assert(set_test(h, h1) == SUCCESS); assert(h1->allocate(h, NULL, &it, key, strlen(key), sizeof(int), 1, 0,0) == ENGINE_SUCCESS); item_info item_info = { .nvalue = 1 }; assert(h1->get_item_info(h, NULL, it, &item_info) == true); uint64_t prev_cas; uint64_t cas = 0; for (int ii = 0; ii < 10; ++ii) { prev_cas = cas; *(int*)(item_info.value[0].iov_base) = ii; assert(h1->store(h, NULL, it, &cas, OPERATION_REPLACE,0) == ENGINE_SUCCESS); assert(cas != prev_cas); } h1->release(h, NULL, it); assert(h1->get(h, NULL, &it, key, strlen(key), 0) == ENGINE_SUCCESS); assert(h1->get_item_info(h, NULL, it, &item_info) == true); assert(item_info.value[0].iov_len == sizeof(int)); assert(*(int*)(item_info.value[0].iov_base) == 9); h1->release(h, NULL, it); return SUCCESS; } /* * Verify append behavior */ static enum test_result append_test(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1) { item *it; void *key = "key"; uint64_t cas; assert(h1->allocate(h, NULL, &it, key, strlen(key), 5, 1, 0, 0) == ENGINE_SUCCESS); item_info item_info = { .nvalue = 1 }; assert(h1->get_item_info(h, NULL, it, &item_info) == true); memcpy(item_info.value[0].iov_base, "HELLO", 5); assert(h1->store(h, NULL, it, &cas, OPERATION_SET, 0) == ENGINE_SUCCESS); h1->release(h, NULL, it); assert(h1->allocate(h, NULL, &it, key, strlen(key), 6, 1, 0,0) == ENGINE_SUCCESS); item_info.nvalue = 1; assert(h1->get_item_info(h, NULL, it, &item_info) == true); memcpy(item_info.value[0].iov_base, " WORLD", 6); assert(h1->store(h, NULL, it, &cas, OPERATION_APPEND, 0) == ENGINE_SUCCESS); h1->release(h, NULL, it); assert(h1->get(h, NULL, &it, key, strlen(key), 0) == ENGINE_SUCCESS); assert(h1->get_item_info(h, NULL, it, &item_info) == true); assert(item_info.value[0].iov_len == 11); assert(memcmp(item_info.value[0].iov_base, "HELLO WORLD", 11) == 0); h1->release(h, NULL, it); return SUCCESS; } /* * Verify prepend behavior */ static enum test_result prepend_test(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1) { item *it; void *key = "key"; uint64_t cas; assert(h1->allocate(h, NULL, &it, key, strlen(key), 5, 1, 0,0) == ENGINE_SUCCESS); item_info item_info = { .nvalue = 1 }; assert(h1->get_item_info(h, NULL, it, &item_info) == true); memcpy(item_info.value[0].iov_base, "HELLO", 5); assert(h1->store(h, NULL, it, &cas, OPERATION_SET, 0) == ENGINE_SUCCESS); h1->release(h, NULL, it); assert(h1->allocate(h, NULL, &it, key, strlen(key), 6, 1, 0,0) == ENGINE_SUCCESS); item_info.nvalue = 1; assert(h1->get_item_info(h, NULL, it, &item_info) == true); memcpy(item_info.value[0].iov_base, " WORLD", 6); assert(h1->store(h, NULL, it, &cas, OPERATION_PREPEND, 0) == ENGINE_SUCCESS); h1->release(h, NULL, it); assert(h1->get(h, NULL, &it, key, strlen(key), 0) == ENGINE_SUCCESS); assert(h1->get_item_info(h, NULL, it, &item_info) == true); assert(item_info.value[0].iov_len == 11); assert(memcmp(item_info.value[0].iov_base, " WORLDHELLO", 11) == 0); h1->release(h, NULL, it); return SUCCESS; } /* * Make sure when we can successfully store an item after it has been allocated * and that the cas for the stored item has been generated. */ static enum test_result store_test(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1) { item *test_item = NULL; void *key = "bkey"; uint64_t cas = 0; assert(h1->allocate(h, NULL, &test_item, key, strlen(key), 1,1,1, 0 ) == ENGINE_SUCCESS); assert(h1->store(h, NULL, test_item, &cas, OPERATION_SET,0) == ENGINE_SUCCESS); assert(cas != 0); h1->release(h,NULL,test_item); return SUCCESS; }