Author: logie
Date: Wed Mar 21 00:05:26 2012
New Revision: 1303225
URL: http://svn.apache.org/viewvc?rev=1303225&view=rev
Log:
LUCY-214
Initial attempt at porting perl terminfo.t over to C.
Added:
incubator/lucy/trunk/core/Lucy/Test/Index/TestTermInfo.c
incubator/lucy/trunk/core/Lucy/Test/Index/TestTermInfo.cfh
incubator/lucy/trunk/perl/t/core/208-terminfo.t
Removed:
incubator/lucy/trunk/perl/t/208-terminfo.t
Modified:
incubator/lucy/trunk/perl/MANIFEST
incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Misc.pm
Added: incubator/lucy/trunk/core/Lucy/Test/Index/TestTermInfo.c
URL:
http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Index/TestTermInfo.c?rev=1303225&view=auto
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Index/TestTermInfo.c (added)
+++ incubator/lucy/trunk/core/Lucy/Test/Index/TestTermInfo.c Wed Mar 21
00:05:26 2012
@@ -0,0 +1,64 @@
+/* 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_LUCY_TESTTERMINFO
+#include "Lucy/Util/ToolSet.h"
+
+#include "Lucy/Test.h"
+#include "Lucy/Test/Index/TestTermInfo.h"
+#include "Lucy/Index/TermInfo.h"
+
+void
+test_freqfilepos(TestBatch *batch) {
+ TermInfo* tinfo = TInfo_new(10);
+ TInfo_set_post_filepos(tinfo, 20);
+ TInfo_set_skip_filepos(tinfo, 40);
+ TInfo_set_lex_filepos(tinfo, 50);
+
+ TermInfo* cloned_tinfo = TInfo_clone(tinfo);
+
+ TEST_FALSE(batch, Lucy_TInfo_Equals(tinfo, (lucy_Obj*)cloned_tinfo),"the
clone should be a separate C struct");
+ TEST_INT_EQ(batch, TInfo_get_doc_freq(tinfo), 10, "new sets doc_freq
correctly" );
+ TEST_INT_EQ(batch, TInfo_get_doc_freq(tinfo), 10, "... doc_freq cloned" );
+ TEST_INT_EQ(batch, TInfo_get_post_filepos(tinfo), 20, "... post_filepos
cloned" );
+ TEST_INT_EQ(batch, TInfo_get_skip_filepos(tinfo), 40, "... skip_filepos
cloned" );
+ TEST_INT_EQ(batch, TInfo_get_lex_filepos(tinfo), 50, "... lex_filepos
cloned" );
+
+ TInfo_set_doc_freq(tinfo, 5);
+ TEST_INT_EQ(batch, TInfo_get_doc_freq(tinfo), 5, "set/get doc_freq" );
+ TEST_INT_EQ(batch, TInfo_get_doc_freq(cloned_tinfo), 10, "setting orig
doesn't affect clone" );
+
+ TInfo_set_post_filepos(tinfo, 15);
+ TEST_INT_EQ(batch, TInfo_get_post_filepos(tinfo), 15, "set/get
post_filepos" );
+
+ TInfo_set_skip_filepos(tinfo, 35);
+ TEST_INT_EQ(batch, TInfo_get_skip_filepos(tinfo), 35, "set/get
skip_filepos" );
+
+ TInfo_set_lex_filepos(tinfo, 45);
+ TEST_INT_EQ(batch, TInfo_get_lex_filepos(tinfo), 45, "set/get lex_filepos"
);
+
+ DECREF(tinfo);
+ DECREF(cloned_tinfo);
+}
+
+void
+TestTermInfo_run_tests() {
+ TestBatch *batch = TestBatch_new(11);
+ TestBatch_Plan(batch);
+ test_freqfilepos(batch);
+
+ DECREF(batch);
+}
Added: incubator/lucy/trunk/core/Lucy/Test/Index/TestTermInfo.cfh
URL:
http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Index/TestTermInfo.cfh?rev=1303225&view=auto
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Index/TestTermInfo.cfh (added)
+++ incubator/lucy/trunk/core/Lucy/Test/Index/TestTermInfo.cfh Wed Mar 21
00:05:26 2012
@@ -0,0 +1,24 @@
+/* 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 Lucy;
+
+inert class Lucy::Test::Index::TestTermInfo {
+ inert void
+ run_tests();
+}
+
+
Modified: incubator/lucy/trunk/perl/MANIFEST
URL:
http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/MANIFEST?rev=1303225&r1=1303224&r2=1303225&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/MANIFEST (original)
+++ incubator/lucy/trunk/perl/MANIFEST Wed Mar 21 00:05:26 2012
@@ -249,7 +249,6 @@ t/201-hit_doc.t
t/204-doc_reader.t
t/205-seg_reader.t
t/207-seg_lexicon.t
-t/208-terminfo.t
t/209-seg_lexicon_heavy.t
t/210-deldocs.t
t/211-seg_posting_list.t
@@ -378,6 +377,7 @@ t/core/156-snowball_stemmer.t
t/core/157-normalizer.t
t/core/158-standard_tokenizer.t
t/core/206-snapshot.t
+t/core/208-terminfo.t
t/core/216-schema.t
t/core/220-doc_writer.t
t/core/221-highlight_writer.t
Modified: incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Misc.pm
URL:
http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Misc.pm?rev=1303225&r1=1303224&r2=1303225&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Misc.pm (original)
+++ incubator/lucy/trunk/perl/buildlib/Lucy/Build/Binding/Misc.pm Wed Mar 21
00:05:26 2012
@@ -167,6 +167,9 @@ PPCODE:
else if (strEQ(package, "TestSnapshot")) {
lucy_TestSnapshot_run_tests();
}
+ else if (strEQ(package, "TestTermInfo")) {
+ lucy_TestTermInfo_run_tests();
+ }
// Lucy::Search
else if (strEQ(package, "TestANDQuery")) {
lucy_TestANDQuery_run_tests();
Added: incubator/lucy/trunk/perl/t/core/208-terminfo.t
URL:
http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/t/core/208-terminfo.t?rev=1303225&view=auto
==============================================================================
--- incubator/lucy/trunk/perl/t/core/208-terminfo.t (added)
+++ incubator/lucy/trunk/perl/t/core/208-terminfo.t Wed Mar 21 00:05:26 2012
@@ -0,0 +1,21 @@
+# 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.
+
+use strict;
+use warnings;
+
+use Lucy::Test;
+Lucy::Test::run_tests("TestTermInfo");
+