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); }
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); }
void TestMatchAllQuery_run_tests() { TestBatch *batch = TestBatch_new(2); TestBatch_Plan(batch); test_Dump_Load_and_Equals(batch); DECREF(batch); }
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); }
void TestSeriesMatcher_run_tests() { TestBatch *batch = TestBatch_new(135); TestBatch_Plan(batch); test_matrix(batch); DECREF(batch); }
void TestReqOptQuery_run_tests() { TestBatch *batch = TestBatch_new(4); TestBatch_Plan(batch); test_Dump_Load_and_Equals(batch); DECREF(batch); }
void TestTermInfo_run_tests() { TestBatch *batch = TestBatch_new(11); TestBatch_Plan(batch); test_freqfilepos(batch); DECREF(batch); }
void TestFSDH_run_tests() { TestBatch *batch = TestBatch_new(5); TestBatch_Plan(batch); test_all(batch); DECREF(batch); }
void TestAtomic_run_tests() { TestBatch *batch = TestBatch_new(6); TestBatch_Plan(batch); test_cas_ptr(batch); DECREF(batch); }
void TestStemmer_run_tests() { TestBatch *batch = TestBatch_new(3); TestBatch_Plan(batch); test_Dump_Load_and_Equals(batch); DECREF(batch); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }