Esempio n. 1
0
int
main (void)
{
  struct corpus *c;
  struct vocab *v;

  size_t i;
  size_t j;
  size_t k;

  v = vocab_new ();
  assert (v != NULL);
  assert (vocab_add (v, "cat") == 0);
  assert (vocab_add (v, "dog") == 0);
  assert (vocab_add (v, "frog") == 0);
  assert (vocab_add (v, "mouse") == 0);

  c = corpus_new (v);
  assert (c != NULL);
  assert (corpus_parse (c, "tests/testdata/corpus.txt") == 0);
  assert (memcmp (c->words.ptr, words, c->words.len * sizeof (size_t)) == 0);
  corpus_clear (c);
  // Stress test to trigger a memory rebuild.
  for (i = 0; i < 2000; i++)
    assert (corpus_parse (c, "tests/testdata/corpus.txt") == 0);
  // Make sure everything is linked correctly.
  for (i = j = 0; i < c->sentences.len; i++) {
    assert (c->sentences.ptr[i]->len == c->words.ptr[j++]);
    for (k = 0; k < c->sentences.ptr[i]->len; k++)
      assert (c->sentences.ptr[i]->words[k] == c->words.ptr[j++]);
  }
  corpus_free (c);
  vocab_free (v);
  return EXIT_SUCCESS;
}
Esempio n. 2
0
static void corpus_new__roomsAndSeats__self(void ** state){

corpus_t * self = NULL;
int number = 4;
int mas[4]  = { 1 , 2 , 3 , 4};
self  = corpus_new(number , mas);
 assert_non_null(self);
 corpus_free(self);
}
Esempio n. 3
0
static void room_empty_seats__self__NoemptySeats(void ** state){

int number =  2;
int mas[2] = {1,2};
corpus_t * corpus = corpus_new(number , mas);
room_t * room =  return_room( corpus,  5);
assert_null(room);// повертає нал
corpus_free(corpus);
}
Esempio n. 4
0
static void room_empty_seats__self__emptySeats(void ** state){

int number =  2;
int mas[2] = {1,2};
corpus_t * corpus = corpus_new(number , mas);
room_t * room =  return_room( corpus,  1);
assert_int_equal(room_empty_seats(room) , 2);
corpus_free(corpus);
}
Esempio n. 5
0
static void corpus_Room_count__self__roomCount(void ** state){

int number =  2;
int mas[2] = {1,2};
corpus_t * corpus  = NULL;
corpus = corpus_new(number , mas);
assert_int_equal(corpus_roomCount(corpus) , 2);
corpus_free(corpus);

}
Esempio n. 6
0
static void room_busy__self__0OR1( void ** state){

corpus_t * corpus = NULL;
int number =  2;
int mas[2] = {1,2};
corpus = corpus_new(number , mas);
room_t * self = NULL;
self = return_room( corpus , 1);
assert_int_equal(room_busy(self ) , 0);
assert_int_equal(room_take(self ,1),  0);
assert_int_equal(room_busy(self),  1);
clock_t time = clock();
while(clock() < time + CLOCKS_PER_SEC);
assert_int_equal(room_busy(self) , 0);
corpus_free(corpus);
}
Esempio n. 7
0
static void
train (void)
{
  struct corpus *c;
  char *arg;

  if (b->model == NULL)
    fatal ("model missing");
  c = corpus_new (b->vocab);
  if (c == NULL)
    fatal ("corpus_new");

  while (arg = program_poparg (), arg != NULL) {
    if (corpus_parse (c, arg) != 0)
      fatal ("corpus_parse");
    if (model_train (b->model, c) != 0)
      fatal ("model_train");
    corpus_clear (c);
  }
  corpus_free (c);
}