Пример #1
0
void
run_client_and_mock_servers_loops_expect_ok(CuTest *tc, test_baton_t *tb,
                                            int num_requests,
                                            handler_baton_t handler_ctx[],
                                            apr_pool_t *pool)
{
    apr_status_t status;

    status = run_client_and_mock_servers_loops(tb, num_requests, handler_ctx,
                                               pool);
    CuAssertIntEquals(tc, APR_SUCCESS, status);

    /* Check that the requests were sent and reveived by the server in the order
     we created them */
    Verify(tb->mh)
      CuAssert(tc, ErrorMessage, VerifyAllRequestsReceivedInOrder);
    EndVerify

    CuAssertIntEquals(tc, num_requests, tb->sent_requests->nelts);
    CuAssertIntEquals(tc, num_requests, tb->accepted_requests->nelts);
    CuAssertIntEquals(tc, num_requests, tb->handled_requests->nelts);
}
Пример #2
0
void Testbst_tree_insert(CuTest *tc)
  {
    test_bst_tree_t *root;
    test_bst_tree_t *elem;
    bool ret;

    root = NULL;
    elem = NULL;
    ret = _bst_tree_insert(NULL, elem, 0, BTREE_COMPARE);
    CuAssertTrue(tc, !ret);
    ret = bst_tree_insert(root, NULL, btree, BTREE_COMPARE);
//    ret = _bst_tree_insert(&(root),
//            (NULL),
//             (unsigned int)offsetof(typeof(*(root)), btree),
//             BTREE_COMPARE);
    CuAssertTrue(tc, !ret);
    ret = bst_tree_insert(root, elem, btree, NULL);
    CuAssertTrue(tc, !ret);
    elem = malloc(sizeof(*elem));
    elem->key = 2;
    ret = bst_tree_insert(root, elem, btree, BTREE_COMPARE);
    CuAssertTrue(tc, ret);
    elem = malloc(sizeof(*elem));
    elem->key = 1;
    ret = bst_tree_insert(root, elem, btree, BTREE_COMPARE);
    CuAssertTrue(tc, ret);
    elem = malloc(sizeof(*elem));
    elem->key = 1;
    ret = bst_tree_insert(root, elem, btree, BTREE_COMPARE);
    CuAssertTrue(tc, !ret);
    elem = malloc(sizeof(*elem));
    elem->key = 3;
    ret = bst_tree_insert(root, elem, btree, BTREE_COMPARE);
    CuAssertTrue(tc, ret);
    elem = root;
    CuAssertIntEquals(tc, 2, elem->key);
    CuAssertIntEquals(tc, 1, ((test_bst_tree_t *)elem->btree.left)->key);
    CuAssertIntEquals(tc, 3, ((test_bst_tree_t *)elem->btree.right)->key);
  }
