コード例 #1
0
ファイル: TestCharBuf.c プロジェクト: pavansondur/lucy
void
TestCB_run_tests() {
    TestBatch *batch = TestBatch_new(55);
    TestBatch_Plan(batch);

    test_vcatf_s(batch);
    test_vcatf_null_string(batch);
    test_vcatf_cb(batch);
    test_vcatf_obj(batch);
    test_vcatf_null_obj(batch);
    test_vcatf_i8(batch);
    test_vcatf_i32(batch);
    test_vcatf_i64(batch);
    test_vcatf_u8(batch);
    test_vcatf_u32(batch);
    test_vcatf_u64(batch);
    test_vcatf_f64(batch);
    test_vcatf_x32(batch);
    test_Cat(batch);
    test_Mimic_and_Clone(batch);
    test_Code_Point_At_and_From(batch);
    test_Find(batch);
    test_SubString(batch);
    test_Nip_and_Chop(batch);
    test_Truncate(batch);
    test_Trim(batch);
    test_To_F64(batch);
    test_To_I64(batch);
    test_serialization(batch);

    DECREF(batch);
}
コード例 #2
0
ファイル: TestJson.c プロジェクト: pavansondur/lucy
void
TestJson_run_tests() {
    int num_tests = 107;
#ifndef LUCY_VALGRIND
    num_tests += 28; // FIXME: syntax errors leak memory.
#endif
    TestBatch *batch = TestBatch_new(num_tests);
    TestBatch_Plan(batch);

    // Test tolerance, then liberalize for testing.
    test_tolerance(batch);
    Json_set_tolerant(true);

    test_to_and_from(batch);
    test_escapes(batch);
    test_numbers(batch);
    test_spew_and_slurp(batch);
    test_integers(batch);
    test_floats(batch);
    test_max_depth(batch);
    test_illegal_keys(batch);

#ifndef LUCY_VALGRIND
    test_syntax_errors(batch);
#endif

    DECREF(batch);
}
コード例 #3
0
ファイル: TestMatchAllQuery.c プロジェクト: pavansondur/lucy
void
TestMatchAllQuery_run_tests() {
    TestBatch *batch = TestBatch_new(2);
    TestBatch_Plan(batch);
    test_Dump_Load_and_Equals(batch);
    DECREF(batch);
}
コード例 #4
0
ファイル: TestMemoryPool.c プロジェクト: pavansondur/lucy
void
TestMemPool_run_tests() {
    TestBatch  *batch     = TestBatch_new(4);
    MemoryPool *mem_pool  = MemPool_new(0);
    MemoryPool *other     = MemPool_new(0);
    char *ptr_a, *ptr_b;

    TestBatch_Plan(batch);

    ptr_a = (char*)MemPool_Grab(mem_pool, 10);
    strcpy(ptr_a, "foo");
    MemPool_Release_All(mem_pool);

    ptr_b = (char*)MemPool_Grab(mem_pool, 10);
    TEST_STR_EQ(batch, ptr_b, "foo", "Recycle RAM on Release_All");

    ptr_a = mem_pool->buf;
    MemPool_Resize(mem_pool, ptr_b, 6);
    TEST_TRUE(batch, mem_pool->buf < ptr_a, "Resize");

    ptr_a = (char*)MemPool_Grab(other, 20);
    MemPool_Release_All(other);
    MemPool_Eat(other, mem_pool);
    TEST_TRUE(batch, other->buf == mem_pool->buf, "Eat");
    TEST_TRUE(batch, other->buf != NULL, "Eat");

    DECREF(mem_pool);
    DECREF(other);
    DECREF(batch);
}
コード例 #5
0
ファイル: TestSeriesMatcher.c プロジェクト: pavansondur/lucy
void
TestSeriesMatcher_run_tests() {
    TestBatch *batch = TestBatch_new(135);
    TestBatch_Plan(batch);
    test_matrix(batch);
    DECREF(batch);
}
コード例 #6
0
ファイル: TestReqOptQuery.c プロジェクト: gitpan/KinoSearch
void
TestReqOptQuery_run_tests()
{
    TestBatch *batch = TestBatch_new(4);
    TestBatch_Plan(batch);
    test_Dump_Load_and_Equals(batch);
    DECREF(batch);
}
コード例 #7
0
ファイル: TestTermInfo.c プロジェクト: pavansondur/lucy
void
TestTermInfo_run_tests() {
    TestBatch *batch = TestBatch_new(11);
    TestBatch_Plan(batch);
    test_freqfilepos(batch);

    DECREF(batch);
}
コード例 #8
0
ファイル: TestFSDirHandle.c プロジェクト: pavansondur/lucy
void
TestFSDH_run_tests() {
    TestBatch *batch = TestBatch_new(5);

    TestBatch_Plan(batch);
    test_all(batch);

    DECREF(batch);
}
コード例 #9
0
ファイル: TestAtomic.c プロジェクト: pavansondur/lucy
void
TestAtomic_run_tests() {
    TestBatch *batch = TestBatch_new(6);

    TestBatch_Plan(batch);

    test_cas_ptr(batch);

    DECREF(batch);
}
コード例 #10
0
ファイル: TestStemmer.c プロジェクト: gitpan/KinoSearch
void
TestStemmer_run_tests()
{
    TestBatch *batch = TestBatch_new(3);

    TestBatch_Plan(batch);

    test_Dump_Load_and_Equals(batch);

    DECREF(batch);
}
コード例 #11
0
void
TestQPSyntax_run_tests(Folder *index)
{
    uint32_t i;
    TestBatch     *batch      = TestBatch_new(58);
    IndexSearcher *searcher   = IxSearcher_new((Obj*)index);
    QueryParser   *qparser    = QParser_new(IxSearcher_Get_Schema(searcher), 
        NULL, NULL, NULL);
    QParser_Set_Heed_Colons(qparser, true);

    TestBatch_Plan(batch);

    for (i = 0; leaf_test_funcs[i] != NULL; i++) {
        kino_TestQPSyntax_test_t test_func = leaf_test_funcs[i];
        TestQueryParser *test_case = test_func();
        Query *tree     = QParser_Tree(qparser, test_case->query_string);
        Query *expanded = QParser_Expand_Leaf(qparser, test_case->tree);
        Query *parsed   = QParser_Parse(qparser, test_case->query_string);
        Hits  *hits     = IxSearcher_Hits(searcher, (Obj*)parsed, 0, 10, NULL);

        TEST_TRUE(batch, Query_Equals(tree, (Obj*)test_case->tree),
            "tree()    %s", (char*)CB_Get_Ptr8(test_case->query_string));
        TEST_TRUE(batch, Query_Equals(expanded, (Obj*)test_case->expanded),
            "expand_leaf()    %s", (char*)CB_Get_Ptr8(test_case->query_string));
        TEST_INT_EQ(batch, Hits_Total_Hits(hits), test_case->num_hits,
            "hits:    %s", (char*)CB_Get_Ptr8(test_case->query_string));
        DECREF(hits);
        DECREF(parsed);
        DECREF(expanded);
        DECREF(tree);
        DECREF(test_case);
    }

    for (i = 0; syntax_test_funcs[i] != NULL; i++) {
        kino_TestQPSyntax_test_t test_func = syntax_test_funcs[i];
        TestQueryParser *test_case = test_func();
        Query *tree   = QParser_Tree(qparser, test_case->query_string);
        Query *parsed = QParser_Parse(qparser, test_case->query_string);
        Hits  *hits   = IxSearcher_Hits(searcher, (Obj*)parsed, 0, 10, NULL);

        TEST_TRUE(batch, Query_Equals(tree, (Obj*)test_case->tree),
            "tree()    %s", (char*)CB_Get_Ptr8(test_case->query_string));
        TEST_INT_EQ(batch, Hits_Total_Hits(hits), test_case->num_hits,
            "hits:    %s", (char*)CB_Get_Ptr8(test_case->query_string));
        DECREF(hits);
        DECREF(parsed);
        DECREF(tree);
        DECREF(test_case);
    }

    DECREF(batch);
    DECREF(searcher);
    DECREF(qparser);
}
コード例 #12
0
ファイル: TestNum.c プロジェクト: pavansondur/lucy
void
TestNum_run_tests() {
    TestBatch *batch = TestBatch_new(53);
    TestBatch_Plan(batch);

    test_To_String(batch);
    test_accessors(batch);
    test_Equals_and_Compare_To(batch);
    test_Clone(batch);
    test_Mimic(batch);

    DECREF(batch);
}
コード例 #13
0
ファイル: TestSegment.c プロジェクト: gitpan/KinoSearch
void
TestSeg_run_tests()
{
    TestBatch *batch = TestBatch_new(21);

    TestBatch_Plan(batch);
    test_fields(batch);
    test_metadata_storage(batch);
    test_seg_name_and_num(batch);
    test_count(batch);
    test_Compare_To(batch);
    test_Write_File_and_Read_File(batch);

    DECREF(batch);
}
コード例 #14
0
ファイル: TestHash.c プロジェクト: pavansondur/lucy
void
TestHash_run_tests() {
    TestBatch *batch = TestBatch_new(28);

    srand((unsigned int)time((time_t*)NULL));

    TestBatch_Plan(batch);
    test_Equals(batch);
    test_Store_and_Fetch(batch);
    test_Keys_Values_Iter(batch);
    test_Dump_and_Load(batch);
    test_stress(batch);

    DECREF(batch);
}
コード例 #15
0
ファイル: TestObj.c プロジェクト: pavansondur/lucy
void
TestObj_run_tests() {
    TestBatch *batch = TestBatch_new(20);

    TestBatch_Plan(batch);

    test_refcounts(batch);
    test_To_String(batch);
    test_Dump(batch);
    test_Equals(batch);
    test_Hash_Sum(batch);
    test_Is_A(batch);
    test_abstract_routines(batch);

    DECREF(batch);
}
コード例 #16
0
ファイル: TestNumberUtils.c プロジェクト: pavansondur/lucy
void
TestNumUtil_run_tests() {
    TestBatch *batch = TestBatch_new(1196);

    TestBatch_Plan(batch);
    srand((unsigned int)time((time_t*)NULL));

    test_u1(batch);
    test_u2(batch);
    test_u4(batch);
    test_c32(batch);
    test_c64(batch);
    test_bigend_u16(batch);
    test_bigend_u32(batch);
    test_bigend_u64(batch);
    test_bigend_f32(batch);
    test_bigend_f64(batch);

    DECREF(batch);
}
コード例 #17
0
ファイル: TestFolder.c プロジェクト: gitpan/KinoSearch
void
TestFolder_run_tests()
{
    TestBatch *batch = TestBatch_new(79);

    TestBatch_Plan(batch);
    test_Exists(batch);
    test_Set_Path_and_Get_Path(batch);
    test_MkDir_and_Is_Directory(batch);
    test_Enclosing_Folder_and_Find_Folder(batch);
    test_List(batch);
    test_Open_Dir(batch);
    test_Open_FileHandle(batch);
    test_Open_Out(batch);
    test_Open_In(batch);
    test_Delete(batch);
    test_Delete_Tree(batch);
    test_Slurp_File(batch);

    DECREF(batch);
}
コード例 #18
0
ファイル: TestBitVector.c プロジェクト: pavansondur/lucy
void
TestBitVector_run_tests() {
    TestBatch *batch = TestBatch_new(1029);

    TestBatch_Plan(batch);
    test_Set_and_Get(batch);
    test_Flip(batch);
    test_Flip_Block_ascending(batch);
    test_Flip_Block_descending(batch);
    test_Flip_Block_bulk(batch);
    test_Mimic(batch);
    test_Or(batch);
    test_Xor(batch);
    test_And(batch);
    test_And_Not(batch);
    test_Count(batch);
    test_Next_Hit(batch);
    test_Clear_All(batch);
    test_Clone(batch);
    test_To_Array(batch);
    test_off_by_one_error();

    DECREF(batch);
}
コード例 #19
0
void
TestQPLogic_run_tests() {
    uint32_t i;
    TestBatch     *batch      = TestBatch_new(258);
    Folder        *folder     = S_create_index();
    IndexSearcher *searcher   = IxSearcher_new((Obj*)folder);
    QueryParser   *or_parser  = QParser_new(IxSearcher_Get_Schema(searcher),
                                            NULL, NULL, NULL);
    ZombieCharBuf *AND        = ZCB_WRAP_STR("AND", 3);
    QueryParser   *and_parser = QParser_new(IxSearcher_Get_Schema(searcher),
                                            NULL, (CharBuf*)AND, NULL);
    QParser_Set_Heed_Colons(or_parser, true);
    QParser_Set_Heed_Colons(and_parser, true);

    TestBatch_Plan(batch);

    // Run logical tests with default boolop of OR.
    for (i = 0; logical_test_funcs[i] != NULL; i++) {
        Lucy_TestQPLogic_Logical_Test_t test_func = logical_test_funcs[i];
        TestQueryParser *test_case = test_func(BOOLOP_OR);
        Query *tree     = QParser_Tree(or_parser, test_case->query_string);
        Query *parsed   = QParser_Parse(or_parser, test_case->query_string);
        Hits  *hits     = IxSearcher_Hits(searcher, (Obj*)parsed, 0, 10, NULL);

        TEST_TRUE(batch, Query_Equals(tree, (Obj*)test_case->tree),
                  "tree() OR   %s", (char*)CB_Get_Ptr8(test_case->query_string));
        TEST_INT_EQ(batch, Hits_Total_Hits(hits), test_case->num_hits,
                    "hits: OR   %s", (char*)CB_Get_Ptr8(test_case->query_string));
        DECREF(hits);
        DECREF(parsed);
        DECREF(tree);
        DECREF(test_case);
    }

    // Run logical tests with default boolop of AND.
    for (i = 0; logical_test_funcs[i] != NULL; i++) {
        Lucy_TestQPLogic_Logical_Test_t test_func = logical_test_funcs[i];
        TestQueryParser *test_case = test_func(BOOLOP_AND);
        Query *tree     = QParser_Tree(and_parser, test_case->query_string);
        Query *parsed   = QParser_Parse(and_parser, test_case->query_string);
        Hits  *hits     = IxSearcher_Hits(searcher, (Obj*)parsed, 0, 10, NULL);

        TEST_TRUE(batch, Query_Equals(tree, (Obj*)test_case->tree),
                  "tree() AND   %s", (char*)CB_Get_Ptr8(test_case->query_string));
        TEST_INT_EQ(batch, Hits_Total_Hits(hits), test_case->num_hits,
                    "hits: AND   %s", (char*)CB_Get_Ptr8(test_case->query_string));
        DECREF(hits);
        DECREF(parsed);
        DECREF(tree);
        DECREF(test_case);
    }

    // Run tests for QParser_Prune().
    for (i = 0; prune_test_funcs[i] != NULL; i++) {
        Lucy_TestQPLogic_Prune_Test_t test_func = prune_test_funcs[i];
        TestQueryParser *test_case = test_func();
        CharBuf *qstring = test_case->tree
                           ? Query_To_String(test_case->tree)
                           : CB_new_from_trusted_utf8("(NULL)", 6);
        Query *tree = test_case->tree;
        Query *wanted = test_case->expanded;
        Query *pruned   = QParser_Prune(or_parser, tree);
        Query *expanded;
        Hits  *hits;

        TEST_TRUE(batch, Query_Equals(pruned, (Obj*)wanted),
                  "prune()   %s", (char*)CB_Get_Ptr8(qstring));
        expanded = QParser_Expand(or_parser, pruned);
        hits = IxSearcher_Hits(searcher, (Obj*)expanded, 0, 10, NULL);
        TEST_INT_EQ(batch, Hits_Total_Hits(hits), test_case->num_hits,
                    "hits:    %s", (char*)CB_Get_Ptr8(qstring));

        DECREF(hits);
        DECREF(expanded);
        DECREF(pruned);
        DECREF(qstring);
        DECREF(test_case);
    }

    DECREF(and_parser);
    DECREF(or_parser);
    DECREF(searcher);
    DECREF(folder);
    DECREF(batch);
}