You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2010/11/23 00:14:04 UTC
[lucy-commits] svn commit: r1037932 - in /incubator/lucy/trunk:
core/Lucy/Test/Analysis/TestAnalyzer.c
core/Lucy/Test/Analysis/TestAnalyzer.cfh perl/lib/Lucy/Test.pm
perl/t/core/150-analyzer.t
Author: marvin
Date: Mon Nov 22 23:14:04 2010
New Revision: 1037932
URL: http://svn.apache.org/viewvc?rev=1037932&view=rev
Log:
Port basic tests for abstract Analyzer class to C.
Added:
incubator/lucy/trunk/core/Lucy/Test/Analysis/TestAnalyzer.c
incubator/lucy/trunk/core/Lucy/Test/Analysis/TestAnalyzer.cfh
incubator/lucy/trunk/perl/t/core/150-analyzer.t
Modified:
incubator/lucy/trunk/perl/lib/Lucy/Test.pm
Added: incubator/lucy/trunk/core/Lucy/Test/Analysis/TestAnalyzer.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Analysis/TestAnalyzer.c?rev=1037932&view=auto
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Analysis/TestAnalyzer.c (added)
+++ incubator/lucy/trunk/core/Lucy/Test/Analysis/TestAnalyzer.c Mon Nov 22 23:14:04 2010
@@ -0,0 +1,69 @@
+/* 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.
+ */
+
+#include "Lucy/Util/ToolSet.h"
+
+#include "Lucy/Test.h"
+#include "Lucy/Test/TestUtils.h"
+#include "Lucy/Test/Analysis/TestAnalyzer.h"
+#include "Lucy/Analysis/Analyzer.h"
+#include "Lucy/Analysis/Inversion.h"
+
+DummyAnalyzer*
+DummyAnalyzer_new()
+{
+ DummyAnalyzer *self = (DummyAnalyzer*)VTable_Make_Obj(DUMMYANALYZER);
+ return DummyAnalyzer_init(self);
+}
+
+DummyAnalyzer*
+DummyAnalyzer_init(DummyAnalyzer *self)
+{
+ return (DummyAnalyzer*)Analyzer_init((Analyzer*)self);
+}
+
+Inversion*
+DummyAnalyzer_transform(DummyAnalyzer *self, Inversion *inversion)
+{
+ UNUSED_VAR(self);
+ return (Inversion*)INCREF(inversion);
+}
+
+static void
+test_analysis(TestBatch *batch)
+{
+ DummyAnalyzer *analyzer = DummyAnalyzer_new();
+ CharBuf *source = CB_newf("foo bar baz");
+ VArray *wanted = VA_new(1);
+ VA_Push(wanted, (Obj*)CB_newf("foo bar baz"));
+ TestUtils_test_analyzer(batch, (Analyzer*)analyzer, source, wanted,
+ "test basic analysis");
+}
+
+void
+TestAnalyzer_run_tests()
+{
+ TestBatch *batch = TestBatch_new(3);
+
+ TestBatch_Plan(batch);
+
+ test_analysis(batch);
+
+ DECREF(batch);
+}
+
+
+
Added: incubator/lucy/trunk/core/Lucy/Test/Analysis/TestAnalyzer.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Test/Analysis/TestAnalyzer.cfh?rev=1037932&view=auto
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Test/Analysis/TestAnalyzer.cfh (added)
+++ incubator/lucy/trunk/core/Lucy/Test/Analysis/TestAnalyzer.cfh Mon Nov 22 23:14:04 2010
@@ -0,0 +1,34 @@
+/* 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::Analysis::TestAnalyzer {
+ inert void
+ run_tests();
+}
+
+class Lucy::Test::Analysis::DummyAnalyzer inherits Lucy::Analysis::Analyzer {
+ inert incremented DummyAnalyzer*
+ new();
+
+ inert DummyAnalyzer*
+ init(DummyAnalyzer *self);
+
+ public incremented Inversion*
+ Transform(DummyAnalyzer *self, Inversion *inversion);
+}
+
Modified: incubator/lucy/trunk/perl/lib/Lucy/Test.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/lib/Lucy/Test.pm?rev=1037932&r1=1037931&r2=1037932&view=diff
==============================================================================
--- incubator/lucy/trunk/perl/lib/Lucy/Test.pm (original)
+++ incubator/lucy/trunk/perl/lib/Lucy/Test.pm Mon Nov 22 23:14:04 2010
@@ -43,7 +43,10 @@ run_tests(package)
PPCODE:
{
// Lucy::Analysis
- if (strEQ(package, "TestCaseFolder")) {
+ if (strEQ(package, "TestAnalyzer")) {
+ lucy_TestAnalyzer_run_tests();
+ }
+ else if (strEQ(package, "TestCaseFolder")) {
lucy_TestCaseFolder_run_tests();
}
else if (strEQ(package, "TestPolyAnalyzer")) {
Added: incubator/lucy/trunk/perl/t/core/150-analyzer.t
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/perl/t/core/150-analyzer.t?rev=1037932&view=auto
==============================================================================
--- incubator/lucy/trunk/perl/t/core/150-analyzer.t (added)
+++ incubator/lucy/trunk/perl/t/core/150-analyzer.t Mon Nov 22 23:14:04 2010
@@ -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("TestAnalyzer");
+