Пример #3
0
void gc_test_forward(CuTest *T) {
  PN_SIZE count;
  char *fj = "frances johnson.";
  PN ptr = potion_data_alloc(P, 16);
  register unsigned long old = ptr & 0xFFFF;
  memcpy(((struct PNData *)ptr)->data, fj, 16);

  count = potion_mark_stack(P, 1);
  CuAssert(T, "copied location identical to original", (old & 0xFFFF) != ptr);
  CuAssertIntEquals(T, "copied object not still PN_TUSER", ((struct PNData *)ptr)->vt, PN_TUSER);
  CuAssert(T, "copied data not identical to original",
    strncmp(((struct PNData *)ptr)->data, fj, 16) == 0);
}
Пример #4
0
void test_upkeep_free(CuTest * tc)
{
    region *r;
    unit *u;
    const item_type *i_silver;

    test_cleanup();
    test_create_world();

    i_silver = it_find("money");
    assert(i_silver);
    r = findregion(0, 0);
    u = test_create_unit(test_create_faction(test_create_race("human")), r);
    assert(r && u);

    set_param(&global.parameters, "rules.food.flags", "4"); // FOOD_IS_FREE
    get_food(r);
    CuAssertIntEquals(tc, 0, i_get(u->items, i_silver));
    CuAssertIntEquals(tc, 0, fval(u, UFL_HUNGER));

    test_cleanup();
}
Пример #5
0
void test_cil_lexer_setup(CuTest *tc) {
   char *test_str = "(test \"qstring\");comment\n";
   uint32_t str_size = strlen(test_str);
   char *buffer = malloc(str_size + 2);

   memset(buffer+str_size, 0, 2);
   strncpy(buffer, test_str, str_size);

   int rc = cil_lexer_setup(buffer, str_size + 2);
   CuAssertIntEquals(tc, SEPOL_OK, rc);

   free(buffer);
}
Пример #6
0
void test_very_nasty(CuTest* tc) {
	initial_max_groups = 1;
	int test_data[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
	                   1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	                   1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0,
	                   1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1,
	                   1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1,
	                   0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1,
	                   1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0,
	                   0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0,
	                   0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0};
	CuAssertIntEquals(tc, compare_inputs(test_data, 11, 9),0);
}
Пример #7
0
void Test_matrix_from_items_example1(CuTest *tc) {
    // This example contains both items from which more than limit fit into a bin
    // and items from which only less than limit fit into a bin.
    
    double items[] = {
        0.5,
        0.33,
        0.25
    };
    
    uint_matrix *A = matrix_from_items(items, 3, 3);
    
    CuAssertIntEquals(tc, 7, A->height);
    
    {
        unsigned int combination[] = {0, 0, 3};
        CuAssertTrue(tc, matrix_contains_exact_row(A, combination));
    }
    
    {
        unsigned int combination[] = {0, 1, 2};
        CuAssertTrue(tc, matrix_contains_exact_row(A, combination));
    }
    
    {
        unsigned int combination[] = {0, 2, 1};
        CuAssertTrue(tc, matrix_contains_exact_row(A, combination));
    }
    
    {
        unsigned int combination[] = {0, 3, 0};
        CuAssertTrue(tc, matrix_contains_exact_row(A, combination));
    }
    
    {
        unsigned int combination[] = {1, 0, 2};
        CuAssertTrue(tc, matrix_contains_exact_row(A, combination));
    }
    
    {
        unsigned int combination[] = {1, 1, 0};
        CuAssertTrue(tc, matrix_contains_exact_row(A, combination));
    }
    
    {
        unsigned int combination[] = {2, 0, 0};
        CuAssertTrue(tc, matrix_contains_exact_row(A, combination));
    }
    
    free_uint_matrix(A);
}
Пример #8
0
void test_tokenize(CuTest *tc) {
	char *file1 = "float bmi = weight/height;";
	char *file2 = "float pi = 3.14159265;";
	char *file3 = "print \"Hello World!\";\nfoo();\n";
	char *file4 = "print \"\\\"Hello World!\\\"\";\nint i = 0;\n\nbar(i++);\\";

	char *file1_expected[7] = {"float", "bmi", "=", "weight", "/", "height", ";"};
	char *file2_expected[5] = {"float", "pi", "=", "3.14159265", ";"};
	char *file3_expected[7] = {"print", "\"Hello World!\"", ";", "foo", "(", ")", ";"};
	char *file4_expected[15] = {"print", "\"\\\"Hello World!\\\"\"", ";", "int", "i", "=",\
					 "0", ";", "bar", "(", "i", "++", ")", ";", "\\" };

	token_t *head = NULL;

	CuAssertIntEquals(tc, 0, tokenize(file1, strlen(file1), &head));
	
	check_tokens(tc, head,  file1_expected, 7);
	free_tokens(head);
	head = NULL;

	CuAssertIntEquals(tc, 0, tokenize(file2, strlen(file2), &head));

	check_tokens(tc, head,  file2_expected, 5);
	free_tokens(head);
	head = NULL;

	CuAssertIntEquals(tc, 0, tokenize(file3, strlen(file3), &head));

	check_tokens(tc, head, file3_expected, 7);
	free_tokens(head);
	head = NULL;

	CuAssertIntEquals(tc, 0, tokenize(file4, strlen(file4), &head));

	check_tokens(tc, head, file4_expected, 15);
	free_tokens(head);
	head = NULL;
}
Пример #9
0
void test_named_spellbooks(CuTest * tc)
{
    spell *sp;
    spellbook *sb;
    spellbook_entry *sbe;
    int counter = 0;

    sb = create_spellbook(0);
    CuAssertPtrNotNull(tc, sb);
    CuAssertPtrEquals(tc, NULL, sb->name);
    spellbook_clear(sb);
    free(sb);

    sb = create_spellbook("spells");
    CuAssertPtrNotNull(tc, sb);
    CuAssertStrEquals(tc, "spells", sb->name);

    sp = create_spell("testspell");
    spellbook_add(sb, sp, 1);
    CuAssertPtrNotNull(tc, sb->spells);

    sbe = spellbook_get(sb, sp);
    CuAssertPtrNotNull(tc, sbe);
    CuAssertIntEquals(tc, 1, sbe->level);
    CuAssertPtrEquals(tc, sp, spellref_get(&sbe->spref));

    spellbook_foreach(sb, count_spell_cb, &counter);
    CuAssertIntEquals(tc, 1, counter);

#ifdef TODO
    /* try adding the same spell twice. that should fail */
    spellbook_add(sb, sp, 1);
    spellbook_foreach(sb, count_spell_cb, &counter);
    CuAssertIntEquals(tc, 1, counter);
#endif
    spellbook_clear(sb);
    free(sb);
}
Пример #10
0
static void test_get_direction_default(CuTest *tc) {
    struct locale *lang;
    test_cleanup();
    lang = get_or_create_locale("en");
    CuAssertIntEquals(tc, NODIRECTION, get_direction("potato", lang));
    CuAssertIntEquals(tc, D_SOUTHWEST, get_direction("southwest", lang));
    CuAssertIntEquals(tc, D_SOUTHEAST, get_direction("southeast", lang));
    CuAssertIntEquals(tc, D_NORTHWEST, get_direction("northwest", lang));
    CuAssertIntEquals(tc, D_NORTHEAST, get_direction("northeast", lang));
    CuAssertIntEquals(tc, D_WEST, get_direction("west", lang));
    CuAssertIntEquals(tc, D_EAST, get_direction("east", lang));
}
Пример #11
0
static void
check_term_docs(CuTest* tc,
                lcn_index_reader_t *index_reader,
                apr_pool_t *pool )
{
    {
        apr_pool_t *td_pool;
        lcn_term_docs_t *term_docs;
        lcn_term_t *term;
        apr_status_t next_status = APR_SUCCESS;
        unsigned int i = 0;

        LCN_TEST( apr_pool_create( &td_pool, pool ));
        LCN_TEST( lcn_term_create( &term, "text", "a", LCN_TERM_TEXT_COPY, td_pool ));
        LCN_TEST( lcn_index_reader_term_docs_from( index_reader, &term_docs, term, td_pool ));

        while(APR_SUCCESS == next_status)
        {
            next_status = lcn_term_docs_next( term_docs );

            if ( APR_SUCCESS != next_status )
            {
                break;
            }

            CuAssertIntEquals(tc, doc_freqs[i][0], lcn_term_docs_doc( term_docs ) );
            CuAssertIntEquals(tc, doc_freqs[i][1], lcn_term_docs_freq( term_docs ) );

            i++;
        }

        CuAssertIntEquals(tc, 47, i );

        LCN_TEST( lcn_term_docs_close( term_docs ));

        apr_pool_destroy( td_pool );
    }
}
Пример #12
0
void test_sl_split_2(CuTest* tc) {
    int i;
    sl* s = sl_split(NULL, "hello  world  this  is  a  test     ", "  ");
    CuAssertPtrNotNull(tc, s);
    printf("got: ");
    for (i=0; i<sl_size(s); i++)
        printf("/%s/ ", sl_get(s, i));
    printf("\n");
    CuAssertIntEquals(tc, 8, sl_size(s));
    CuAssertIntEquals(tc, 0, strcmp(sl_get(s, 0), "hello"));
    CuAssertIntEquals(tc, 0, strcmp(sl_get(s, 1), "world"));
    CuAssertIntEquals(tc, 0, strcmp(sl_get(s, 2), "this"));
    CuAssertIntEquals(tc, 0, strcmp(sl_get(s, 3), "is"));
    CuAssertIntEquals(tc, 0, strcmp(sl_get(s, 4), "a"));
    CuAssertIntEquals(tc, 0, strcmp(sl_get(s, 5), "test"));
    CuAssertIntEquals(tc, 0, strcmp(sl_get(s, 6), ""));
    CuAssertIntEquals(tc, 0, strcmp(sl_get(s, 7), " "));
    sl_free2(s);
}
Пример #13
0
void Test__cstring_free(CuTest* tc)
{
  CSTRING* a=NULL;
  CSTRING* b=NULL;
  CSTRING  c;
  int error = 0;

  // pass a null to the 'free' function
  cstring_free(NULL);
  error = errno;
  errno = 0;
  CuAssertIntEquals(tc, EFAULT, error);

  // send non-alloc'd - passing static non-alloc address
  a = cstring_import("ABCDE", 5);
  c = cstring_strchr(a, 'C');
  b=&c;
  cstring_free(&b);
  error = errno;
  errno = 0;
  CuAssertIntEquals(tc, EFAULT, error);
  cstring_free(&a);

  // passing argument returned from cstring_import
  a = cstring_import("ABCDE", 5);
  cstring_free(&a);

  // check that the structure is null'd
  CuAssertPtrEquals(tc, NULL, a);

  // trying to double free an imported cstring
  a = cstring_import("abcde", 5);
  cstring_free(&a);
  cstring_free(&a);
  error = errno;
  errno = 0;
  CuAssertIntEquals(tc, EFAULT, error);
}
Пример #14
0
void test_sl_split_1(CuTest* tc) {
    sl* s = sl_split(NULL, "hello world this is a test", " ");
    CuAssertPtrNotNull(tc, s);
    CuAssertIntEquals(tc, 6, sl_size(s));
    CuAssertIntEquals(tc, 0, strcmp(sl_get(s, 0), "hello"));
    CuAssertIntEquals(tc, 0, strcmp(sl_get(s, 1), "world"));
    CuAssertIntEquals(tc, 0, strcmp(sl_get(s, 2), "this"));
    CuAssertIntEquals(tc, 0, strcmp(sl_get(s, 3), "is"));
    CuAssertIntEquals(tc, 0, strcmp(sl_get(s, 4), "a"));
    CuAssertIntEquals(tc, 0, strcmp(sl_get(s, 5), "test"));
    sl_free2(s);
}
Пример #15
0
static void test_otherfaction(CuTest *tc) {
    unit *u;
    faction *f;

    test_setup();
    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
    f = test_create_faction(NULL);
    config_set("stealth.faction.other", "1");
    CuAssertIntEquals(tc, true, rule_stealth_other());
    CuAssertPtrEquals(tc, u->faction, visible_faction(f, u));
    a_add(&u->attribs, make_otherfaction(f));
    CuAssertPtrEquals(tc, f, visible_faction(f, u));
    test_teardown();
}
Пример #16
0
static void test_memstream(CuTest *tc) {
    storage store;
    stream out = { 0 };
    char buf[1024];
    int val=0;

    mstream_init(&out);
    binstore_init(&store, &out);
    store.handle.data = &out;

    WRITE_INT(&store, 999999);
    WRITE_TOK(&store, "fortytwo");
    WRITE_INT(&store, 42);

    out.api->rewind(out.handle);
    READ_INT(&store, &val);
    READ_TOK(&store, buf, 1024);
    CuAssertIntEquals(tc, 999999, val);
    CuAssertStrEquals(tc, "fortytwo", buf);
    READ_INT(&store, &val);
    CuAssertIntEquals(tc, 42, val);
    mstream_done(&out);
}
void Test_serialize_int(CuTest * tc){

    printf("Int serialization tests and experiments \n");
    printf("maximum int = %d\n",INT_MAX);
    printf("size of int in bytes= %zu\n",sizeof(int));
    int a = 18505;
    int value;
    unsigned char buffer[sizeof(int)];

    serialize_int(buffer,a);
    printf(" serialized is %s\n",buffer);
    deserialize_int(buffer,&value);
    printf(" deserialized is %d\n",value);
    CuAssertIntEquals(tc,value,a);
    a = INT_MAX;
    serialize_int(buffer,a);
    deserialize_int(buffer,&value);
    CuAssertIntEquals(tc,value,a);
    a = INT_MIN;
    serialize_int(buffer,a);
    deserialize_int(buffer,&value);
    CuAssertIntEquals(tc,value,a);
}
Пример #18
0
static void clear_all_signalled(CuTest *tc)
{
    apr_status_t rv;
    int srv = SMALL_NUM_SOCKETS;

    recv_msg(s, 0, p, tc);
    recv_msg(s, 2, p, tc);

    rv = apr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC);
    CuAssertIntEquals(tc, 1, APR_STATUS_IS_TIMEUP(rv));
    check_sockets(pollarray, s, 0, 0, tc);
    check_sockets(pollarray, s, 1, 0, tc);
    check_sockets(pollarray, s, 2, 0, tc);
}
Пример #19
0
static void recv_1_send_0(CuTest *tc)
{
    apr_status_t rv;
    int srv = SMALL_NUM_SOCKETS;

    recv_msg(s, 1, p, tc);
    send_msg(s, sa, 0, tc);

    rv = apr_poll(pollarray, SMALL_NUM_SOCKETS, &srv, 2 * APR_USEC_PER_SEC);
    CuAssertIntEquals(tc, APR_SUCCESS, rv);
    check_sockets(pollarray, s, 0, 1, tc);
    check_sockets(pollarray, s, 1, 0, tc);
    check_sockets(pollarray, s, 2, 1, tc);
}
Пример #20
0
void test_user_get_record_returns_requested_user(CuTest *tc)
{
    struct user_record *rec;

    setup();
    rec = user_get_record("tom");
    CuAssertIntEquals(tc, 2, rec->uid);
    CuAssertStrEquals(tc, "tom", rec->login);
    CuAssertStrEquals(tc, "$1$3$def", rec->password);
    CuAssertStrEquals(tc, "Tom Jones", rec->name);
    CuAssertStrEquals(tc, "*****@*****.**", rec->email);

    teardown();
}
Пример #21
0
static void test_normals_recruit(CuTest * tc) {
    unit *u;

    test_cleanup();

    u = create_recruiter();
    unit_addorder(u, create_order(K_RECRUIT, default_locale, "1"));

    economics(u->region);

    CuAssertIntEquals(tc, 2, u->number);

    test_cleanup();
}
Пример #22
0
/*=====================================================================================
 * RFC 2606 madates that the first level domains .test, .example, .invalid and 
 * .localhost can not be registered.  It has become common practice for servers
 * to use .localhost to reference themselves, therefore for testing handling of
 * invalid domains this test code uses the domain ".invalid"
 * ====================================================================================
 */
