You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by di...@apache.org on 2011/05/16 08:15:29 UTC

[Lucene.Net] svn commit: r1103617 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/Regex: ./ Contrib.Regex.Test.csproj Properties/ Properties/AssemblyInfo.cs TestRegexpQuery.cs

Author: digy
Date: Mon May 16 06:15:29 2011
New Revision: 1103617

URL: http://svn.apache.org/viewvc?rev=1103617&view=rev
Log:
[LUCENENET-412] broken regex build

Added:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/Regex/
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/Regex/Contrib.Regex.Test.csproj
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/Regex/Properties/
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/Regex/Properties/AssemblyInfo.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/Regex/TestRegexpQuery.cs

Added: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/Regex/Contrib.Regex.Test.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/Regex/Contrib.Regex.Test.csproj?rev=1103617&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/Regex/Contrib.Regex.Test.csproj (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/Regex/Contrib.Regex.Test.csproj Mon May 16 06:15:29 2011
@@ -0,0 +1,65 @@
+<?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\contrib\Regex\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="nunit.framework">
+      <HintPath>..\..\..\lib\NUnit.org\NUnit\2.5.9\bin\net-2.0\nunit.framework.dll</HintPath>
+    </Reference>
+    <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>
+    <ProjectReference Include="..\..\core\Lucene.Net.Test.csproj">
+      <Project>{AAF68BCF-F781-45FC-98B3-2B9CEE411E01}</Project>
+      <Name>Lucene.Net.Test</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/branches/Lucene.Net_2_9_4g/test/contrib/Regex/Properties/AssemblyInfo.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/Regex/Properties/AssemblyInfo.cs?rev=1103617&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/Regex/Properties/AssemblyInfo.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/Regex/Properties/AssemblyInfo.cs Mon May 16 06:15:29 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/branches/Lucene.Net_2_9_4g/test/contrib/Regex/TestRegexpQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/Regex/TestRegexpQuery.cs?rev=1103617&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/Regex/TestRegexpQuery.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/contrib/Regex/TestRegexpQuery.cs Mon May 16 06:15:29 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"));
+        }
+    }
+
+}