http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Object/TestBitVector.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Object/TestBitVector.c b/core/Lucy/Test/Object/TestBitVector.c deleted file mode 100644 index 03b3c57..0000000 --- a/core/Lucy/Test/Object/TestBitVector.c +++ /dev/null @@ -1,453 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTBITVECTOR -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" - -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Clownfish/TestHarness/TestUtils.h" -#include "Lucy/Test.h" -#include "Lucy/Test/TestUtils.h" -#include "Lucy/Test/Object/TestBitVector.h" - -#include <stdlib.h> - -TestBitVector* -TestBitVector_new() { - return (TestBitVector*)Class_Make_Obj(TESTBITVECTOR); -} - -static void -test_Set_and_Get(TestBatchRunner *runner) { - const size_t three = 3; - const size_t seventeen = 17; - BitVector *bit_vec = BitVec_new(8); - - BitVec_Set(bit_vec, three); - TEST_TRUE(runner, BitVec_Get_Capacity(bit_vec) < seventeen, - "set below cap"); - BitVec_Set(bit_vec, seventeen); - TEST_TRUE(runner, BitVec_Get_Capacity(bit_vec) > seventeen, - "set above cap causes BitVector to grow"); - - size_t i, max; - for (i = 0, max = BitVec_Get_Capacity(bit_vec); i < max; i++) { - if (i == three || i == seventeen) { - TEST_TRUE(runner, BitVec_Get(bit_vec, i), "set/get %u", (unsigned)i); - } - else { - TEST_FALSE(runner, BitVec_Get(bit_vec, i), "get %u", (unsigned)i); - } - } - TEST_FALSE(runner, BitVec_Get(bit_vec, i), "out of range get"); - - DECREF(bit_vec); -} - -static void -test_Flip(TestBatchRunner *runner) { - BitVector *bit_vec = BitVec_new(0); - - unsigned i; - for (i = 0; i <= 20; i++) { BitVec_Flip(bit_vec, i); } - for (i = 0; i <= 20; i++) { - TEST_TRUE(runner, BitVec_Get(bit_vec, i), "flip on %u", i); - } - TEST_FALSE(runner, BitVec_Get(bit_vec, i), "no flip %u", i); - for (i = 0; i <= 20; i++) { BitVec_Flip(bit_vec, i); } - for (i = 0; i <= 20; i++) { - TEST_FALSE(runner, BitVec_Get(bit_vec, i), "flip off %u", i); - } - TEST_FALSE(runner, BitVec_Get(bit_vec, 21), "still no flip %u", i); - - DECREF(bit_vec); -} - -static void -test_Flip_Block_ascending(TestBatchRunner *runner) { - BitVector *bit_vec = BitVec_new(0); - - for (unsigned i = 0; i <= 20; i++) { - BitVec_Flip_Block(bit_vec, i, 21 - i); - } - - for (unsigned i = 0; i <= 20; i++) { - if (i % 2 == 0) { - TEST_TRUE(runner, BitVec_Get(bit_vec, i), - "Flip_Block ascending %u", i); - } - else { - TEST_FALSE(runner, BitVec_Get(bit_vec, i), - "Flip_Block ascending %u", i); - } - } - - DECREF(bit_vec); -} - -static void -test_Flip_Block_descending(TestBatchRunner *runner) { - BitVector *bit_vec = BitVec_new(0); - - for (int i = 19; i >= 0; i--) { - BitVec_Flip_Block(bit_vec, 1, (size_t)i); - } - - for (unsigned i = 0; i <= 20; i++) { - if (i % 2) { - TEST_TRUE(runner, BitVec_Get(bit_vec, i), - "Flip_Block descending %u", i); - } - else { - TEST_FALSE(runner, BitVec_Get(bit_vec, i), - "Flip_Block descending %u", i); - } - } - - DECREF(bit_vec); -} - -static void -test_Flip_Block_bulk(TestBatchRunner *runner) { - for (unsigned offset = 0; offset <= 17; offset++) { - for (unsigned len = 0; len <= 17; len++) { - int upper = (int)offset + (int)len - 1; - BitVector *bit_vec = BitVec_new(0); - - BitVec_Flip_Block(bit_vec, offset, len); - unsigned i; - for (i = 0; i <= 17; i++) { - if (i >= offset && (int)i <= upper) { - if (!BitVec_Get(bit_vec, i)) { break; } - } - else { - if (BitVec_Get(bit_vec, i)) { break; } - } - } - TEST_UINT_EQ(runner, i, 18, "Flip_Block(%u, %u)", offset, len); - - DECREF(bit_vec); - } - } -} - -static void -test_Mimic(TestBatchRunner *runner) { - for (unsigned foo = 0; foo <= 17; foo++) { - for (unsigned bar = 0; bar <= 17; bar++) { - BitVector *foo_vec = BitVec_new(0); - BitVector *bar_vec = BitVec_new(0); - - BitVec_Set(foo_vec, foo); - BitVec_Set(bar_vec, bar); - BitVec_Mimic(foo_vec, (Obj*)bar_vec); - - unsigned i; - for (i = 0; i <= 17; i++) { - if (BitVec_Get(foo_vec, i) && i != bar) { break; } - } - TEST_UINT_EQ(runner, i, 18, "Mimic(%u, %u)", foo, bar); - - DECREF(foo_vec); - DECREF(bar_vec); - } - } -} - -static BitVector* -S_create_set(int set_num) { - unsigned nums_1[] = { 1, 2, 3, 10, 20, 30, 0 }; - unsigned nums_2[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 0 - }; - unsigned *nums = set_num == 1 ? nums_1 : nums_2; - BitVector *bit_vec = BitVec_new(31); - for (unsigned i = 0; nums[i] != 0; i++) { - BitVec_Set(bit_vec, nums[i]); - } - return bit_vec; -} - -#define OP_OR 1 -#define OP_XOR 2 -#define OP_AND 3 -#define OP_AND_NOT 4 -static unsigned -S_verify_logical_op(BitVector *bit_vec, BitVector *set_1, BitVector *set_2, - int op) { - unsigned i; - - for (i = 0; i < 50; i++) { - bool wanted; - - switch (op) { - case OP_OR: - wanted = BitVec_Get(set_1, i) || BitVec_Get(set_2, i); - break; - case OP_XOR: - wanted = (!BitVec_Get(set_1, i)) != (!BitVec_Get(set_2, i)); - break; - case OP_AND: - wanted = BitVec_Get(set_1, i) && BitVec_Get(set_2, i); - break; - case OP_AND_NOT: - wanted = BitVec_Get(set_1, i) && (!BitVec_Get(set_2, i)); - break; - default: - wanted = false; - THROW(ERR, "unknown op: %d", op); - } - - if (BitVec_Get(bit_vec, i) != wanted) { break; } - } - - return i; -} - -static void -test_Or(TestBatchRunner *runner) { - BitVector *smaller = S_create_set(1); - BitVector *larger = S_create_set(2); - BitVector *set_1 = S_create_set(1); - BitVector *set_2 = S_create_set(2); - - BitVec_Or(smaller, set_2); - TEST_UINT_EQ(runner, S_verify_logical_op(smaller, set_1, set_2, OP_OR), - 50, "OR with self smaller than other"); - BitVec_Or(larger, set_1); - TEST_UINT_EQ(runner, S_verify_logical_op(larger, set_1, set_2, OP_OR), - 50, "OR with other smaller than self"); - - DECREF(smaller); - DECREF(larger); - DECREF(set_1); - DECREF(set_2); -} - -static void -test_Xor(TestBatchRunner *runner) { - BitVector *smaller = S_create_set(1); - BitVector *larger = S_create_set(2); - BitVector *set_1 = S_create_set(1); - BitVector *set_2 = S_create_set(2); - - BitVec_Xor(smaller, set_2); - TEST_UINT_EQ(runner, S_verify_logical_op(smaller, set_1, set_2, OP_XOR), - 50, "XOR with self smaller than other"); - BitVec_Xor(larger, set_1); - TEST_UINT_EQ(runner, S_verify_logical_op(larger, set_1, set_2, OP_XOR), - 50, "XOR with other smaller than self"); - - DECREF(smaller); - DECREF(larger); - DECREF(set_1); - DECREF(set_2); -} - -static void -test_And(TestBatchRunner *runner) { - BitVector *smaller = S_create_set(1); - BitVector *larger = S_create_set(2); - BitVector *set_1 = S_create_set(1); - BitVector *set_2 = S_create_set(2); - - BitVec_And(smaller, set_2); - TEST_UINT_EQ(runner, S_verify_logical_op(smaller, set_1, set_2, OP_AND), - 50, "AND with self smaller than other"); - BitVec_And(larger, set_1); - TEST_UINT_EQ(runner, S_verify_logical_op(larger, set_1, set_2, OP_AND), - 50, "AND with other smaller than self"); - - DECREF(smaller); - DECREF(larger); - DECREF(set_1); - DECREF(set_2); -} - -static void -test_And_Not(TestBatchRunner *runner) { - BitVector *smaller = S_create_set(1); - BitVector *larger = S_create_set(2); - BitVector *set_1 = S_create_set(1); - BitVector *set_2 = S_create_set(2); - - BitVec_And_Not(smaller, set_2); - TEST_UINT_EQ(runner, - S_verify_logical_op(smaller, set_1, set_2, OP_AND_NOT), - 50, "AND_NOT with self smaller than other"); - BitVec_And_Not(larger, set_1); - TEST_UINT_EQ(runner, - S_verify_logical_op(larger, set_2, set_1, OP_AND_NOT), - 50, "AND_NOT with other smaller than self"); - - DECREF(smaller); - DECREF(larger); - DECREF(set_1); - DECREF(set_2); -} - -static void -test_Count(TestBatchRunner *runner) { - unsigned shuffled[64]; - BitVector *bit_vec = BitVec_new(64); - - for (unsigned i = 0; i < 64; i++) { shuffled[i] = i; } - for (unsigned i = 0; i < 64; i++) { - unsigned shuffle_pos = (unsigned)rand() % 64; - unsigned temp = shuffled[shuffle_pos]; - shuffled[shuffle_pos] = shuffled[i]; - shuffled[i] = temp; - } - unsigned i; - for (i = 0; i < 64; i++) { - BitVec_Set(bit_vec, shuffled[i]); - if (BitVec_Count(bit_vec) != (uint32_t)(i + 1)) { break; } - } - TEST_UINT_EQ(runner, i, 64, "Count() returns the right number of bits"); - - DECREF(bit_vec); -} - -static void -test_Next_Hit(TestBatchRunner *runner) { - for (int i = 24; i <= 33; i++) { - BitVector *bit_vec = BitVec_new(64); - BitVec_Set(bit_vec, (size_t)i); - TEST_INT_EQ(runner, BitVec_Next_Hit(bit_vec, 0), i, - "Next_Hit for 0 is %d", i); - TEST_INT_EQ(runner, BitVec_Next_Hit(bit_vec, 1), i, - "Next_Hit for 1 is %d", i); - for (int probe = 15; probe <= i; probe++) { - TEST_INT_EQ(runner, BitVec_Next_Hit(bit_vec, (size_t)probe), i, - "Next_Hit for %d is %d", probe, i); - } - for (int probe = i + 1; probe <= i + 9; probe++) { - TEST_INT_EQ(runner, BitVec_Next_Hit(bit_vec, (size_t)probe), -1, - "no Next_Hit for %d when max is %d", probe, i); - } - TEST_INT_EQ(runner, BitVec_Next_Hit(bit_vec, INT32_MAX), -1, - "no Next_Hit for INT32_MAX when max is %d", i); - DECREF(bit_vec); - } -} - -static void -test_Clear_All(TestBatchRunner *runner) { - BitVector *bit_vec = BitVec_new(64); - BitVec_Flip_Block(bit_vec, 0, 63); - BitVec_Clear_All(bit_vec); - TEST_INT_EQ(runner, BitVec_Next_Hit(bit_vec, 0), -1, "Clear_All"); - DECREF(bit_vec); -} - -static void -test_Clone(TestBatchRunner *runner) { - BitVector *self = BitVec_new(30); - BitVector *twin; - - BitVec_Set(self, 2); - BitVec_Set(self, 3); - BitVec_Set(self, 10); - BitVec_Set(self, 20); - - twin = BitVec_Clone(self); - size_t i; - for (i = 0; i < 50; i++) { - if (BitVec_Get(self, i) != BitVec_Get(twin, i)) { break; } - } - TEST_UINT_EQ(runner, i, 50, "Clone"); - TEST_UINT_EQ(runner, BitVec_Count(twin), 4, "clone Count"); - - DECREF(self); - DECREF(twin); -} - -static int -S_compare_u64s(const void *va, const void *vb) { - uint64_t a = *(uint64_t*)va; - uint64_t b = *(uint64_t*)vb; - return a == b ? 0 : a < b ? -1 : 1; -} - -static void -test_To_Array(TestBatchRunner *runner) { - uint64_t *source_ints = TestUtils_random_u64s(NULL, 20, 0, 200); - BitVector *bit_vec = BitVec_new(0); - I32Array *array; - unsigned num_unique = 0; - - // Unique the random ints. - qsort(source_ints, 20, sizeof(uint64_t), S_compare_u64s); - for (unsigned i = 0; i < 19; i++) { - if (source_ints[i] != source_ints[i + 1]) { - source_ints[num_unique] = source_ints[i]; - num_unique++; - } - } - - // Set bits. - for (unsigned i = 0; i < num_unique; i++) { - BitVec_Set(bit_vec, (size_t)source_ints[i]); - } - - // Create the array and compare it to the source. - array = BitVec_To_Array(bit_vec); - unsigned i; - for (i = 0; i < num_unique; i++) { - if (I32Arr_Get(array, (size_t)i) != (int32_t)source_ints[i]) { break; } - } - TEST_UINT_EQ(runner, i, num_unique, "To_Array (%u == %u)", i, - num_unique); - - DECREF(array); - DECREF(bit_vec); - FREEMEM(source_ints); -} - - -// Valgrind only - detect off-by-one error. -static void -test_off_by_one_error() { - for (unsigned cap = 5; cap <= 24; cap++) { - BitVector *bit_vec = BitVec_new(cap); - BitVec_Set(bit_vec, cap - 2); - DECREF(bit_vec); - } -} - -void -TestBitVector_Run_IMP(TestBitVector *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 1039); - test_Set_and_Get(runner); - test_Flip(runner); - test_Flip_Block_ascending(runner); - test_Flip_Block_descending(runner); - test_Flip_Block_bulk(runner); - test_Mimic(runner); - test_Or(runner); - test_Xor(runner); - test_And(runner); - test_And_Not(runner); - test_Count(runner); - test_Next_Hit(runner); - test_Clear_All(runner); - test_Clone(runner); - test_To_Array(runner); - test_off_by_one_error(); -} - -
http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Object/TestBitVector.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Object/TestBitVector.cfh b/core/Lucy/Test/Object/TestBitVector.cfh deleted file mode 100644 index e38c66d..0000000 --- a/core/Lucy/Test/Object/TestBitVector.cfh +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Object::TestBitVector - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestBitVector* - new(); - - void - Run(TestBitVector *self, TestBatchRunner *runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Object/TestI32Array.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Object/TestI32Array.c b/core/Lucy/Test/Object/TestI32Array.c deleted file mode 100644 index 7236d7b..0000000 --- a/core/Lucy/Test/Object/TestI32Array.c +++ /dev/null @@ -1,73 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTI32ARRAY -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" - -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Lucy/Test.h" -#include "Lucy/Test/Object/TestI32Array.h" - -static int32_t source_ints[] = { -1, 0, INT32_MIN, INT32_MAX, 1 }; -static size_t num_ints = sizeof(source_ints) / sizeof(int32_t); - -TestI32Array* -TestI32Arr_new() { - return (TestI32Array*)Class_Make_Obj(TESTI32ARRAY); -} - -static void -test_all(TestBatchRunner *runner) { - I32Array *i32_array = I32Arr_new(source_ints, num_ints); - int32_t *ints_copy = (int32_t*)malloc(num_ints * sizeof(int32_t)); - I32Array *stolen = I32Arr_new_steal(ints_copy, num_ints); - size_t num_matched; - - memcpy(ints_copy, source_ints, num_ints * sizeof(int32_t)); - - TEST_TRUE(runner, I32Arr_Get_Size(i32_array) == num_ints, - "Get_Size"); - TEST_TRUE(runner, I32Arr_Get_Size(stolen) == num_ints, - "Get_Size for stolen"); - - for (num_matched = 0; num_matched < num_ints; num_matched++) { - if (source_ints[num_matched] != I32Arr_Get(i32_array, num_matched)) { - break; - } - } - TEST_UINT_EQ(runner, num_matched, num_ints, - "Matched all source ints with Get()"); - - for (num_matched = 0; num_matched < num_ints; num_matched++) { - if (source_ints[num_matched] != I32Arr_Get(stolen, num_matched)) { - break; - } - } - TEST_UINT_EQ(runner, num_matched, num_ints, - "Matched all source ints in stolen I32Array with Get()"); - - DECREF(i32_array); - DECREF(stolen); -} - -void -TestI32Arr_Run_IMP(TestI32Array *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 4); - test_all(runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Object/TestI32Array.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Object/TestI32Array.cfh b/core/Lucy/Test/Object/TestI32Array.cfh deleted file mode 100644 index dceba6b..0000000 --- a/core/Lucy/Test/Object/TestI32Array.cfh +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Object::TestI32Array nickname TestI32Arr - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestI32Array* - new(); - - void - Run(TestI32Array *self, TestBatchRunner *runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Plan/TestArchitecture.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Plan/TestArchitecture.c b/core/Lucy/Test/Plan/TestArchitecture.c deleted file mode 100644 index 138405c..0000000 --- a/core/Lucy/Test/Plan/TestArchitecture.c +++ /dev/null @@ -1,50 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTARCHITECTURE -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" - -#include "Lucy/Test.h" -#include "Lucy/Test/Plan/TestArchitecture.h" -#include "Lucy/Plan/Architecture.h" - -TestArchitecture* -TestArch_new() { - TestArchitecture *self - = (TestArchitecture*)Class_Make_Obj(TESTARCHITECTURE); - return TestArch_init(self); -} - -TestArchitecture* -TestArch_init(TestArchitecture *self) { - Arch_init((Architecture*)self); - return self; -} - -int32_t -TestArch_Index_Interval_IMP(TestArchitecture *self) { - UNUSED_VAR(self); - return 5; -} - -int32_t -TestArch_Skip_Interval_IMP(TestArchitecture *self) { - UNUSED_VAR(self); - return 3; -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Plan/TestArchitecture.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Plan/TestArchitecture.cfh b/core/Lucy/Test/Plan/TestArchitecture.cfh deleted file mode 100644 index 737519b..0000000 --- a/core/Lucy/Test/Plan/TestArchitecture.cfh +++ /dev/null @@ -1,39 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -/** - * Returns absurdly low values for [](cfish:.Index_Interval) and [](cfish:.Skip_Interval). - */ - -class Lucy::Test::Plan::TestArchitecture nickname TestArch - inherits Lucy::Plan::Architecture { - - inert incremented TestArchitecture* - new(); - - inert TestArchitecture* - init(TestArchitecture *self); - - int32_t - Index_Interval(TestArchitecture *self); - - int32_t - Skip_Interval(TestArchitecture *self); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Plan/TestBlobType.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Plan/TestBlobType.c b/core/Lucy/Test/Plan/TestBlobType.c deleted file mode 100644 index a207997..0000000 --- a/core/Lucy/Test/Plan/TestBlobType.c +++ /dev/null @@ -1,59 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTBLOBTYPE -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" - -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Lucy/Test.h" -#include "Lucy/Test/Plan/TestBlobType.h" -#include "Lucy/Test/TestUtils.h" -#include "Lucy/Plan/BlobType.h" -#include "Lucy/Util/Freezer.h" - -TestBlobType* -TestBlobType_new() { - return (TestBlobType*)Class_Make_Obj(TESTBLOBTYPE); -} - -static void -test_Dump_Load_and_Equals(TestBatchRunner *runner) { - BlobType *type = BlobType_new(true); - Obj *dump = (Obj*)BlobType_Dump(type); - Obj *clone = Freezer_load(dump); - Obj *another_dump = (Obj*)BlobType_Dump_For_Schema(type); - BlobType *another_clone = BlobType_Load(type, another_dump); - - TEST_TRUE(runner, BlobType_Equals(type, (Obj*)clone), - "Dump => Load round trip"); - TEST_TRUE(runner, BlobType_Equals(type, (Obj*)another_clone), - "Dump_For_Schema => Load round trip"); - - DECREF(type); - DECREF(dump); - DECREF(clone); - DECREF(another_dump); - DECREF(another_clone); -} - -void -TestBlobType_Run_IMP(TestBlobType *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 2); - test_Dump_Load_and_Equals(runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Plan/TestBlobType.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Plan/TestBlobType.cfh b/core/Lucy/Test/Plan/TestBlobType.cfh deleted file mode 100644 index a0ffc79..0000000 --- a/core/Lucy/Test/Plan/TestBlobType.cfh +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Plan::TestBlobType - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestBlobType* - new(); - - void - Run(TestBlobType *self, TestBatchRunner *runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Plan/TestFieldMisc.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Plan/TestFieldMisc.c b/core/Lucy/Test/Plan/TestFieldMisc.c deleted file mode 100644 index 54779f4..0000000 --- a/core/Lucy/Test/Plan/TestFieldMisc.c +++ /dev/null @@ -1,248 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Lucy/Test.h" -#include "Lucy/Test/Plan/TestFieldMisc.h" - -#include "Lucy/Analysis/EasyAnalyzer.h" -#include "Lucy/Analysis/StandardTokenizer.h" -#include "Lucy/Document/Doc.h" -#include "Lucy/Document/HitDoc.h" -#include "Lucy/Index/Indexer.h" -#include "Lucy/Plan/FullTextType.h" -#include "Lucy/Plan/Schema.h" -#include "Lucy/Plan/StringType.h" -#include "Lucy/Search/Hits.h" -#include "Lucy/Search/IndexSearcher.h" -#include "Lucy/Search/TermQuery.h" -#include "Lucy/Store/RAMFolder.h" - -static String *analyzed_str; -static String *easy_analyzed_str; -static String *state_str; -static String *states_str; -static String *string_str; -static String *unindexed_but_analyzed_str; -static String *unindexed_unanalyzed_str; -static String *united_states_str; - -TestFieldMisc* -TestFieldMisc_new() { - return (TestFieldMisc*)Class_Make_Obj(TESTFIELDMISC); -} - -static void -S_init_strings() { - analyzed_str = Str_newf("analyzed"); - easy_analyzed_str = Str_newf("easy_analyzed"); - state_str = Str_newf("state"); - states_str = Str_newf("States"); - string_str = Str_newf("string"); - unindexed_but_analyzed_str = Str_newf("unindexed_but_analyzed"); - unindexed_unanalyzed_str = Str_newf("unindexed_unanalyzed"); - united_states_str = Str_newf("United States"); -} - -static void -S_destroy_strings() { - DECREF(analyzed_str); - DECREF(easy_analyzed_str); - DECREF(state_str); - DECREF(states_str); - DECREF(string_str); - DECREF(unindexed_but_analyzed_str); - DECREF(unindexed_unanalyzed_str); - DECREF(united_states_str); -} - -static Schema* -S_create_schema() { - Schema *schema = Schema_new(); - - StandardTokenizer *tokenizer = StandardTokenizer_new(); - String *language = Str_newf("en"); - EasyAnalyzer *easy_analyzer = EasyAnalyzer_new(language); - - FullTextType *plain = FullTextType_new((Analyzer*)tokenizer); - FullTextType *easy_analyzed = FullTextType_new((Analyzer*)easy_analyzer); - - StringType *string_spec = StringType_new(); - - FullTextType *unindexed_but_analyzed - = FullTextType_new((Analyzer*)tokenizer); - FullTextType_Set_Indexed(unindexed_but_analyzed, false); - - StringType *unindexed_unanalyzed = StringType_new(); - StringType_Set_Indexed(unindexed_unanalyzed, false); - - Schema_Spec_Field(schema, analyzed_str, (FieldType*)plain); - Schema_Spec_Field(schema, easy_analyzed_str, (FieldType*)easy_analyzed); - Schema_Spec_Field(schema, string_str, (FieldType*)string_spec); - Schema_Spec_Field(schema, unindexed_but_analyzed_str, - (FieldType*)unindexed_but_analyzed); - Schema_Spec_Field(schema, unindexed_unanalyzed_str, - (FieldType*)unindexed_unanalyzed); - - DECREF(unindexed_unanalyzed); - DECREF(unindexed_but_analyzed); - DECREF(string_spec); - DECREF(easy_analyzed); - DECREF(plain); - DECREF(easy_analyzer); - DECREF(language); - DECREF(tokenizer); - - return schema; -} - -static void -S_add_doc(Indexer *indexer, String *field_name) { - Doc *doc = Doc_new(NULL, 0); - Doc_Store(doc, field_name, (Obj*)united_states_str); - Indexer_Add_Doc(indexer, doc, 1.0f); - DECREF(doc); -} - -static void -S_check(TestBatchRunner *runner, RAMFolder *folder, String *field, - String *query_text, uint32_t expected_num_hits) { - char *field_str = Str_To_Utf8(field); - TermQuery *query = TermQuery_new(field, (Obj*)query_text); - IndexSearcher *searcher = IxSearcher_new((Obj*)folder); - Hits *hits = IxSearcher_Hits(searcher, (Obj*)query, 0, 10, NULL); - - TEST_TRUE(runner, Hits_Total_Hits(hits) == expected_num_hits, - "%s correct num hits", field_str); - - // Don't check the contents of the hit if there aren't any. - if (expected_num_hits) { - HitDoc *hit = Hits_Next(hits); - String *value = (String*)HitDoc_Extract(hit, field); - TEST_TRUE(runner, Str_Equals(united_states_str, (Obj*)value), - "%s correct doc returned", field_str); - DECREF(value); - DECREF(hit); - } - - DECREF(hits); - DECREF(searcher); - DECREF(query); - free(field_str); -} - -static void -test_spec_field(TestBatchRunner *runner) { - RAMFolder *folder = RAMFolder_new(NULL); - Schema *schema = S_create_schema(); - Indexer *indexer = Indexer_new(schema, (Obj*)folder, NULL, 0); - - S_add_doc(indexer, analyzed_str); - S_add_doc(indexer, easy_analyzed_str); - S_add_doc(indexer, string_str); - S_add_doc(indexer, unindexed_but_analyzed_str); - S_add_doc(indexer, unindexed_unanalyzed_str); - - Indexer_Commit(indexer); - - S_check(runner, folder, analyzed_str, states_str, 1); - S_check(runner, folder, easy_analyzed_str, state_str, 1); - S_check(runner, folder, string_str, united_states_str, 1); - S_check(runner, folder, unindexed_but_analyzed_str, state_str, 0); - S_check(runner, folder, unindexed_but_analyzed_str, united_states_str, 0); - S_check(runner, folder, unindexed_unanalyzed_str, state_str, 0); - S_check(runner, folder, unindexed_unanalyzed_str, united_states_str, 0); - - DECREF(indexer); - DECREF(schema); - DECREF(folder); -} - -static void -S_add_many_fields_doc(Indexer *indexer, String *content, int num_fields) { - Doc *doc = Doc_new(NULL, 0); - for (int32_t i = 1; i <= num_fields; ++i) { - String *field = Str_newf("field%i32", i); - Doc_Store(doc, field, (Obj*)content); - DECREF(field); - } - Indexer_Add_Doc(indexer, doc, 1.0f); - DECREF(doc); -} - -static void -test_many_fields(TestBatchRunner *runner) { - Schema *schema = Schema_new(); - StandardTokenizer *tokenizer = StandardTokenizer_new(); - FullTextType *type = FullTextType_new((Analyzer*)tokenizer); - String *query = Str_newf("x"); - - for (int32_t num_fields = 1; num_fields <= 10; ++num_fields) { - // Build an index with num_fields fields, and the same content in each. - String *field = Str_newf("field%i32", num_fields); - Schema_Spec_Field(schema, field, (FieldType*)type); - - RAMFolder *folder = RAMFolder_new(NULL); - Indexer *indexer = Indexer_new(schema, (Obj*)folder, NULL, 0); - - String *content; - - for (int c = 'a'; c <= 'z'; ++c) { - content = Str_new_from_char(c); - S_add_many_fields_doc(indexer, content, num_fields); - DECREF(content); - } - - content = Str_newf("x x y"); - S_add_many_fields_doc(indexer, content, num_fields); - DECREF(content); - - Indexer_Commit(indexer); - - // See if our search results match as expected. - IndexSearcher *searcher = IxSearcher_new((Obj*)folder); - Hits *hits = IxSearcher_Hits(searcher, (Obj*)query, 0, 100, NULL); - TEST_TRUE(runner, Hits_Total_Hits(hits) == 2, - "correct number of hits for %d fields", num_fields); - HitDoc *top_hit = Hits_Next(hits); - - DECREF(top_hit); - DECREF(hits); - DECREF(searcher); - DECREF(indexer); - DECREF(folder); - DECREF(field); - } - - DECREF(query); - DECREF(type); - DECREF(tokenizer); - DECREF(schema); -} - -void -TestFieldMisc_Run_IMP(TestFieldMisc *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 20); - S_init_strings(); - test_spec_field(runner); - test_many_fields(runner); - S_destroy_strings(); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Plan/TestFieldMisc.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Plan/TestFieldMisc.cfh b/core/Lucy/Test/Plan/TestFieldMisc.cfh deleted file mode 100644 index f3f686a..0000000 --- a/core/Lucy/Test/Plan/TestFieldMisc.cfh +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Plan::TestFieldMisc - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestFieldMisc* - new(); - - void - Run(TestFieldMisc *self, TestBatchRunner *runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Plan/TestFieldType.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Plan/TestFieldType.c b/core/Lucy/Test/Plan/TestFieldType.c deleted file mode 100644 index b81fce5..0000000 --- a/core/Lucy/Test/Plan/TestFieldType.c +++ /dev/null @@ -1,107 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTFIELDTYPE -#define C_LUCY_DUMMYFIELDTYPE -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" - -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Lucy/Test.h" -#include "Lucy/Test/Plan/TestFieldType.h" -#include "Lucy/Test/TestUtils.h" - -TestFieldType* -TestFType_new() { - return (TestFieldType*)Class_Make_Obj(TESTFIELDTYPE); -} - -DummyFieldType* -DummyFieldType_new() { - DummyFieldType *self = (DummyFieldType*)Class_Make_Obj(DUMMYFIELDTYPE); - return (DummyFieldType*)FType_init((FieldType*)self); -} - -static FieldType* -S_alt_field_type() { - String *name = SSTR_WRAP_C("DummyFieldType2"); - Class *klass = Class_singleton(name, DUMMYFIELDTYPE); - FieldType *self = (FieldType*)Class_Make_Obj(klass); - return FType_init(self); -} - -static void -test_Dump_Load_and_Equals(TestBatchRunner *runner) { - FieldType *type = (FieldType*)DummyFieldType_new(); - FieldType *other = (FieldType*)DummyFieldType_new(); - FieldType *class_differs = S_alt_field_type(); - FieldType *boost_differs = (FieldType*)DummyFieldType_new(); - FieldType *indexed = (FieldType*)DummyFieldType_new(); - FieldType *stored = (FieldType*)DummyFieldType_new(); - - FType_Set_Boost(other, 1.0); - FType_Set_Indexed(indexed, false); - FType_Set_Stored(stored, false); - - FType_Set_Boost(boost_differs, 1.5); - FType_Set_Indexed(indexed, true); - FType_Set_Stored(stored, true); - - TEST_TRUE(runner, FType_Equals(type, (Obj*)other), - "Equals() true with identical stats"); - TEST_FALSE(runner, FType_Equals(type, (Obj*)class_differs), - "Equals() false with subclass"); - TEST_FALSE(runner, FType_Equals(type, (Obj*)class_differs), - "Equals() false with super class"); - TEST_FALSE(runner, FType_Equals(type, (Obj*)boost_differs), - "Equals() false with different boost"); - TEST_FALSE(runner, FType_Equals(type, (Obj*)indexed), - "Equals() false with indexed => true"); - TEST_FALSE(runner, FType_Equals(type, (Obj*)stored), - "Equals() false with stored => true"); - - DECREF(stored); - DECREF(indexed); - DECREF(boost_differs); - DECREF(class_differs); - DECREF(other); - DECREF(type); -} - -static void -test_Compare_Values(TestBatchRunner *runner) { - FieldType *type = (FieldType*)DummyFieldType_new(); - Obj *a = (Obj*)SSTR_WRAP_C("a"); - Obj *b = (Obj*)SSTR_WRAP_C("b"); - - TEST_TRUE(runner, FType_Compare_Values(type, a, b) < 0, - "a less than b"); - TEST_TRUE(runner, FType_Compare_Values(type, b, a) > 0, - "b greater than a"); - TEST_TRUE(runner, FType_Compare_Values(type, b, b) == 0, - "b equals b"); - - DECREF(type); -} - -void -TestFType_Run_IMP(TestFieldType *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 9); - test_Dump_Load_and_Equals(runner); - test_Compare_Values(runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Plan/TestFieldType.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Plan/TestFieldType.cfh b/core/Lucy/Test/Plan/TestFieldType.cfh deleted file mode 100644 index a82c640..0000000 --- a/core/Lucy/Test/Plan/TestFieldType.cfh +++ /dev/null @@ -1,33 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Plan::TestFieldType nickname TestFType - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestFieldType* - new(); - - void - Run(TestFieldType *self, TestBatchRunner *runner); -} - -class Lucy::Test::Plan::DummyFieldType inherits Lucy::Plan::FieldType { - inert incremented DummyFieldType* - new(); -} - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Plan/TestFullTextType.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Plan/TestFullTextType.c b/core/Lucy/Test/Plan/TestFullTextType.c deleted file mode 100644 index 709b1c2..0000000 --- a/core/Lucy/Test/Plan/TestFullTextType.c +++ /dev/null @@ -1,112 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTFULLTEXTTYPE -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" - -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Lucy/Test.h" -#include "Lucy/Test/Plan/TestFullTextType.h" -#include "Lucy/Test/TestUtils.h" -#include "Lucy/Plan/FullTextType.h" -#include "Lucy/Analysis/Normalizer.h" -#include "Lucy/Analysis/StandardTokenizer.h" -#include "Lucy/Util/Freezer.h" - -TestFullTextType* -TestFullTextType_new() { - return (TestFullTextType*)Class_Make_Obj(TESTFULLTEXTTYPE); -} - -static void -test_Dump_Load_and_Equals(TestBatchRunner *runner) { - StandardTokenizer *tokenizer = StandardTokenizer_new(); - Normalizer *normalizer = Normalizer_new(NULL, true, false); - FullTextType *type = FullTextType_new((Analyzer*)tokenizer); - FullTextType *other = FullTextType_new((Analyzer*)normalizer); - FullTextType *boost_differs = FullTextType_new((Analyzer*)tokenizer); - FullTextType *not_indexed = FullTextType_new((Analyzer*)tokenizer); - FullTextType *not_stored = FullTextType_new((Analyzer*)tokenizer); - FullTextType *highlightable = FullTextType_new((Analyzer*)tokenizer); - Obj *dump = (Obj*)FullTextType_Dump(type); - Obj *clone = Freezer_load(dump); - Obj *another_dump = (Obj*)FullTextType_Dump_For_Schema(type); - - FullTextType_Set_Boost(boost_differs, 1.5); - FullTextType_Set_Indexed(not_indexed, false); - FullTextType_Set_Stored(not_stored, false); - FullTextType_Set_Highlightable(highlightable, true); - - // (This step is normally performed by Schema_Load() internally.) - Hash_Store_Utf8((Hash*)another_dump, "analyzer", 8, INCREF(tokenizer)); - FullTextType *another_clone = FullTextType_Load(type, another_dump); - - TEST_FALSE(runner, FullTextType_Equals(type, (Obj*)boost_differs), - "Equals() false with different boost"); - TEST_FALSE(runner, FullTextType_Equals(type, (Obj*)other), - "Equals() false with different Analyzer"); - TEST_FALSE(runner, FullTextType_Equals(type, (Obj*)not_indexed), - "Equals() false with indexed => false"); - TEST_FALSE(runner, FullTextType_Equals(type, (Obj*)not_stored), - "Equals() false with stored => false"); - TEST_FALSE(runner, FullTextType_Equals(type, (Obj*)highlightable), - "Equals() false with highlightable => true"); - TEST_TRUE(runner, FullTextType_Equals(type, (Obj*)clone), - "Dump => Load round trip"); - TEST_TRUE(runner, FullTextType_Equals(type, (Obj*)another_clone), - "Dump_For_Schema => Load round trip"); - - DECREF(another_clone); - DECREF(dump); - DECREF(clone); - DECREF(another_dump); - DECREF(highlightable); - DECREF(not_stored); - DECREF(not_indexed); - DECREF(boost_differs); - DECREF(other); - DECREF(type); - DECREF(normalizer); - DECREF(tokenizer); -} - -static void -test_Compare_Values(TestBatchRunner *runner) { - StandardTokenizer *tokenizer = StandardTokenizer_new(); - FullTextType *type = FullTextType_new((Analyzer*)tokenizer); - Obj *a = (Obj*)SSTR_WRAP_C("a"); - Obj *b = (Obj*)SSTR_WRAP_C("b"); - - TEST_TRUE(runner, FullTextType_Compare_Values(type, a, b) < 0, - "a less than b"); - TEST_TRUE(runner, FullTextType_Compare_Values(type, b, a) > 0, - "b greater than a"); - TEST_TRUE(runner, FullTextType_Compare_Values(type, b, b) == 0, - "b equals b"); - - DECREF(type); - DECREF(tokenizer); -} - -void -TestFullTextType_Run_IMP(TestFullTextType *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 10); - test_Dump_Load_and_Equals(runner); - test_Compare_Values(runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Plan/TestFullTextType.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Plan/TestFullTextType.cfh b/core/Lucy/Test/Plan/TestFullTextType.cfh deleted file mode 100644 index cfdbf7c..0000000 --- a/core/Lucy/Test/Plan/TestFullTextType.cfh +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Plan::TestFullTextType - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestFullTextType* - new(); - - void - Run(TestFullTextType *self, TestBatchRunner *runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Plan/TestNumericType.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Plan/TestNumericType.c b/core/Lucy/Test/Plan/TestNumericType.c deleted file mode 100644 index b36af4c..0000000 --- a/core/Lucy/Test/Plan/TestNumericType.c +++ /dev/null @@ -1,109 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTNUMERICTYPE -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" - -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Lucy/Test.h" -#include "Lucy/Test/Plan/TestNumericType.h" -#include "Lucy/Test/TestUtils.h" -#include "Lucy/Plan/BlobType.h" -#include "Lucy/Plan/NumericType.h" -#include "Lucy/Util/Freezer.h" - -TestNumericType* -TestNumericType_new() { - return (TestNumericType*)Class_Make_Obj(TESTNUMERICTYPE); -} - -static void -test_Dump_Load_and_Equals(TestBatchRunner *runner) { - Int32Type *i32 = Int32Type_new(); - Int64Type *i64 = Int64Type_new(); - Float32Type *f32 = Float32Type_new(); - Float64Type *f64 = Float64Type_new(); - - TEST_FALSE(runner, Int32Type_Equals(i32, (Obj*)i64), - "Int32Type_Equals() false for different type"); - TEST_FALSE(runner, Int32Type_Equals(i32, NULL), - "Int32Type_Equals() false for NULL"); - - TEST_FALSE(runner, Int64Type_Equals(i64, (Obj*)i32), - "Int64Type_Equals() false for different type"); - TEST_FALSE(runner, Int64Type_Equals(i64, NULL), - "Int64Type_Equals() false for NULL"); - - TEST_FALSE(runner, Float32Type_Equals(f32, (Obj*)f64), - "Float32Type_Equals() false for different type"); - TEST_FALSE(runner, Float32Type_Equals(f32, NULL), - "Float32Type_Equals() false for NULL"); - - TEST_FALSE(runner, Float64Type_Equals(f64, (Obj*)f32), - "Float64Type_Equals() false for different type"); - TEST_FALSE(runner, Float64Type_Equals(f64, NULL), - "Float64Type_Equals() false for NULL"); - - { - Obj *dump = (Obj*)Int32Type_Dump(i32); - Obj *other = Freezer_load(dump); - TEST_TRUE(runner, Int32Type_Equals(i32, other), - "Dump => Load round trip for Int32Type"); - DECREF(dump); - DECREF(other); - } - - { - Obj *dump = (Obj*)Int64Type_Dump(i64); - Obj *other = Freezer_load(dump); - TEST_TRUE(runner, Int64Type_Equals(i64, other), - "Dump => Load round trip for Int64Type"); - DECREF(dump); - DECREF(other); - } - - { - Obj *dump = (Obj*)Float32Type_Dump(f32); - Obj *other = Freezer_load(dump); - TEST_TRUE(runner, Float32Type_Equals(f32, other), - "Dump => Load round trip for Float32Type"); - DECREF(dump); - DECREF(other); - } - - { - Obj *dump = (Obj*)Float64Type_Dump(f64); - Obj *other = Freezer_load(dump); - TEST_TRUE(runner, Float64Type_Equals(f64, other), - "Dump => Load round trip for Float64Type"); - DECREF(dump); - DECREF(other); - } - - DECREF(i32); - DECREF(i64); - DECREF(f32); - DECREF(f64); -} - -void -TestNumericType_Run_IMP(TestNumericType *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 12); - test_Dump_Load_and_Equals(runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Plan/TestNumericType.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Plan/TestNumericType.cfh b/core/Lucy/Test/Plan/TestNumericType.cfh deleted file mode 100644 index e3d952e..0000000 --- a/core/Lucy/Test/Plan/TestNumericType.cfh +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Plan::TestNumericType - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestNumericType* - new(); - - void - Run(TestNumericType *self, TestBatchRunner *runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Search/TestLeafQuery.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Search/TestLeafQuery.c b/core/Lucy/Test/Search/TestLeafQuery.c deleted file mode 100644 index f6e013f..0000000 --- a/core/Lucy/Test/Search/TestLeafQuery.c +++ /dev/null @@ -1,70 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTLEAFQUERY -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" -#include <math.h> - -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Lucy/Test.h" -#include "Lucy/Test/Search/TestLeafQuery.h" -#include "Lucy/Test/TestUtils.h" -#include "Lucy/Search/LeafQuery.h" - -TestLeafQuery* -TestLeafQuery_new() { - return (TestLeafQuery*)Class_Make_Obj(TESTLEAFQUERY); -} - -static void -test_Dump_Load_and_Equals(TestBatchRunner *runner) { - LeafQuery *query = TestUtils_make_leaf_query("content", "foo"); - LeafQuery *field_differs = TestUtils_make_leaf_query("stuff", "foo"); - LeafQuery *null_field = TestUtils_make_leaf_query(NULL, "foo"); - LeafQuery *term_differs = TestUtils_make_leaf_query("content", "bar"); - LeafQuery *boost_differs = TestUtils_make_leaf_query("content", "foo"); - Obj *dump = (Obj*)LeafQuery_Dump(query); - LeafQuery *clone = (LeafQuery*)LeafQuery_Load(term_differs, dump); - - TEST_FALSE(runner, LeafQuery_Equals(query, (Obj*)field_differs), - "Equals() false with different field"); - TEST_FALSE(runner, LeafQuery_Equals(query, (Obj*)null_field), - "Equals() false with null field"); - TEST_FALSE(runner, LeafQuery_Equals(query, (Obj*)term_differs), - "Equals() false with different term"); - LeafQuery_Set_Boost(boost_differs, 0.5); - TEST_FALSE(runner, LeafQuery_Equals(query, (Obj*)boost_differs), - "Equals() false with different boost"); - TEST_TRUE(runner, LeafQuery_Equals(query, (Obj*)clone), - "Dump => Load round trip"); - - DECREF(query); - DECREF(term_differs); - DECREF(field_differs); - DECREF(null_field); - DECREF(boost_differs); - DECREF(dump); - DECREF(clone); -} - -void -TestLeafQuery_Run_IMP(TestLeafQuery *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 5); - test_Dump_Load_and_Equals(runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Search/TestLeafQuery.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Search/TestLeafQuery.cfh b/core/Lucy/Test/Search/TestLeafQuery.cfh deleted file mode 100644 index 3750b6e..0000000 --- a/core/Lucy/Test/Search/TestLeafQuery.cfh +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Search::TestLeafQuery - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestLeafQuery* - new(); - - void - Run(TestLeafQuery *self, TestBatchRunner *runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Search/TestMatchAllQuery.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Search/TestMatchAllQuery.c b/core/Lucy/Test/Search/TestMatchAllQuery.c deleted file mode 100644 index 524d25d..0000000 --- a/core/Lucy/Test/Search/TestMatchAllQuery.c +++ /dev/null @@ -1,57 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTMATCHALLQUERY -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" -#include <math.h> - -#include "Clownfish/Boolean.h" -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Lucy/Test.h" -#include "Lucy/Test/TestUtils.h" -#include "Lucy/Test/Search/TestMatchAllQuery.h" -#include "Lucy/Search/MatchAllQuery.h" - -TestMatchAllQuery* -TestMatchAllQuery_new() { - return (TestMatchAllQuery*)Class_Make_Obj(TESTMATCHALLQUERY); -} - -static void -test_Dump_Load_and_Equals(TestBatchRunner *runner) { - MatchAllQuery *query = MatchAllQuery_new(); - Obj *dump = (Obj*)MatchAllQuery_Dump(query); - MatchAllQuery *clone = (MatchAllQuery*)MatchAllQuery_Load(query, dump); - - TEST_TRUE(runner, MatchAllQuery_Equals(query, (Obj*)clone), - "Dump => Load round trip"); - TEST_FALSE(runner, MatchAllQuery_Equals(query, (Obj*)CFISH_TRUE), - "Equals"); - - DECREF(query); - DECREF(dump); - DECREF(clone); -} - - -void -TestMatchAllQuery_Run_IMP(TestMatchAllQuery *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 2); - test_Dump_Load_and_Equals(runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Search/TestMatchAllQuery.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Search/TestMatchAllQuery.cfh b/core/Lucy/Test/Search/TestMatchAllQuery.cfh deleted file mode 100644 index c4232ff..0000000 --- a/core/Lucy/Test/Search/TestMatchAllQuery.cfh +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Search::TestMatchAllQuery - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestMatchAllQuery* - new(); - - void - Run(TestMatchAllQuery *self, TestBatchRunner *runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Search/TestNOTQuery.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Search/TestNOTQuery.c b/core/Lucy/Test/Search/TestNOTQuery.c deleted file mode 100644 index eee7657..0000000 --- a/core/Lucy/Test/Search/TestNOTQuery.c +++ /dev/null @@ -1,70 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTNOTQUERY -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" -#include <math.h> - -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Lucy/Test.h" -#include "Lucy/Test/TestUtils.h" -#include "Lucy/Test/Search/TestNOTQuery.h" -#include "Lucy/Search/NOTQuery.h" -#include "Lucy/Search/LeafQuery.h" -#include "Lucy/Util/Freezer.h" - -TestNOTQuery* -TestNOTQuery_new() { - return (TestNOTQuery*)Class_Make_Obj(TESTNOTQUERY); -} - -static void -test_Dump_Load_and_Equals(TestBatchRunner *runner) { - Query *a_leaf = (Query*)TestUtils_make_leaf_query(NULL, "a"); - Query *b_leaf = (Query*)TestUtils_make_leaf_query(NULL, "b"); - NOTQuery *query = NOTQuery_new(a_leaf); - NOTQuery *kids_differ = NOTQuery_new(b_leaf); - NOTQuery *boost_differs = NOTQuery_new(a_leaf); - Obj *dump = (Obj*)NOTQuery_Dump(query); - NOTQuery *clone = (NOTQuery*)Freezer_load(dump); - - TEST_FALSE(runner, NOTQuery_Equals(query, (Obj*)kids_differ), - "Different kids spoil Equals"); - TEST_TRUE(runner, NOTQuery_Equals(query, (Obj*)boost_differs), - "Equals with identical boosts"); - NOTQuery_Set_Boost(boost_differs, 1.5); - TEST_FALSE(runner, NOTQuery_Equals(query, (Obj*)boost_differs), - "Different boost spoils Equals"); - TEST_TRUE(runner, NOTQuery_Equals(query, (Obj*)clone), - "Dump => Load round trip"); - - DECREF(a_leaf); - DECREF(b_leaf); - DECREF(query); - DECREF(kids_differ); - DECREF(boost_differs); - DECREF(dump); - DECREF(clone); -} - -void -TestNOTQuery_Run_IMP(TestNOTQuery *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 4); - test_Dump_Load_and_Equals(runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Search/TestNOTQuery.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Search/TestNOTQuery.cfh b/core/Lucy/Test/Search/TestNOTQuery.cfh deleted file mode 100644 index bc432ff..0000000 --- a/core/Lucy/Test/Search/TestNOTQuery.cfh +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Search::TestNOTQuery - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestNOTQuery* - new(); - - void - Run(TestNOTQuery *self, TestBatchRunner *runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Search/TestNoMatchQuery.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Search/TestNoMatchQuery.c b/core/Lucy/Test/Search/TestNoMatchQuery.c deleted file mode 100644 index bac28b9..0000000 --- a/core/Lucy/Test/Search/TestNoMatchQuery.c +++ /dev/null @@ -1,57 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTNOMATCHQUERY -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" -#include <math.h> - -#include "Clownfish/Boolean.h" -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Lucy/Test.h" -#include "Lucy/Test/TestUtils.h" -#include "Lucy/Test/Search/TestNoMatchQuery.h" -#include "Lucy/Search/NoMatchQuery.h" - -TestNoMatchQuery* -TestNoMatchQuery_new() { - return (TestNoMatchQuery*)Class_Make_Obj(TESTNOMATCHQUERY); -} - -static void -test_Dump_Load_and_Equals(TestBatchRunner *runner) { - NoMatchQuery *query = NoMatchQuery_new(); - Obj *dump = (Obj*)NoMatchQuery_Dump(query); - NoMatchQuery *clone = (NoMatchQuery*)NoMatchQuery_Load(query, dump); - - TEST_TRUE(runner, NoMatchQuery_Equals(query, (Obj*)clone), - "Dump => Load round trip"); - TEST_FALSE(runner, NoMatchQuery_Equals(query, (Obj*)CFISH_TRUE), - "Equals"); - - DECREF(query); - DECREF(dump); - DECREF(clone); -} - - -void -TestNoMatchQuery_Run_IMP(TestNoMatchQuery *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 2); - test_Dump_Load_and_Equals(runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Search/TestNoMatchQuery.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Search/TestNoMatchQuery.cfh b/core/Lucy/Test/Search/TestNoMatchQuery.cfh deleted file mode 100644 index cb3420e..0000000 --- a/core/Lucy/Test/Search/TestNoMatchQuery.cfh +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Search::TestNoMatchQuery - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestNoMatchQuery* - new(); - - void - Run(TestNoMatchQuery *self, TestBatchRunner *runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Search/TestPhraseQuery.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Search/TestPhraseQuery.c b/core/Lucy/Test/Search/TestPhraseQuery.c deleted file mode 100644 index c0ed6da..0000000 --- a/core/Lucy/Test/Search/TestPhraseQuery.c +++ /dev/null @@ -1,53 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTPHRASEQUERY -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" -#include <math.h> - -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Lucy/Test.h" -#include "Lucy/Test/TestUtils.h" -#include "Lucy/Test/Search/TestPhraseQuery.h" -#include "Lucy/Search/PhraseQuery.h" -#include "Lucy/Util/Freezer.h" - -TestPhraseQuery* -TestPhraseQuery_new() { - return (TestPhraseQuery*)Class_Make_Obj(TESTPHRASEQUERY); -} - -static void -test_Dump_And_Load(TestBatchRunner *runner) { - PhraseQuery *query - = TestUtils_make_phrase_query("content", "a", "b", "c", NULL); - Obj *dump = (Obj*)PhraseQuery_Dump(query); - PhraseQuery *twin = (PhraseQuery*)Freezer_load(dump); - TEST_TRUE(runner, PhraseQuery_Equals(query, (Obj*)twin), - "Dump => Load round trip"); - DECREF(query); - DECREF(dump); - DECREF(twin); -} - -void -TestPhraseQuery_Run_IMP(TestPhraseQuery *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 1); - test_Dump_And_Load(runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Search/TestPhraseQuery.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Search/TestPhraseQuery.cfh b/core/Lucy/Test/Search/TestPhraseQuery.cfh deleted file mode 100644 index 78969dc..0000000 --- a/core/Lucy/Test/Search/TestPhraseQuery.cfh +++ /dev/null @@ -1,29 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Search::TestPhraseQuery - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestPhraseQuery* - new(); - - void - Run(TestPhraseQuery *self, TestBatchRunner *runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Search/TestPolyQuery.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Search/TestPolyQuery.c b/core/Lucy/Test/Search/TestPolyQuery.c deleted file mode 100644 index 67fe6fa..0000000 --- a/core/Lucy/Test/Search/TestPolyQuery.c +++ /dev/null @@ -1,93 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTPOLYQUERY -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" -#include <math.h> - -#include "Clownfish/TestHarness/TestBatchRunner.h" -#include "Lucy/Test.h" -#include "Lucy/Test/TestUtils.h" -#include "Lucy/Test/Search/TestPolyQuery.h" -#include "Lucy/Search/ANDQuery.h" -#include "Lucy/Search/ORQuery.h" -#include "Lucy/Search/PolyQuery.h" -#include "Lucy/Search/LeafQuery.h" -#include "Lucy/Util/Freezer.h" - -TestANDQuery* -TestANDQuery_new() { - return (TestANDQuery*)Class_Make_Obj(TESTANDQUERY); -} - -TestORQuery* -TestORQuery_new() { - return (TestORQuery*)Class_Make_Obj(TESTORQUERY); -} - -static void -test_Dump_Load_and_Equals(TestBatchRunner *runner, uint32_t boolop) { - LeafQuery *a_leaf = TestUtils_make_leaf_query(NULL, "a"); - LeafQuery *b_leaf = TestUtils_make_leaf_query(NULL, "b"); - LeafQuery *c_leaf = TestUtils_make_leaf_query(NULL, "c"); - PolyQuery *query - = (PolyQuery*)TestUtils_make_poly_query(boolop, INCREF(a_leaf), - INCREF(b_leaf), NULL); - PolyQuery *kids_differ - = (PolyQuery*)TestUtils_make_poly_query(boolop, INCREF(a_leaf), - INCREF(b_leaf), - INCREF(c_leaf), - NULL); - PolyQuery *boost_differs - = (PolyQuery*)TestUtils_make_poly_query(boolop, INCREF(a_leaf), - INCREF(b_leaf), NULL); - Obj *dump = (Obj*)PolyQuery_Dump(query); - PolyQuery *clone = (PolyQuery*)Freezer_load(dump); - - TEST_FALSE(runner, PolyQuery_Equals(query, (Obj*)kids_differ), - "Different kids spoil Equals"); - TEST_TRUE(runner, PolyQuery_Equals(query, (Obj*)boost_differs), - "Equals with identical boosts"); - PolyQuery_Set_Boost(boost_differs, 1.5); - TEST_FALSE(runner, PolyQuery_Equals(query, (Obj*)boost_differs), - "Different boost spoils Equals"); - TEST_TRUE(runner, PolyQuery_Equals(query, (Obj*)clone), - "Dump => Load round trip"); - - DECREF(a_leaf); - DECREF(b_leaf); - DECREF(c_leaf); - DECREF(query); - DECREF(kids_differ); - DECREF(boost_differs); - DECREF(dump); - DECREF(clone); -} - -void -TestANDQuery_Run_IMP(TestANDQuery *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 4); - test_Dump_Load_and_Equals(runner, BOOLOP_AND); -} - -void -TestORQuery_Run_IMP(TestORQuery *self, TestBatchRunner *runner) { - TestBatchRunner_Plan(runner, (TestBatch*)self, 4); - test_Dump_Load_and_Equals(runner, BOOLOP_OR); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Search/TestPolyQuery.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Search/TestPolyQuery.cfh b/core/Lucy/Test/Search/TestPolyQuery.cfh deleted file mode 100644 index 3e4a42d..0000000 --- a/core/Lucy/Test/Search/TestPolyQuery.cfh +++ /dev/null @@ -1,39 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -class Lucy::Test::Search::TestANDQuery - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestANDQuery* - new(); - - void - Run(TestANDQuery *self, TestBatchRunner *runner); -} - -class Lucy::Test::Search::TestORQuery - inherits Clownfish::TestHarness::TestBatch { - - inert incremented TestORQuery* - new(); - - void - Run(TestORQuery *self, TestBatchRunner *runner); -} - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Search/TestQueryParser.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Search/TestQueryParser.c b/core/Lucy/Test/Search/TestQueryParser.c deleted file mode 100644 index 57dcd17..0000000 --- a/core/Lucy/Test/Search/TestQueryParser.c +++ /dev/null @@ -1,81 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define C_TESTLUCY_TESTQUERYPARSER -#define TESTLUCY_USE_SHORT_NAMES -#include "Lucy/Util/ToolSet.h" -#include <string.h> - -#include "Clownfish/TestHarness/TestUtils.h" -#include "Lucy/Test/Search/TestQueryParser.h" -#include "Lucy/Test/TestUtils.h" -#include "Lucy/Search/TermQuery.h" -#include "Lucy/Search/PhraseQuery.h" -#include "Lucy/Search/LeafQuery.h" -#include "Lucy/Search/ANDQuery.h" -#include "Lucy/Search/NOTQuery.h" -#include "Lucy/Search/ORQuery.h" - -TestQueryParser* -TestQP_new(const char *query_string, Query *tree, Query *expanded, - uint32_t num_hits) { - TestQueryParser *self - = (TestQueryParser*)Class_Make_Obj(TESTQUERYPARSER); - return TestQP_init(self, query_string, tree, expanded, num_hits); -} - -TestQueryParser* -TestQP_init(TestQueryParser *self, const char *query_string, Query *tree, - Query *expanded, uint32_t num_hits) { - TestQueryParserIVARS *const ivars = TestQP_IVARS(self); - ivars->query_string = query_string ? TestUtils_get_str(query_string) : NULL; - ivars->tree = tree ? tree : NULL; - ivars->expanded = expanded ? expanded : NULL; - ivars->num_hits = num_hits; - return self; -} - -void -TestQP_Destroy_IMP(TestQueryParser *self) { - TestQueryParserIVARS *const ivars = TestQP_IVARS(self); - DECREF(ivars->query_string); - DECREF(ivars->tree); - DECREF(ivars->expanded); - SUPER_DESTROY(self, TESTQUERYPARSER); -} - -String* -TestQP_Get_Query_String_IMP(TestQueryParser *self) { - return TestQP_IVARS(self)->query_string; -} - -Query* -TestQP_Get_Tree_IMP(TestQueryParser *self) { - return TestQP_IVARS(self)->tree; -} - -Query* -TestQP_Get_Expanded_IMP(TestQueryParser *self) { - return TestQP_IVARS(self)->expanded; -} - -uint32_t -TestQP_Get_Num_Hits_IMP(TestQueryParser *self) { - return TestQP_IVARS(self)->num_hits; -} - - - http://git-wip-us.apache.org/repos/asf/lucy/blob/572d3564/core/Lucy/Test/Search/TestQueryParser.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Search/TestQueryParser.cfh b/core/Lucy/Test/Search/TestQueryParser.cfh deleted file mode 100644 index 4c900d5..0000000 --- a/core/Lucy/Test/Search/TestQueryParser.cfh +++ /dev/null @@ -1,61 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -parcel TestLucy; - -/** Test case object for QueryParser unit tests. - */ - -class Lucy::Test::Search::TestQueryParser nickname TestQP - inherits Clownfish::Obj { - - String *query_string; - Query *tree; - Query *expanded; - uint32_t num_hits; - - /** Note that unlike most Clownfish constructors, this routine will consume one - * reference count each for `tree`, and `expanded`. - */ - inert incremented TestQueryParser* - new(const char *query_string = NULL, Query *tree = NULL, - Query *expanded = NULL, uint32_t num_hits); - - inert TestQueryParser* - init(TestQueryParser *self, const char *query_string = NULL, - Query *tree = NULL, Query *expanded = NULL, uint32_t num_hits); - - nullable String* - Get_Query_String(TestQueryParser *self); - - nullable Query* - Get_Tree(TestQueryParser *self); - - nullable Query* - Get_Expanded(TestQueryParser *self); - - uint32_t - Get_Num_Hits(TestQueryParser *self); - - public void - Destroy(TestQueryParser *self); -} - -__C__ - -__END_C__ - -