void
test_uri_resolve_3(CuTest *tc)
{
	char *href = strdup("http://invalid/");
	uriobj_t *uri = uri_alloc();
	int err = 0;
    uri_parse(&uri,re,href);
	uri_parse_auth(&uri);
	err = uri_resolve(&uri);
    printf("err    = '%d'\n", err); 
    printf("errstr = '%s'\n",gai_strerror(err));
    CuAssertIntEquals(tc, err, EAI_NONAME);
    uri_free(uri);
}
Пример #23
0
void test_message(CuTest *tc) {
    message *msg;
    message_type *mtype;

    test_setup();
    mtype = mt_create(mt_new("custom", NULL), NULL, 0);
    CuAssertPtrEquals(tc, mtype, (void *)mt_find("custom"));
    CuAssertIntEquals(tc, 0, mtype->nparameters);
    CuAssertPtrEquals(tc, NULL, (void *)mtype->pnames);
    CuAssertPtrEquals(tc, NULL, (void *)mtype->types);
    msg = msg_message("custom", "");
    CuAssertPtrNotNull(tc, msg);
    CuAssertIntEquals(tc, 1, msg->refcount);
    CuAssertPtrEquals(tc, NULL, msg->parameters);
    CuAssertPtrEquals(tc, mtype, (void *)msg->type);

    CuAssertPtrEquals(tc, msg, msg_addref(msg));
    CuAssertIntEquals(tc, 2, msg->refcount);
    msg_release(msg);
    CuAssertIntEquals(tc, 1, msg->refcount);
    msg_release(msg);
    test_teardown();
}
Пример #24
0
static void testDefineUndefine(CuTest *tc) {
    char *bridge_xml = NULL;
    struct netcf_if *nif = NULL;
    int r;

    bridge_xml = read_test_file(tc, "interface/bridge42.xml");
    CuAssertPtrNotNull(tc, bridge_xml);

    nif = ncf_define(ncf, bridge_xml);
    CuAssertPtrNotNull(tc, nif);
    assert_ncf_no_error(tc);

    r = ncf_if_undefine(nif);
    CuAssertIntEquals(tc, 0, r);
    assert_ncf_no_error(tc);

    ncf_close(ncf);
    r = ncf_init(&ncf, root);
    CuAssertIntEquals(tc, 0, r);

    nif = ncf_lookup_by_name(ncf, "br42");
    CuAssertPtrEquals(tc, NULL, nif);
}
Пример #25
0
static void test_loop(CuTest * tc)
{
    ql_iter iter;
    quicklist * ql = 0;
    int result = 0;

    ql_push(&ql, (void *)data);
    ql_push(&ql, (void *)(data + 1));
    for (iter = qli_init(&ql); qli_more(iter);) {
        const char * c = (const char *)qli_next(&iter);
        result += *c;
    }
    CuAssertIntEquals(tc, data[0] + data[1], result);
}
Пример #26
0
static void read_write(CuTest *tc)
{
    apr_status_t rv;
    char *buf;
    apr_size_t nbytes;
    
    nbytes = strlen("this is a test");
    buf = (char *)apr_palloc(p, nbytes + 1);

    rv = apr_file_pipe_create(&readp, &writep, p);
    CuAssertIntEquals(tc, APR_SUCCESS, rv);
    CuAssertPtrNotNull(tc, readp);
    CuAssertPtrNotNull(tc, writep);

    rv = apr_file_pipe_timeout_set(readp, apr_time_from_sec(1));
    CuAssertIntEquals(tc, APR_SUCCESS, rv);

    rv = apr_file_read(readp, buf, &nbytes);
    if (!rv) {
      CuAssertIntEquals(tc, 1, APR_STATUS_IS_TIMEUP(rv));
      CuAssertIntEquals(tc, 0, nbytes);
    }
}
Пример #27
0
static void test_skills(CuTest * tc)
{
    const char * data = "{\"skills\": { \"de\" : { \"alchemy\" : \"ALCHEMIE\", \"crossbow\" : [ \"ARMBRUST\", \"KREUZBOGEN\" ] }}}";
    const struct locale * lang;

    cJSON *json = cJSON_Parse(data);

    test_cleanup();
    lang = get_or_create_locale("de");
    CuAssertPtrNotNull(tc, json);
    CuAssertIntEquals(tc, NOSKILL, get_skill("potato", lang));

    json_config(json);
    CuAssertIntEquals(tc, NOSKILL, get_skill("potato", lang));
    CuAssertIntEquals(tc, SK_CROSSBOW, get_skill("armbrust", lang));
    CuAssertIntEquals(tc, SK_CROSSBOW, get_skill("kreuz", lang));
    CuAssertIntEquals(tc, SK_ALCHEMY, get_skill("alchemie", lang));

    CuAssertStrEquals(tc, "ALCHEMIE", locale_string(lang, "skill::alchemy"));
    CuAssertStrEquals(tc, "ARMBRUST", locale_string(lang, "skill::crossbow"));

    test_cleanup();
}
Пример #28
0
static void
test_index_searcher( CuTest* tc )
{
    apr_pool_t* pool;
    lcn_searcher_t* searcher;
    unsigned int doc_freq;
    lcn_term_t* term;

    apr_pool_create( &pool, main_pool );

    LCN_TEST( lcn_term_create( &term, "text", "a", 1, pool ) );
    LCN_TEST( lcn_index_searcher_create_by_path( &searcher,
                                                 test_index_name,
                                                 pool ) );

    CuAssertIntEquals( tc, 331,  lcn_searcher_max_doc( searcher ) );

    LCN_TEST( lcn_searcher_doc_freq( searcher, term, &doc_freq ) );

    CuAssertIntEquals( tc, 47, doc_freq );

    apr_pool_destroy( pool );
}
Пример #29
0
static void test_open_readwrite(CuTest *tc)
{
    apr_status_t rv;
    apr_file_t *filetest = NULL;

    filetest = NULL;
    rv = apr_file_open(&filetest, FILENAME, 
                       APR_READ | APR_WRITE, 
                       APR_UREAD | APR_UWRITE | APR_GREAD, p);
    CuAssertIntEquals(tc, APR_SUCCESS, rv);
    CuAssertPtrNotNull(tc, filetest);

    apr_file_close(filetest);
}
Пример #30
0
static void testMtime(CuTest *tc) {
    const char *s, *mtime2;
    char *mtime1;
    int r;

    r = aug_set(aug, "/files/etc/hosts/1/alias[last() + 1]", "new");
    CuAssertIntEquals(tc, 0, r);

    r = aug_get(aug, "/augeas/files/etc/hosts/mtime", &s);
    CuAssertIntEquals(tc, 1, r);
    mtime1 = strdup(s);
    CuAssertPtrNotNull(tc, mtime1);


    r = aug_save(aug);
    CuAssertIntEquals(tc, 0, r);

    r = aug_get(aug, "/augeas/files/etc/hosts/mtime", &mtime2);
    CuAssertIntEquals(tc, 1, r);

    CuAssertStrNotEqual(tc, mtime1, mtime2);
    CuAssertStrNotEqual(tc, "0", mtime2);
}