Exemplo n.º 1
0
void test_repeat_word(void){
  char buff[MAX_OUT_BUFF] = "";
  char *words[] = {"a", "a", "a", "a", "a"};
  struct yaml_stringaab * ys = create_yamlaab();

  print_test_infoaab(ys, "test_repeat_word", "a a a a a", "a 5", "20");

  clear_hashtab();
  count_words(words, sizeof(words)/sizeof(char*));

  qsort(hashtab, HASH_TAB, sizeof(struct hashrec), cmp);
  print_hashtab(buff, MAX_OUT_BUFF);
  print_test_outputaab(ys, buff); 
}
Exemplo n.º 2
0
void test_zero_words(void){
  char buff[MAX_OUT_BUFF] = "";
  char *words[] = {NULL};
  struct yaml_stringaab * ys = create_yamlaab();

  print_test_infoaab(ys, "test_zero_words", "", "", "20");

  clear_hashtab();
  count_words(words, 0);

  qsort(hashtab, HASH_TAB, sizeof(struct hashrec), cmp);
  print_hashtab(buff, MAX_OUT_BUFF);
  print_test_outputaab(ys, buff); 
}
int main()
{
	char* h  =(char*) malloc(NUM_TOTAL_CONSTRAINT*SIZE_CONSTRAINT);
	bzero(h,NUM_TOTAL_CONSTRAINT*SIZE_CONSTRAINT);
	hash_tab* ht = init_hashtab(4,2,h);
 	put_element(ht,0,strdup("_Ad b   ")); 
	put_element(ht,0,strdup("_lc a c "));
	put_element(ht,1,strdup("_v1     "));

	print_hashtab(ht); 

	char* out=(char*) malloc(NUM_TOTAL_CONSTRAINT*SIZE_CONSTRAINT);
	bzero(out,NUM_TOTAL_CONSTRAINT*SIZE_CONSTRAINT);
	solver_constraint_wrapper(ht,out);
}
Exemplo n.º 4
0
void test_unique_words(void){
  char buff[MAX_OUT_BUFF] = "";
  char *words[] = {"cat", "sat", "on", "the", "mat"};
  struct yaml_stringaab * ys = create_yamlaab();

  print_test_infoaab(ys, "test_unique_words", 
                      "cat sat on the mat", 
                      "cat 1\nmat 1\non 1\nsat 1\nthe 1", 
                      "20");

  clear_hashtab();
  count_words(words, sizeof(words)/sizeof(char*));

  qsort(hashtab, HASH_TAB, sizeof(struct hashrec), cmp);
  print_hashtab(buff, MAX_OUT_BUFF);
  print_test_outputaab(ys, buff); 
}