static void test_double() { printf ("Test double insertion\n"); Trie *trie = test_insert (0, "", "root"); succeed_if (trie, "could not insert into trie"); Trie *t1 = test_insert (trie, "user/tests/simple", "t1"); succeed_if (t1, "could not insert into trie"); succeed_if (t1 == trie, "should be the same"); // output_trie (trie); Trie *t2 = test_insert (trie, "user/tests/simple", "t2"); succeed_if (t2, "could not insert into trie"); succeed_if (t2 == trie, "should be not the same"); // output_trie (trie); /* ... gets lost Trie *t3 = test_insert (trie, "user/tests/simple", "t3"); succeed_if (t3, "could not insert into trie"); succeed_if (t3 == trie, "should be not the same"); // output_trie (trie); */ elektraTrieClose(trie, 0); }
static void test_umlauts() { printf ("Test umlauts trie\n"); Trie *trie = test_insert (0, "user/umlauts/test", "slash"); trie = test_insert (trie, "user/umlauts#test", "hash"); trie = test_insert (trie, "user/umlauts test", "space"); trie = test_insert (trie, "user/umlauts\200test", "umlauts"); exit_if_fail (trie, "trie was not build up successfully"); Key *searchKey = keyNew("user", KEY_END); Backend *backend = elektraTrieLookup(trie, searchKey); succeed_if (!backend, "there should be no backend"); Key *mp = keyNew("user/umlauts/test", KEY_VALUE, "slash", KEY_END); keySetName(searchKey, "user/umlauts/test"); backend = elektraTrieLookup(trie, searchKey); succeed_if (backend, "there should be a backend"); compare_key(backend->mountpoint, mp); keySetName(searchKey, "user/umlauts#test"); keySetName(mp, "user/umlauts#test"); keySetString(mp, "hash"); Backend *b2 = elektraTrieLookup(trie, searchKey); succeed_if (b2, "there should be a backend"); succeed_if (backend != b2, "should be other backend"); compare_key(b2->mountpoint, mp); keySetName(searchKey, "user/umlauts test"); keySetName(mp, "user/umlauts test"); keySetString(mp, "space"); b2 = elektraTrieLookup(trie, searchKey); succeed_if (b2, "there should be a backend"); succeed_if (backend != b2, "should be other backend"); compare_key(b2->mountpoint, mp); keySetName(searchKey, "user/umlauts\200test"); keySetName(mp, "user/umlauts\200test"); keySetString(mp, "umlauts"); b2 = elektraTrieLookup(trie, searchKey); succeed_if (b2, "there should be a backend"); succeed_if (backend != b2, "should be other backend"); compare_key(b2->mountpoint, mp); // output_trie(trie); elektraTrieClose(trie, 0); keyDel (mp); keyDel (searchKey); }
int main(){ test_init(); test_insert(); printf("Tests finished"); return 0; }
int main(int argc, char *argv[]) { const char * test_server = (argc > 1 ? argv[1] : TEST_SERVER); mongo conn[1]; char version[10]; INIT_SOCKETS_FOR_WINDOWS; test_write_concern_finish( ); CONN_CLIENT_TEST; ASSERT( conn->write_concern != (void*)0 ); test_insert( conn ); if( mongo_get_server_version( version ) != -1 && version[0] != '1' ) { test_write_concern_input( conn ); test_update_and_remove( conn ); test_batch_insert_with_continue( conn ); } mongo_destroy( conn ); test_write_concern_api(); return 0; }
void test_generic_multiset<ValueTraits, ContainerDefiner>::test_all () { typedef typename ValueTraits::value_type value_type; static const int random_init[6] = { 3, 2, 4, 1, 5, 2 }; value_cont_type values (6); for (int i = 0; i < 6; ++i) (&values[i])->value_ = random_init[i]; typedef ContainerDefiner < value_type , value_traits<ValueTraits> , constant_time_size<value_type::constant_time_size> > definer_function; typedef typename definer_function::type multiset_type; { multiset_type testset(values.begin(), values.end()); test::test_container(testset); testset.clear(); testset.insert(values.begin(), values.end()); test::test_common_unordered_and_associative_container(testset, values); testset.clear(); testset.insert(values.begin(), values.end()); test::test_associative_container(testset, values); testset.clear(); testset.insert(values.begin(), values.end()); test::test_non_unique_container(testset, values); } test_sort(values); test_insert(values); test_swap(values); test_find(values); test_impl(); test_generic_assoc<ValueTraits, ContainerDefiner>::test_all(values); }
static void test_minimaltrie() { printf ("Test minimal trie\n"); Trie *trie = test_insert (0, "", ""); Key *s = keyNew ("", KEY_END); Key *mp = keyNew ("", KEY_VALUE, "", KEY_END); succeed_if (elektraTrieLookup (trie, s), "trie should not be null"); compare_key(elektraTrieLookup (trie, s)->mountpoint, mp); keySetName (s, "user"); compare_key(elektraTrieLookup (trie, s)->mountpoint, mp); keySetName (s, "system"); compare_key(elektraTrieLookup (trie, s)->mountpoint, mp); keySetName (s, "user/below"); compare_key(elektraTrieLookup (trie, s)->mountpoint, mp); keySetName (s, "system/below"); compare_key(elektraTrieLookup (trie, s)->mountpoint, mp); elektraTrieClose(trie, 0); keyDel (s); keyDel (mp); }
void test_generic_set<ValueTraits, ContainerDefiner>::test_all() { typedef typename ValueTraits::value_type value_type; static const int random_init[6] = { 3, 2, 4, 1, 5, 2 }; std::vector<value_type> values (6); for (int i = 0; i < 6; ++i) values[i].value_ = random_init[i]; typedef typename ContainerDefiner < value_type , value_traits<ValueTraits> , constant_time_size<value_type::constant_time_size> >::type set_type; { set_type testset(values.begin(), values.end()); test::test_container(testset); testset.clear(); testset.insert(values.begin(), values.end()); test::test_common_unordered_and_associative_container(testset, values); testset.clear(); testset.insert(values.begin(), values.end()); test::test_associative_container(testset, values); testset.clear(); testset.insert(values.begin(), values.end()); test::test_unique_container(testset, values); } test_sort(values); test_insert(values); test_insert_advanced(values); test_swap(values); test_find(values); test_impl(); test_generic_assoc<ValueTraits, ContainerDefiner>::test_all(values); }
int main() { mongo conn[1]; char version[10]; INIT_SOCKETS_FOR_WINDOWS; test_write_concern_finish( ); if( mongo_client( conn, TEST_SERVER, 27017 ) != MONGO_OK ) { printf( "failed to connect\n" ); exit( 1 ); } ASSERT( conn->write_concern != (void*)0 ); test_insert( conn ); if( mongo_get_server_version( version ) != -1 && version[0] != '1' ) { test_write_concern_input( conn ); test_update_and_remove( conn ); test_batch_insert_with_continue( conn ); } mongo_destroy( conn ); return 0; }
int main() { BTree *tree; BTree *find; int depth; char *array[11]; array[0] = "5"; array[1] = "1"; array[2] = "6"; array[3] = "9"; array[4] = "0"; array[5] = "4"; array[6] = "3"; array[7] = "8"; array[8] = "2"; array[9] = "7"; array[10] = "4"; tree = array_to_btree(array); /*print_preorder(tree);*/ printLevelOrder(tree,5); depth = btree_depth(tree); printf("d_array:%d\n", depth); find = btree_find(tree, "A"); /*print_preorder(find);*/ if(find == NULL){ printf("Not found.\n"); }else{ printLevelOrder(find,5); } btree_free(tree); test_insert(); return 0; }
int main(){ int i; int a[] = {8, 2, 7, 9, 11, 3, 2, 6}; BST_PTR t = bst_create(); for(i=0; i<8; i++) bst_insert(t, a[i]); assert(bst_size(t) == 7); test_insert(t); test_contains(t); bst_inorder(t); bst_preorder(t); bst_postorder(t); bst_ith_smallest(t, 1) bst_size(t); bst_free(t); }
int main() { test_insert(); test_lookup(); test_remove(); return 0; }
static void test_emptyvalues() { printf ("Test empty values in trie\n"); Trie *trie = 0; trie = test_insert (trie, "user/umlauts/b/", "b"); trie = test_insert (trie, "user/umlauts/a/", "a"); trie = test_insert (trie, "user/umlauts/", "/"); trie = test_insert (trie, "user/umlauts/c/", "c"); trie = test_insert (trie, "user/", "u"); exit_if_fail (trie, "trie was not build up successfully"); // output_trie(trie); elektraTrieClose(trie, 0); }
void test_insert( uint32_t num_nodes , uint32_t num_inserts , uint32_t num_duplicates , bool near ) { typedef Kokkos::UnorderedMap<uint32_t,uint32_t, Device> map_type; typedef Kokkos::UnorderedMap<const uint32_t,const uint32_t, Device> const_map_type; const uint32_t expected_inserts = (num_inserts + num_duplicates -1u) / num_duplicates; map_type map; map.rehash(num_nodes,false); if (near) { Impl::TestInsert<map_type,true> test_insert(map, num_inserts, num_duplicates); test_insert.testit(); } else { Impl::TestInsert<map_type,false> test_insert(map, num_inserts, num_duplicates); test_insert.testit(); } const bool print_list = false; if (print_list) { Kokkos::Impl::UnorderedMapPrint<map_type> f(map); f.apply(); } const uint32_t map_size = map.size(); ASSERT_FALSE( map.failed_insert()); { EXPECT_EQ(expected_inserts, map_size); { uint32_t find_errors = 0; Impl::TestFind<const_map_type> test_find(map, num_inserts, num_duplicates); test_find.testit(find_errors); EXPECT_EQ( 0u, find_errors); } map.begin_erase(); Impl::TestErase<map_type,false> test_erase(map, num_inserts, num_duplicates); test_erase.testit(); map.end_erase(); EXPECT_EQ(0u, map.size()); } }
static void run_tests() { test_misc(); test_insert(); test_remove(); test_clear(); test_extend(); test_circular(); }
int main(void){ test_insert(); test_insert_list3(); printf("Success, no errors\n"); return 0; }
static void test_root() { printf ("Test trie with root\n"); Trie *trie = 0; trie = test_insert (trie, "", "root"); trie = test_insert (trie, "user/tests/simple", "simple"); exit_if_fail (trie, "trie was not build up successfully"); Key *searchKey = keyNew("user", KEY_END); Key *rmp = keyNew("", KEY_VALUE, "root", KEY_END); Backend *backend = elektraTrieLookup(trie, searchKey); succeed_if (backend, "there should be the root backend"); compare_key(backend->mountpoint, rmp); Key *mp = keyNew("user/tests/simple", KEY_VALUE, "simple", KEY_END); keySetName(searchKey, "user/tests/simple"); backend = elektraTrieLookup(trie, searchKey); succeed_if (backend, "there should be a backend"); compare_key(backend->mountpoint, mp); keySetName(searchKey, "user/tests/simple/below"); Backend *b2 = elektraTrieLookup(trie, searchKey); succeed_if (b2, "there should be a backend"); succeed_if (backend == b2, "should be same backend"); compare_key(b2->mountpoint, mp); keySetName(searchKey, "user/tests/simple/deep/below"); b2 = elektraTrieLookup(trie, searchKey); succeed_if (b2, "there should be a backend"); succeed_if (backend == b2, "should be same backend"); compare_key(b2->mountpoint, mp); // output_trie(trie); elektraTrieClose(trie, 0); keyDel (mp); keyDel (rmp); keyDel (searchKey); }
int main() { test_empty_rope(); test_append(); test_prepend(); test_insert(); test_erase(); return 0; }
/* Program entry point */ int main(int argc, char **argv) { cb_tree_t tree = cb_tree_make(); printf("%d ", ++tnum); fflush(stdout); test_insert(&tree); printf("%d ", ++tnum); fflush(stdout); test_complete(&tree, sizeof(dict) / sizeof(const char *)); printf("%d ", ++tnum); fflush(stdout); test_insert_dup(&tree); printf("%d ", ++tnum); fflush(stdout); test_contains(&tree); printf("%d ", ++tnum); fflush(stdout); test_delete(&tree); printf("%d ", ++tnum); fflush(stdout); cb_tree_clear(&tree); test_insert(&tree); test_complete(&tree, sizeof(dict) / sizeof(const char *)); printf("%d ", ++tnum); fflush(stdout); test_delete_all(&tree); printf("%d ", ++tnum); fflush(stdout); test_complete(&tree, 0); printf("%d ", ++tnum); fflush(stdout); cb_tree_clear(&tree); test_empty(&tree); printf("%d ", ++tnum); fflush(stdout); test_insert(&tree); test_prefixes(&tree); cb_tree_clear(&tree); printf("ok\n"); return 0; }
void test_failed_insert( uint32_t num_nodes) { typedef Kokkos::UnorderedMap<uint32_t,uint32_t, Device> map_type; map_type map(num_nodes); Impl::TestInsert<map_type> test_insert(map, 2u*num_nodes, 1u); test_insert.testit(false /*don't rehash on fail*/); Device::execution_space::fence(); EXPECT_TRUE( map.failed_insert() ); }
int main() { test_push_back(); test_emplace_back(); test_insert_range(); test_insert(); test_emplace(); test_insert_range2(); test_insert_n(); test_insert_n2(); test_resize(); test_resize_param(); }
void test_insert (charT*, Traits*, Allocator*, const StringTestCaseData<charT> &tdata) { typedef std::basic_string<charT, Traits, Allocator> String; if (tdata.func_.which_ == Insert (iter_range)) { switch (tdata.func_.iter_id_) { // exercise possible overloads of the member function template // on common RandomAccessIterator types #undef TEST #define TEST(Iterator) do { \ typedef typename String::Iterator Iter; \ static const \ InsertRangeOverload<String, Iter> rng; \ test_insert ((charT*)0, (Traits*)0, (Allocator*)0, rng, tdata); \ } while (0) case StringIds::Pointer: TEST (pointer); break; case StringIds::ConstPointer: TEST (const_pointer); break; case StringIds::Iterator: TEST (iterator); break; case StringIds::ConstIterator: TEST (const_iterator); break; case StringIds::ReverseIterator: TEST (reverse_iterator); break; case StringIds::ConstReverseIterator: TEST (const_reverse_iterator); break; // exercise specializations of the member function template // on the required iterator categories #undef TEST #define TEST(Iterator) do { \ typedef Iterator<charT> Iter; \ static const \ InsertRange<String, Iter> rng; \ test_insert ((charT*)0, (Traits*)0, (Allocator*)0, rng, tdata); \ } while (0) case StringIds::Input: TEST (InputIter); break; case StringIds::Forward: TEST (ConstFwdIter); break; case StringIds::Bidir: TEST (ConstBidirIter); break; case StringIds::Random: TEST (ConstRandomAccessIter); break; default: rw_error (0, 0, __LINE__, "bad iterator id"); } } else { // exercise ordinary overloads of the member function static const RangeBase<String> rng; test_insert ((charT*)0, (Traits*)0, (Allocator*)0, rng, tdata); } }
int main(int argc, char **argv) { int i; SQLLEN bytes_returned; /* do not allocate so big memory in stack */ buf = (unsigned char *) malloc(TEST_BUF_LEN); odbc_connect(); odbc_command("create table " TEST_TABLE_NAME " (im IMAGE)"); odbc_command("SET TEXTSIZE 1000000"); /* populate test buffer with ramp */ for (i = 0; i < TEST_BUF_LEN; i++) { buf[i] = BYTE_AT(i); } /* insert test pattern into database */ if (test_insert(buf, TEST_BUF_LEN) == -1) { clean_up(); return -1; } memset(buf, 0, TEST_BUF_LEN); /* read test pattern from database */ if (test_select(buf, TEST_BUF_LEN, &bytes_returned) == -1) { clean_up(); return -1; } /* compare inserted and read back test patterns */ if (bytes_returned != TEST_BUF_LEN) { show_error("main(): comparing buffers", "Mismatch in input and output pattern sizes."); clean_up(); return -1; } for (i = 0; i < TEST_BUF_LEN; ++i) { if (buf[i] != BYTE_AT(i)) { printf("mismatch at pos %d %d != %d\n", i, buf[i], BYTE_AT(i)); show_error("main(): comparing buffers", "Mismatch in input and output patterns."); clean_up(); return -1; } } printf("Input and output buffers of length %d match.\nTest passed.\n", TEST_BUF_LEN); clean_up(); return 0; }
void test_deep_copy( uint32_t num_nodes ) { typedef Kokkos::UnorderedMap<uint32_t,uint32_t, Device> map_type; typedef Kokkos::UnorderedMap<const uint32_t, const uint32_t, Device> const_map_type; typedef typename map_type::HostMirror host_map_type ; // typedef Kokkos::UnorderedMap<uint32_t, uint32_t, typename Device::host_mirror_execution_space > host_map_type; map_type map; map.rehash(num_nodes,false); { Impl::TestInsert<map_type> test_insert(map, num_nodes, 1); test_insert.testit(); ASSERT_EQ( map.size(), num_nodes); ASSERT_FALSE( map.failed_insert() ); { uint32_t find_errors = 0; Impl::TestFind<map_type> test_find(map, num_nodes, 1); test_find.testit(find_errors); EXPECT_EQ( find_errors, 0u); } } host_map_type hmap; Kokkos::deep_copy(hmap, map); ASSERT_EQ( map.size(), hmap.size()); ASSERT_EQ( map.capacity(), hmap.capacity()); { uint32_t find_errors = 0; Impl::TestFind<host_map_type> test_find(hmap, num_nodes, 1); test_find.testit(find_errors); EXPECT_EQ( find_errors, 0u); } map_type mmap; Kokkos::deep_copy(mmap, hmap); const_map_type cmap = mmap; EXPECT_EQ( cmap.size(), num_nodes); { uint32_t find_errors = 0; Impl::TestFind<const_map_type> test_find(cmap, num_nodes, 1); test_find.testit(find_errors); EXPECT_EQ( find_errors, 0u); } }
int main() { BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::list<int> >::value)); BOOST_STATIC_ASSERT((!phx::stl::has_key_type<std::list<int> >::value)); std::list<int> const data = build_list(); test_empty(data); test_end(data); test_erase(data); test_front(data); test_get_allocator(data); test_insert(data); test_max_size(data); return boost::report_errors(); }
virtual void run(void) { try { std::cout << "before" << std::endl; std::auto_ptr<SqlConnection> connection = dataSource_->getConnection(); std::cout << "after" << std::endl; test_insert(*connection); // test_insert(*connection); // transaction->commit(); } catch (SqlException& e) { std::cout << e.getMessage() << std::endl; } }
} SDFV # endif main (int argc, char *argv[]) { // Func1(); test_allocfree(); test_member(); test_nthchild(); // test_clone(); test_fileio(); test_assign(); // test_error(); test_insert(); // test_notify(); }
int main() { std::deque<int> const data = build_deque(); test_insert(data); test_max_size(data); test_pop_back(data); test_pop_front(data); test_push_back(data); test_push_front(data); test_rbegin(data); test_rend(data); test_resize(data); test_size(data); return boost::report_errors(); }
void test_slist(struct cag_test_series *tests) { test_it(tests); test_new(tests); test_prepend(tests); test_insert(tests); test_insertp(tests); test_distance(tests); test_front(tests); test_erase(tests); test_copy(tests); test_reverse(tests); test_copy_over(tests); test_sort(tests); test_find(tests); }
int main(int args, char *arg[]) { list_t *list = NULL; list = test_create(); test_insert(list); test_delete(list); test_examine(list); test_distroy(&list); list = test_create(); test_sorting(list); test_distroy(&list); test_concat_lists(); test_merge_lists(); test_reverse_lists(); exit (EXIT_SUCCESS); }
/* * The main function just calls all unit tests and prints a summary * message (success or failure). * * \return zero on success. */ int main (int argc, char ** argv) { int ok = 1; if (0 != test_append()) ok = 0; if (0 != test_prepend()) ok = 0; if (0 != test_insert()) ok = 0; if (0 != test_remove()) ok = 0; if (ok) { printf ("\nall tests PASSED\n"); return 0; } printf ("\none or more tests FAILED\n"); return 1; }