lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnas...@apache.org
Subject [Lucene.Net] svn commit: r1102186 - in /incubator/lucene.net/trunk: build/vs2010/test/ test/contrib/Regex/ test/contrib/Regex/Properties/
Date Thu, 12 May 2011 07:21:24 GMT
Author: pnasser
Date: Thu May 12 07:21:23 2011
New Revision: 1102186

URL: http://svn.apache.org/viewvc?rev=1102186&view=rev
Log:
LUCENENET-371 Unit test for Search.Regex port (trunk)

Added:
    incubator/lucene.net/trunk/test/contrib/Regex/
    incubator/lucene.net/trunk/test/contrib/Regex/Contrib.Regex.Test.csproj
    incubator/lucene.net/trunk/test/contrib/Regex/Properties/
    incubator/lucene.net/trunk/test/contrib/Regex/Properties/AssemblyInfo.cs
    incubator/lucene.net/trunk/test/contrib/Regex/TestRegexpQuery.cs
Modified:
    incubator/lucene.net/trunk/build/vs2010/test/Contrib.All.Test.sln

Modified: incubator/lucene.net/trunk/build/vs2010/test/Contrib.All.Test.sln
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/build/vs2010/test/Contrib.All.Test.sln?rev=1102186&r1=1102185&r2=1102186&view=diff
==============================================================================
--- incubator/lucene.net/trunk/build/vs2010/test/Contrib.All.Test.sln (original)
+++ incubator/lucene.net/trunk/build/vs2010/test/Contrib.All.Test.sln Thu May 12 07:21:23
2011
@@ -1,6 +1,6 @@
 
 Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual C# Express 2010
+# Visual Studio 2010
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net", "..\..\..\src\core\Lucene.Net.csproj",
"{5D4AD9BE-1FFB-41AB-9943-25737971BF57}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contrib.Core", "..\..\..\src\contrib\Core\Contrib.Core.csproj",
"{FEF899EB-610C-4D3C-A556-A01F56F4AFE0}"
@@ -39,6 +39,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.Common", "..\..\..\src\demo\Demo.Common\Demo.Common.csproj",
"{F04CA2F4-E182-46A8-B914-F46AF5319E83}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contrib.Regex.Test", "..\..\..\test\contrib\Regex\Contrib.Regex.Test.csproj",
"{F1875552-0E59-46AA-976E-6183733FD2AB}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contrib.Regex", "..\..\..\src\contrib\Regex\Contrib.Regex.csproj",
"{A26BD3B7-DF90-43B4-99E2-6A617CDE1579}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -121,6 +125,14 @@ Global
 		{F04CA2F4-E182-46A8-B914-F46AF5319E83}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{F04CA2F4-E182-46A8-B914-F46AF5319E83}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{F04CA2F4-E182-46A8-B914-F46AF5319E83}.Release|Any CPU.Build.0 = Release|Any CPU
