static void test_exceptions(void) { hashset_t set = hashset_create(); assert(hashset_add(set, (void *)0) == -1); assert(hashset_add(set, (void *)1) == -1); }
static void test_gaps(void) { hashset_t set = hashset_create(); /* fill the hashset */ hashset_add(set, (void *)0xbabe); hashset_add(set, (void *)0xbeef); hashset_add(set, (void *)0xbad); hashset_add(set, (void *)0xf00d); /* 0xf00d (nil) (nil) (nil) (nil) 0xbad 0xbabe 0xbeef */ /* make a gap */ hashset_remove(set, (void *)0xbeef); /* 0xf00d (nil) (nil) (nil) (nil) 0xbad 0xbabe 0x1 */ /* check that 0xf00d is still reachable */ assert(hashset_is_member(set, (void *)0xf00d)); /* add 0xbeef back */ hashset_add(set, (void *)0xbeef); /* 0xf00d (nil) (nil) (nil) (nil) 0xbad 0xbabe 0xbeef */ /* verify */ assert(hashset_is_member(set, (void *)0xbeef)); assert(hashset_is_member(set, (void *)0xf00d)); }
static void trivial(void) { char *missing = "missing"; char *items[] = {"zero", "one", "two", "three", NULL}; char *foo = "foo"; size_t ii, nitems = 4; hashset_t set = hashset_create(); if (set == NULL) { fprintf(stderr, "failed to create hashset instance\n"); abort(); } for (ii = 0; ii < nitems; ++ii) { hashset_add(set, items[ii]); } for (ii = 0; ii < nitems; ++ii) { assert(hashset_is_member(set, items[ii])); } assert(hashset_is_member(set, missing) == 0); assert(hashset_remove(set, items[1]) == 1); assert(hashset_num_items(set) == 3); assert(hashset_remove(set, items[1]) == 0); assert(hashset_add(set, foo) == 1); assert(hashset_add(set, foo) == 0); hashset_destroy(set); }
hashset_t hashset_addition(hashset_t set, hashset_t add) { hashset_t ret = hashset_create(); hashset_union(ret,set); hashset_union(ret,add); return ret; }
int main(int argc, char** argv) { hashset_init(argc, argv, 4); struct timeval tv; gettimeofday(&tv, 0); srand(tv.tv_usec); unsigned i; #ifdef PTHREAD hashset_create(TABLE_SIZE, GRT_TRUE); #else hashset_create(TABLE_SIZE, GRT_FALSE); #endif BARRIER(); grt_debug_print("generating numbers\n"); for (i = 0; i < N; ++i) { numbers[i] = rand(); } grt_debug_print("inserting numbers\n"); for (i = 0; i < N; ++i) { hashset_insert(numbers[i]); } BARRIER(); grt_debug_print("finding numbers\n"); for (i = 0; i < N; ++i) { grt_word_t num = numbers[i]; unsigned found = hashset_find(num); if (!found) { fprintf(stderr, "processor %d: expected to find %llx\n", grt_id, num); } } BARRIER(); grt_debug_print("done\n"); hashset_destroy(); hashset_exit(0); }
/** * * @param n_props number of properties (html_tags+property-names) * @param properties array of props and html tag names alternately * @return an initialised matrix */ matrix *matrix_create( int n_props, UChar **properties ) { matrix *m = calloc(1,sizeof(matrix) ); if ( m != NULL ) { m->n_props = n_props/2; m->names = calloc( m->n_props, sizeof(UChar*) ); m->html_tags = calloc( m->n_props, sizeof(UChar*) ); if ( m->names != NULL && m->html_tags != NULL ) { int i,j; for ( j=0,i=0;i<n_props-1;j++,i+=2 ) { m->names[j] = u_strdup(properties[i]); //printf("%s\n",properties[i]); m->html_tags[j] = (properties[i+1]==NULL) ?NULL:u_strdup(properties[i+1]); } m->cells = (int*)calloc( m->n_props*m->n_props, sizeof(int) ); if ( m->cells == NULL ) { matrix_dispose( m ); m = NULL; warning("failed to allocate %dx%d matrix\n",n_props,n_props); } else { m->lookup = hashset_create(); if ( m->lookup == NULL ) { matrix_dispose( m ); m = NULL; } else { int k; for ( k=0;k<m->n_props;k++ ) { hashset_put( m->lookup, m->names[k] ); } } } } else { warning("matrix: failed to allocate names and tags\n"); matrix_dispose( m ); m = NULL; } } return m; }
int main( int argc, char **argv ) { hashset *hs = hashset_create(); if ( hs != NULL ) { char utmp[32]; hashset_put( hs, str2ustr("banana",utmp,32) ); hashset_put( hs, str2ustr("apple",utmp,32) ); hashset_put( hs, str2ustr("pineapple",utmp,32) ); hashset_put( hs, str2ustr("guava",utmp,32) ); hashset_put( hs, str2ustr("watermelon",utmp,32) ); hashset_put( hs, str2ustr("orange",utmp,32) ); hashset_put( hs, str2ustr("starfruit",utmp,32) ); hashset_put( hs, str2ustr("durian",utmp,32) ); hashset_put( hs, str2ustr("cherry",utmp,32) ); hashset_put( hs, str2ustr("apricot",utmp,32) ); hashset_put( hs, str2ustr("peach",utmp,32) ); hashset_put( hs, str2ustr("pear",utmp,32) ); hashset_put( hs, str2ustr("nectarine",utmp,32) ); hashset_put( hs, str2ustr("plum",utmp,32) ); hashset_put( hs, str2ustr("grape",utmp,32) ); hashset_put( hs, str2ustr("mandarin",utmp,32) ); hashset_put( hs, str2ustr("lemon",utmp,32) ); hashset_put( hs, str2ustr("clementine",utmp,32) ); hashset_put( hs, str2ustr("cumquat",utmp,32) ); hashset_put( hs, str2ustr("custard apple",utmp,32) ); hashset_put( hs, str2ustr("asian pear",utmp,32) ); hashset_put( hs, str2ustr("jakfruit",utmp,32) ); hashset_put( hs, str2ustr("rambutan",utmp,32) ); hashset_put( hs, str2ustr("lime",utmp,32) ); hashset_put( hs, str2ustr("lychee",utmp,32) ); hashset_put( hs, str2ustr("mango",utmp,32) ); hashset_put( hs, str2ustr("mangosteen",utmp,32) ); hashset_put( hs, str2ustr("avocado",utmp,32) ); hashset_put( hs, str2ustr("grandilla",utmp,32) ); hashset_put( hs, str2ustr("grumichama",utmp,32) ); hashset_put( hs, str2ustr("breadfruit",utmp,32) ); // repeats hashset_put( hs, str2ustr("banana",utmp,32) ); hashset_put( hs, str2ustr("apple",utmp,32) ); hashset_put( hs, str2ustr("pineapple",utmp,32) ); hashset_put( hs, str2ustr("guava",utmp,32) ); hashset_put( hs, str2ustr("watermelon",utmp,32) ); hashset_print( hs ); printf("number of elements in set=%d\n",hashset_size(hs)); } }
void run() { unsigned i, time; gasnett_tick_t start, end; hashset_create(params[HASHSET_SIZE], params[ON_PTHREAD]); BARRIER(); start = gasnett_ticks_now(); for (i = 0; i < MY_NUM_OPS; ++i) { if (put_flags[i] == GRT_TRUE) { hashset_insert(numbers[i]); } else { hashset_find(numbers[i]); } } end = gasnett_ticks_now(); time = ((unsigned) gasnett_ticks_to_us(end - start)); //printf("processor %u: execution time=%f us\n", // grt_id, (double) time); fflush(stdout); grt_write(0, time, ×[grt_id]); BARRIER(); if (grt_id == 0) { time = 0, max_time = 0; for (i = 0; i < grt_num_procs; ++i) { gasnett_tick_t this_time = times[i]; time += this_time; if (this_time >= max_time) max_time = this_time; } time_per_op = ((float) time) / params[NUM_OPS]; printf("total CPU time=%f us\n", (double) time); printf("time per operation=%f us\n", time_per_op); printf("max time=%f us\n", (double) max_time); } BARRIER(); hashset_destroy(); BARRIER(); }
static void test_fill_with_deleted_items() { char *s = "some string"; hashset_t set = hashset_create(); if (set == NULL) abort(); /* fill `set` with deleted items */ for (int i = 0; i < 8; ++i) { hashset_add(set, s + i); hashset_remove(set, s + i); } /* this should not cause an infinite loop */ assert(hashset_is_member(set, s) == 0); hashset_destroy(set); }
hashset_t hashset_substraction(hashset_t set, hashset_t substrahend) { hashset_t ret = hashset_create(); hashset_union(ret,set); int i; for(i = 0; i < substrahend->nitems; i++) { char* value = substrahend->items[i]; if(value != NULL) { if(hashset_is_member(ret,value)) { hashset_remove(ret, value); } } } return ret; }
static void test_iterating(void) { hashset_t set = hashset_create(); hashset_itr_t iter = hashset_iterator(set); int step; /* fill the hashset */ hashset_add(set, (void *)"Bob"); hashset_add(set, (void *)"Steve"); hashset_add(set, (void *)"Karen"); hashset_add(set, (void *)"Ellen"); step = 0; while(hashset_iterator_has_next(iter)) { if(step == 0) { assert(strncmp((char *)hashset_iterator_value(iter), "Karen", 5) == 0); } if(step == 1) { assert(strncmp((char *)hashset_iterator_value(iter), "Steve", 5) == 0); } if(step == 2) { assert(strncmp((char *)hashset_iterator_value(iter), "Bob", 3) == 0); } if(step == 3) { assert(strncmp((char *)hashset_iterator_value(iter), "Ellen", 5) == 0); } hashset_iterator_next(iter); step++; } assert(hashset_iterator_has_next(iter) == 0); assert(hashset_iterator_next(iter) == -1); }
LIBCOUCHBASE_API lcb_error_t lcb_create(lcb_t *instance, const struct lcb_create_st *options) { const char *host = NULL; const char *user = NULL; const char *passwd = NULL; const char *bucket = NULL; struct lcb_io_opt_st *io = NULL; struct lcb_create_st options_container; struct lcb_create_st2 *e_options = &options_container.v.v2; lcb_type_t type = LCB_TYPE_BUCKET; lcb_t obj; lcb_error_t err; lcb_settings *settings; err = normalize_options(&options_container, options); if (err != LCB_SUCCESS) { return err; } host = get_nonempty_string(e_options->host); user = get_nonempty_string(e_options->user); passwd = get_nonempty_string(e_options->passwd); bucket = get_nonempty_string(e_options->bucket); io = e_options->io; type = e_options->type; if (type == LCB_TYPE_CLUSTER && user == NULL && passwd == NULL) { return LCB_EINVAL; } if (host == NULL) { host = "localhost"; } if (bucket == NULL) { bucket = "default"; } /* Do not allow people use Administrator account for data access */ if (type == LCB_TYPE_BUCKET && user && strcmp(user, bucket) != 0) { return LCB_INVALID_USERNAME; } if ((obj = calloc(1, sizeof(*obj))) == NULL) { return LCB_CLIENT_ENOMEM; } obj->type = type; obj->compat.type = (lcb_compat_t)0xdead; if (io == NULL) { lcb_io_opt_t ops; if ((err = lcb_create_io_ops(&ops, NULL)) != LCB_SUCCESS) { /* You can't initialize the library without a io-handler! */ free(obj); return err; } io = ops; io->v.v0.need_cleanup = 1; } settings = &obj->settings; settings->randomize_bootstrap_nodes = 1; settings->bummer = 0; settings->io = io; obj->syncmode = LCB_ASYNCHRONOUS; settings->ipv6 = LCB_IPV6_DISABLED; settings->operation_timeout = LCB_DEFAULT_TIMEOUT; settings->config_timeout = LCB_DEFAULT_CONFIGURATION_TIMEOUT; settings->config_node_timeout = LCB_DEFAULT_NODECONFIG_TIMEOUT; settings->views_timeout = LCB_DEFAULT_VIEW_TIMEOUT; settings->rbufsize = LCB_DEFAULT_RBUFSIZE; settings->wbufsize = LCB_DEFAULT_WBUFSIZE; settings->durability_timeout = LCB_DEFAULT_DURABILITY_TIMEOUT; settings->durability_interval = LCB_DEFAULT_DURABILITY_INTERVAL; settings->http_timeout = LCB_DEFAULT_HTTP_TIMEOUT; settings->weird_things_threshold = LCB_DEFAULT_CONFIG_ERRORS_THRESHOLD; settings->weird_things_delay = LCB_DEFAULT_CONFIG_ERRORS_DELAY; settings->max_redir = LCB_DEFAULT_CONFIG_MAXIMUM_REDIRECTS; settings->grace_next_cycle = LCB_DEFAULT_CLCONFIG_GRACE_CYCLE; settings->grace_next_provider = LCB_DEFAULT_CLCONFIG_GRACE_NEXT; settings->bc_http_stream_time = LCB_DEFAULT_BC_HTTP_DISCONNTMO; settings->bucket = strdup(bucket); settings->logger = lcb_init_console_logger(); settings->iid = lcb_instance_index++; if (user) { settings->username = strdup(user); } else { settings->username = strdup(settings->bucket); } if (passwd) { settings->password = strdup(passwd); } lcb_initialize_packet_handlers(obj); obj->memd_sockpool = connmgr_create(settings, io); obj->memd_sockpool->max_idle = 1; obj->memd_sockpool->idle_timeout = 10000000; obj->confmon = lcb_confmon_create(settings); obj->usernodes = hostlist_create(); /** We might want to sanitize this a bit more later on.. */ if (strstr(host, "://") != NULL && strstr(host, "http://") == NULL) { lcb_destroy(obj); return LCB_INVALID_HOST_FORMAT; } err = hostlist_add_string(obj->usernodes, host, -1, LCB_CONFIG_HTTP_PORT); if (err != LCB_SUCCESS) { lcb_destroy(obj); return err; } err = lcb_init_providers(obj, e_options); if (err != LCB_SUCCESS) { lcb_destroy(obj); return err; } lcb_initialize_packet_handlers(obj); obj->timers = hashset_create(); obj->http_requests = hashset_create(); obj->durability_polls = hashset_create(); /* No error has occurred yet. */ obj->last_error = LCB_SUCCESS; if ((obj->cmdht = lcb_hashtable_szt_new(32)) == NULL) { lcb_destroy(obj); return LCB_CLIENT_ENOMEM; } if (!ringbuffer_initialize(&obj->purged_buf, 4096)) { lcb_destroy(obj); return LCB_CLIENT_ENOMEM; } if (!ringbuffer_initialize(&obj->purged_cookies, 4096)) { lcb_destroy(obj); return LCB_CLIENT_ENOMEM; } *instance = obj; return LCB_SUCCESS; }
double genHOMFitness(char* srcDir,char*target,char*makeDir,Config *user_config,char*original_source,MResult *mResult,HOMutant *hom){ char **args_combineFOM = malloc(sizeof(char*)*(hom->FOMutants_count+4)); args_combineFOM[0]="bash"; args_combineFOM[1]="combineFOM.sh"; args_combineFOM[2]=original_source; args_combineFOM[hom->FOMutants_count+2]=NULL; //Merge all the FOM source files to generate the HOM int i; for (i=0;i<hom->FOMutants_count;i++){ args_combineFOM[i+3]=hom->FOMutants[i].mutant_source_file; } startprogram(args_combineFOM,NULL,0); free(args_combineFOM); char hom_dir[strlen(srcDir)+strlen("hom_dir.log")+2]; sprintf(hom_dir,"%s/%s", srcDir, "hom_dir.log"); char hom_dir_loc[strlen(srcDir)+20]; char hom_file_name[strlen(srcDir)+20]; FILE* hom_dir_file =fopen(hom_dir,"r"); if(hom_dir_file==NULL){ return -1; } fscanf (hom_dir_file, "%s %s",hom_file_name , hom_dir_loc); fclose(hom_dir_file); copy_file(hom_dir_loc, target); //Evaluate mutant //Run make on the mutated project in order to build it printf("--> Evaluating HOM: %s\n",hom_file_name); //Open log file for recording mutation results mutation_results = fopen(mutation_results_path,"a+"); fprintf(mutation_results, "\n**** Mutant: %s ****\n",hom_file_name); fflush(mutation_results); fclose(mutation_results); mResult->homResult->total_mutants++; //Get mutants killed by tests before new evaluation int prev_killed_by_tests=get_non_trivial_FOM_stats()[0]; if(runMake(makeDir,hom_file_name,user_config->makeTestTarget)==2){ mResult->homResult->mutant_kill_count++; } //Get mutants killed by tests after evaluation int *stats = get_non_trivial_FOM_stats(); if(stats[0]-prev_killed_by_tests==1){ mResult->homResult->mutant_kill_count++; } hom->fragility=((double)stats[1]/(double)stats[2]); //Generate the fragility for all the set of FOMs that makeup this HOM hashset_t test_killed_set = hashset_create(); if (test_killed_set == NULL) { fprintf(stderr, "failed to create hashset instance\n"); abort(); } int mut,c; for(mut=0;mut<hom->FOMutants_count;mut++){ Mutant mutant = hom->FOMutants[mut]; for(c=0;c<mutant.killed_by_tests_count;c++){ hashset_add(test_killed_set, &mutant.killed_by_tests[c]); } } hom->fitness=hom->fragility/(((double)hashset_num_items(test_killed_set)/(double)stats[2])); hashset_destroy(test_killed_set); return hom->fitness; }
static void test_rehashing_items_placed_beyond_nitems(void) { hashset_t set = hashset_create(); assert(hashset_add(set, (void *)20644128) == 1); assert(hashset_add(set, (void *)21747760) == 1); assert(hashset_add(set, (void *)17204864) == 1); assert(hashset_add(set, (void *)22937440) == 1); assert(hashset_add(set, (void *)14734272) == 1); assert(hashset_add(set, (void *)13948320) == 1); assert(hashset_add(set, (void *)18116496) == 1); assert(hashset_add(set, (void *)18229952) == 1); assert(hashset_add(set, (void *)20390128) == 1); assert(hashset_add(set, (void *)23523264) == 1); assert(hashset_add(set, (void *)22866784) == 1); assert(hashset_add(set, (void *)17501248) == 1); assert(hashset_add(set, (void *)17168832) == 1); assert(hashset_add(set, (void *)13389824) == 1); assert(hashset_add(set, (void *)15795136) == 1); assert(hashset_add(set, (void *)15154464) == 1); assert(hashset_add(set, (void *)22507840) == 1); assert(hashset_add(set, (void *)22977920) == 1); assert(hashset_add(set, (void *)20527584) == 1); assert(hashset_add(set, (void *)21557872) == 1); assert(hashset_add(set, (void *)23089952) == 1); assert(hashset_add(set, (void *)21606240) == 1); assert(hashset_add(set, (void *)25168704) == 1); assert(hashset_add(set, (void *)25198096) == 1); assert(hashset_add(set, (void *)25248000) == 1); assert(hashset_add(set, (void *)25260976) == 1); assert(hashset_add(set, (void *)25905520) == 1); assert(hashset_add(set, (void *)25934608) == 1); assert(hashset_add(set, (void *)26015264) == 1); assert(hashset_add(set, (void *)26044352) == 1); assert(hashset_add(set, (void *)24784800) == 1); assert(hashset_add(set, (void *)24813888) == 1); assert(hashset_add(set, (void *)24663936) == 1); assert(hashset_add(set, (void *)24693536) == 1); assert(hashset_add(set, (void *)24743792) == 1); assert(hashset_add(set, (void *)24756480) == 1); assert(hashset_is_member(set, (void *)20644128) == 1); assert(hashset_is_member(set, (void *)21747760) == 1); assert(hashset_is_member(set, (void *)17204864) == 1); assert(hashset_is_member(set, (void *)22937440) == 1); assert(hashset_is_member(set, (void *)14734272) == 1); assert(hashset_is_member(set, (void *)13948320) == 1); assert(hashset_is_member(set, (void *)18116496) == 1); assert(hashset_is_member(set, (void *)18229952) == 1); assert(hashset_is_member(set, (void *)20390128) == 1); assert(hashset_is_member(set, (void *)23523264) == 1); assert(hashset_is_member(set, (void *)22866784) == 1); assert(hashset_is_member(set, (void *)17501248) == 1); assert(hashset_is_member(set, (void *)17168832) == 1); assert(hashset_is_member(set, (void *)13389824) == 1); assert(hashset_is_member(set, (void *)15795136) == 1); assert(hashset_is_member(set, (void *)15154464) == 1); assert(hashset_is_member(set, (void *)22507840) == 1); assert(hashset_is_member(set, (void *)22977920) == 1); assert(hashset_is_member(set, (void *)20527584) == 1); assert(hashset_is_member(set, (void *)21557872) == 1); assert(hashset_is_member(set, (void *)23089952) == 1); assert(hashset_is_member(set, (void *)21606240) == 1); assert(hashset_is_member(set, (void *)25168704) == 1); assert(hashset_is_member(set, (void *)25198096) == 1); assert(hashset_is_member(set, (void *)25248000) == 1); assert(hashset_is_member(set, (void *)25260976) == 1); assert(hashset_is_member(set, (void *)25905520) == 1); assert(hashset_is_member(set, (void *)25934608) == 1); assert(hashset_is_member(set, (void *)26015264) == 1); assert(hashset_is_member(set, (void *)26044352) == 1); assert(hashset_is_member(set, (void *)24784800) == 1); assert(hashset_is_member(set, (void *)24813888) == 1); assert(hashset_is_member(set, (void *)24663936) == 1); assert(hashset_is_member(set, (void *)24693536) == 1); assert(hashset_is_member(set, (void *)24743792) == 1); assert(hashset_is_member(set, (void *)24756480) == 1); }
int hashset_testmain(int argc, const char *argv[]) { /* 0: Test Data/Result Initialization; Test Environment peekup */ testlog = fopen("hashsettest_log.txt", "a"); testresult = fopen("hashsettest_result.txt", "a"); char *string0 = "tester0"; char *string1 = "tester1"; char *string2 = "tester2"; char *string3 = "tester3"; char *string4 = "tester4"; char *string5 = "tester5"; char *string6 = "tester6"; char *string7 = "tester7"; char *string8 = "tester8"; char *string9 = "tester9"; /* 1: No Data Structure Memory Test */ stage_log(1, "START"); HashSet *set = hashset_create(DATATYPE_STRING, POOLTYPE_LOCAL, 10); if(set != NULL) stage_result(1, "create", true, set); else stage_result(1, "create", false, set); stage_log(1, "END"); /* 2: No Node Memory Test */ stage_log(2, "START"); /* Test Data peekup */ set = hashset_create(DATATYPE_STRING, POOLTYPE_LOCAL, 10); bool stage2_result = set->add(set, string0); if(stage2_result == true) stage_result(2, "get", true, set); else stage_result(2, "get", false, set); hashset_destroy(set); stage_log(2, "END"); /* 3: Between Node Memory: NULL Data */ stage_log(3, "START"); /* Test Data peekup */ set = hashset_create(DATATYPE_STRING, POOLTYPE_LOCAL, 10); /* Test Procedure */ void* stage31_result = set->get(set, (void *)NULL); if(stage31_result != NULL) stage_result(3, "get", true, set); else stage_result(3, "get", false, set); bool stage32_result = set->add(set, (void *)NULL); if(stage32_result == true) stage_result(3, "add", true, set); else stage_result(3, "add", false, set); bool stage33_result = set->remove(set, (void*)NULL); if(stage33_result == true) stage_result(3, "remove", true, set); else stage_result(3, "remove", false, set); bool stage34_result = set->contains(set, (void *)NULL); if(stage34_result == true) stage_result(3, "contains", true, set); else stage_result(3, "contains", false, set); hashset_destroy(set); stage_log(3, "END"); /* 4: Between Node Memory: No Duplicated Data */ stage_log(4, "START"); /* Test Data removeup */ set = hashset_create(DATATYPE_STRING, POOLTYPE_LOCAL, 10); set->add(set, string0); set->add(set, string1); set->add(set, string2); set->add(set, string3); set->add(set, string4); /* Test Procedure */ void* stage41_result = set->get(set, string5); if(stage41_result != NULL) stage_result(4, "get", true, set); else stage_result(4, "get", false, set); bool stage42_result = set->add(set, string5 ); if(stage42_result == true) stage_result(4, "add", true, set); else stage_result(4, "add", false, set); bool stage43_result = set->remove(set, string5); if(stage43_result == true) stage_result(4, "remove", true, set); else stage_result(4, "remove", false, set); bool stage44_result = set->contains(set, string1); if(stage44_result == true) stage_result(4, "contains", true, set); else stage_result(4, "contains", false, set); /* abnormal case */ void* stage45_result = set->get(set, string9); if(stage45_result != NULL) stage_result(4, "abnormal get", true, set); else stage_result(4, "abnormal get", false, set); bool stage46_result = set->remove(set, string8); if(stage46_result == true) stage_result(4, "abnormal remove", true, set); else stage_result(4, "abnormal remove", false, set); bool stage47_result = set->contains(set, string8); if(stage47_result == true) stage_result(4, "abnormal contains", true, set); else stage_result(4, "abnormal contains", false, set); hashset_destroy(set); stage_log(4, "END"); /* 5: Between Node Memory: Duplicated Data */ stage_log(5, "START"); /* Test Data removeup */ set = hashset_create(DATATYPE_STRING, POOLTYPE_LOCAL, 10); set->add(set, string0); set->add(set, string1); set->add(set, string2); set->add(set, string3); set->add(set, string4); /* Test Procedure */ void* stage51_result = set->get(set, string0); if(stage51_result != NULL) stage_result(5, "get", true, set); else stage_result(5, "get", false, set); bool stage52_result = set->add(set, string1); if(stage52_result == true) stage_result(5, "add", true, set); else stage_result(5, "add", false, set); bool stage53_result = set->remove(set, string1); if(stage53_result == true) stage_result(5, "remove", true, set); else stage_result(5, "remove", false, set); bool stage54_result = set->contains(set, string1); if(stage54_result == true) stage_result(5, "contains", true, set); else stage_result(5, "contains", false, set); hashset_destroy(set); stage_log(5, "END"); /* 6: Max Node Memory: NULL Data */ stage_log(6, "START"); /* Test Data removeup */ set = hashset_create(DATATYPE_STRING, POOLTYPE_LOCAL, 10); set->add(set, string0); set->add(set, string1); set->add(set, string2); set->add(set, string3); set->add(set, string4); set->add(set, string5); set->add(set, string6); set->add(set, string7); set->add(set, string8); set->add(set, string9); /* Test Procedure */ void* stage61_result = set->get(set, (void *)NULL); if(stage61_result != NULL) stage_result(6, "get", true, set); else stage_result(6, "get", false, set); bool stage62_result = set->add(set, (void *)NULL); if(stage62_result == true) stage_result(6, "add", true, set); else stage_result(6, "add", false, set); bool stage63_result = set->remove(set, (void *)NULL); if(stage63_result == true) stage_result(6, "remove", true, set); else stage_result(6, "remove", false, set); bool stage64_result = set->contains(set, (void *)NULL); if(stage64_result == true) stage_result(6, "contains", true, set); else stage_result(6, "contains", false, set); hashset_destroy(set); stage_log(6, "END"); /* 7: Max Node Memory: No Duplicated Data */ stage_log(7, "START"); /* Test Data removeup */ set = hashset_create(DATATYPE_STRING, POOLTYPE_LOCAL, 10); set->add(set, string0); set->add(set, string1); set->add(set, string2); set->add(set, string3); set->add(set, string4); set->add(set, string5); set->add(set, string6); set->add(set, string7); set->add(set, string8); set->add(set, string9); /* Test Procedure */ void* stage71_result = set->get(set, string1); if(stage71_result != NULL) stage_result(7, "get", true, set); else stage_result(7, "get", false, set); bool stage72_result = set->add(set, string1); if(stage72_result == true) stage_result(7, "add", true, set); else stage_result(7, "add", false, set); bool stage73_result = set->remove(set, string1); if(stage73_result == true) stage_result(7, "remove", true, set); else stage_result(7, "remove", false, set); bool stage74_result = set->contains(set, string1); if(stage74_result == true) stage_result(7, "contains", true, set); else stage_result(7, "contains", false, set); hashset_destroy(set); stage_log(7, "END"); /* 8: Max Node Memory: Duplicated Data */ stage_log(8, "START"); /* Test Data removeup */ set = hashset_create(DATATYPE_STRING, POOLTYPE_LOCAL, 10); set->add(set, string0); set->add(set, string1); set->add(set, string2); set->add(set, string3); set->add(set, string4); set->add(set, string0); set->add(set, string1); set->add(set, string2); set->add(set, string3); set->add(set, string4); /* Test Procedure */ void* stage81_result = set->get(set, string1); if(stage81_result != NULL) stage_result(8, "get", true, set); else stage_result(8, "get", false, set); bool stage82_result = set->add(set, string1); if(stage82_result == true) stage_result(8, "add", true, set); else stage_result(8, "add", false, set); bool stage83_result = set->remove(set, string1); if(stage83_result == true) stage_result(8, "remove", true, set); else stage_result(8, "remove", false, set); bool stage84_result = set->contains(set, string1); if(stage84_result == true) stage_result(8, "contains", true, set); else stage_result(8, "contains", false, set); hashset_destroy(set); stage_log(8, "END"); /* 9: Test Result Store */ fclose(testlog); fclose(testresult); return 0; }
int main(int argc, char *argv[]) { hashset_t set = hashset_create(); hashset_add(set,"leer"); curl_global_init(CURL_GLOBAL_ALL); CURL * myHandle = curl_easy_init(); char md5Password [32]; struct string s; struct string g; init_string(&s); init_string(&g); int i; /* char password[BUFSIZ]; char name[BUFSIZ]; printf("Enter Username: \n"); fgets(name, BUFSIZ, stdin); printf("Enter Password: \n"); fgets(password,BUFSIZ,stdin); cleaner(name); cleaner(password); */ //temp char password [] = "569dgBAh#6Kv2^e9z^ALFiOq"; char name [] = "Foxi"; //temp hashPassword(password, md5Password); doLogin(name, md5Password, myHandle); sleep(3); getSecretToken(myHandle,&s); sleep(3); char* tokenarray = (char*) malloc((s.len + 3) * sizeof (char)); strcpy(tokenarray, s.ptr); findSecretToken(tokenarray, s.len); //Hier muss die URL hin auf welche Danke gesagt wird! char danke [] = "http://usenet-4all.info/forum/showthread.php?t=637647"; doTanks(danke,&g, myHandle); char* pidarray = (char*) malloc((g.len + 3) * sizeof (char)); strcpy(pidarray, g.ptr); findPid(pidarray, g.len, set); //Ab hier habe ich alle PIDS! pushthanks(tokenarray,danke,set,myHandle); print_cookies(myHandle); curl_easy_cleanup(myHandle); free(s.ptr); free(tokenarray); free(pidarray); free(g.ptr); return 0; }