+		{F1875552-0E59-46AA-976E-6183733FD2AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{F1875552-0E59-46AA-976E-6183733FD2AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{F1875552-0E59-46AA-976E-6183733FD2AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{F1875552-0E59-46AA-976E-6183733FD2AB}.Release|Any CPU.Build.0 = Release|Any CPU
+		{A26BD3B7-DF90-43B4-99E2-6A617CDE1579}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{A26BD3B7-DF90-43B4-99E2-6A617CDE1579}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{A26BD3B7-DF90-43B4-99E2-6A617CDE1579}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{A26BD3B7-DF90-43B4-99E2-6A617CDE1579}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

Added: incubator/lucene.net/trunk/test/contrib/Regex/Contrib.Regex.Test.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Regex/Contrib.Regex.Test.csproj?rev=1102186&view=auto
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Regex/Contrib.Regex.Test.csproj (added)
+++ incubator/lucene.net/trunk/test/contrib/Regex/Contrib.Regex.Test.csproj Thu May 12 07:21:23
2011
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{F1875552-0E59-46AA-976E-6183733FD2AB}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Contrib.Regex.Test</RootNamespace>
+    <AssemblyName>Contrib.Regex.Test</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\..\bin\contrib\Regex\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="TestRegexpQuery.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\src\contrib\Regex\Contrib.Regex.csproj">
+      <Project>{A26BD3B7-DF90-43B4-99E2-6A617CDE1579}</Project>
+      <Name>Contrib.Regex</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\src\core\Lucene.Net.csproj">
+      <Project>{5D4AD9BE-1FFB-41AB-9943-25737971BF57}</Project>
+      <Name>Lucene.Net</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and
uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

Added: incubator/lucene.net/trunk/test/contrib/Regex/Properties/AssemblyInfo.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Regex/Properties/AssemblyInfo.cs?rev=1102186&view=auto
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Regex/Properties/AssemblyInfo.cs (added)
+++ incubator/lucene.net/trunk/test/contrib/Regex/Properties/AssemblyInfo.cs Thu May 12 07:21:23
2011
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Lucene.Net.Contrib.Spatial")]
+[assembly: AssemblyDescription("The Apache Software Foundation Lucene.Net a full-text search
engine library")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("The Apache Software Foundation")]
+[assembly: AssemblyProduct("Lucene.Net.Contrib.Regex.Text")]
+[assembly: AssemblyCopyright("Copyright 2009 - 2011 The Apache Software Foundation")]
+[assembly: AssemblyTrademark("Copyright 2009 - 2011 The Apache Software Foundation")]
+[assembly: AssemblyDefaultAlias("Lucene.Net.Regex")]
+[assembly: AssemblyCulture("")]
+
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("aec606a7-af40-4946-9448-f048fae90fa2")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("2.9.4")]
+[assembly: AssemblyFileVersion("2.9.4")]

Added: incubator/lucene.net/trunk/test/contrib/Regex/TestRegexpQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/test/contrib/Regex/TestRegexpQuery.cs?rev=1102186&view=auto
==============================================================================
--- incubator/lucene.net/trunk/test/contrib/Regex/TestRegexpQuery.cs (added)
+++ incubator/lucene.net/trunk/test/contrib/Regex/TestRegexpQuery.cs Thu May 12 07:21:23 2011
@@ -0,0 +1,129 @@
+/* 
+ * 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.
+ */
+
+using Lucene.Net.Analysis;
+using Lucene.Net.Documents;
+using Lucene.Net.Index;
+using Lucene.Net.Search;
+using Lucene.Net.Search.Regex;
+using Lucene.Net.Store;
+using Lucene.Net.Util;
+using NUnit.Framework;
+
+
+namespace Lucene.Net.Search.Regex
+{
+    /// <summary>
+    /// See http://svn.eu.apache.org/repos/asf/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java
+    /// </summary>
+    [TestFixture]
+    public class TestRegexpQuery : LuceneTestCase
+    {
+        private IndexSearcher _searcher;
+        private const string FIELDNAME = "field";
+
+        public override void SetUp()
+        {
+            base.SetUp();
+
+            RAMDirectory directory = new RAMDirectory();
+            IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+
+            Document doc = new Document();
+            doc.Add(new Field(FIELDNAME, "the quick brown fox jumps over the lazy crazy pretty
dog",
+                Field.Store.NO, Field.Index.ANALYZED));
+            writer.AddDocument(doc);
+            writer.Optimize();
+            writer.Close();
+            _searcher = new IndexSearcher(directory, true);
+        }
+
+        public override void TearDown()
+        {
+            _searcher.Close();
+            base.TearDown();
+        }
+
+        private static Term NewTerm(string sValue)
+        {
+            return new Term(FIELDNAME, sValue);
+        }
+
+        private int GetRegexQueryHitsCount(string sRegex)
+        {
+            RegexQuery query = new RegexQuery(NewTerm(sRegex));
+            return _searcher.Search(query, 5).totalHits;
+        }
+
+        [Test]
+        public void TestLiterals()
+        {
+            Assert.AreEqual(0, GetRegexQueryHitsCount(@"nothing"));
+
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"brown"));
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"ver"));
+
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"the"));
+        }
+
+        [Test]
+        public void TestExpressions()
+        {
+            // wildcards
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"j.mps"));
+
+            // repetitions
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"dogs?"));
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"pret+y"));
+
+            // classes
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"q.[aeiou]c.*"));
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"br?own?"));
+            Assert.AreEqual(0, GetRegexQueryHitsCount(@"z.[aeiou]c.*"));
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"c?[rl]azy"));
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"\bc?[rl]azy\b"));
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"c[^lmn]azy"));
+            Assert.AreEqual(0, GetRegexQueryHitsCount(@"c[^r]azy"));
+
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"\p{L}+"));
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"\p{L}{6,}"));
+            Assert.AreEqual(0, GetRegexQueryHitsCount(@"\p{L}{7,}"));
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"\p{L}{6,7}"));
+            Assert.AreEqual(0, GetRegexQueryHitsCount(@"\p{L}{7,9}"));
+
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"\D+"));
+            Assert.AreEqual(0, GetRegexQueryHitsCount(@"\d+"));
+
+            // position
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"^q"));
+            Assert.AreEqual(0, GetRegexQueryHitsCount(@"q$"));
+
+            // alternatives
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"brown|red"));
+            Assert.AreEqual(0, GetRegexQueryHitsCount(@"yellow|red"));
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"(l|cr)azy"));
+
+            // lookaround
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"\b\w+(?=zy)"));
+            Assert.AreEqual(0, GetRegexQueryHitsCount(@"\b\w+(?=zu)"));
+
+            Assert.AreEqual(0, GetRegexQueryHitsCount(@"\b\w*q[^u]\w*\b"));
+            Assert.AreEqual(1, GetRegexQueryHitsCount(@"\b\w*qu\w*\b"));
+        }
+    }
+
+}



Mime
View raw message