You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2015/12/14 14:44:13 UTC
lucenenet git commit: Tests for character utils
Repository: lucenenet
Updated Branches:
refs/heads/master 092aab40f -> 8cef92b2f
Tests for character utils
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/8cef92b2
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/8cef92b2
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/8cef92b2
Branch: refs/heads/master
Commit: 8cef92b2f8f98d1e04f8978edb41488c789e9608
Parents: 092aab4
Author: Laimonas Simutis <la...@gmail.com>
Authored: Sat Dec 12 09:17:50 2015 -0500
Committer: Laimonas Simutis <la...@gmail.com>
Committed: Sat Dec 12 09:17:50 2015 -0500
----------------------------------------------------------------------
Lucene.Net.sln | 28 +-
.../Lucene.Net.Analysis.Common.csproj | 190 +------
src/Lucene.Net.Core/Support/Character.cs | 62 +++
.../Analysis/Util/TestCharacterUtils.cs | 532 +++++++++----------
.../Lucene.Net.Tests.Analysis.Common.csproj | 9 +
5 files changed, 347 insertions(+), 474 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8cef92b2/Lucene.Net.sln
----------------------------------------------------------------------
diff --git a/Lucene.Net.sln b/Lucene.Net.sln
index debbc08..baeedad 100644
--- a/Lucene.Net.sln
+++ b/Lucene.Net.sln
@@ -1,8 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.23107.0
-MinimumVisualStudioVersion = 10.0.40219.1
+# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net", "src\Lucene.Net.Core\Lucene.Net.csproj", "{5D4AD9BE-1FFB-41AB-9943-25737971BF57}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Tests", "src\Lucene.Net.Tests\Lucene.Net.Tests.csproj", "{DE63DB10-975F-460D-AF85-572C17A91284}"
@@ -44,6 +42,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Grouping", "src\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Tests.Join", "src\Lucene.Net.Tests.Join\Lucene.Net.Tests.Join.csproj", "{4C1B794F-8158-45E6-85B3-2C46569BEBC2}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Analysis.Common", "src\Lucene.Net.Analysis.Common\Lucene.Net.Analysis.Common.csproj", "{4ADD0BBC-B900-4715-9526-D871DE8EEA64}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Tests.Analysis.Common", "src\Lucene.Net.Tests.Analysis.Common\Lucene.Net.Tests.Analysis.Common.csproj", "{C54FE8FA-7986-4C94-B872-D5BFF7C6C74E}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -221,6 +223,26 @@ Global
{4C1B794F-8158-45E6-85B3-2C46569BEBC2}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{4C1B794F-8158-45E6-85B3-2C46569BEBC2}.Release|x86.ActiveCfg = Release|Any CPU
{4C1B794F-8158-45E6-85B3-2C46569BEBC2}.Release|x86.Build.0 = Release|Any CPU
+ {4ADD0BBC-B900-4715-9526-D871DE8EEA64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4ADD0BBC-B900-4715-9526-D871DE8EEA64}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4ADD0BBC-B900-4715-9526-D871DE8EEA64}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {4ADD0BBC-B900-4715-9526-D871DE8EEA64}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {4ADD0BBC-B900-4715-9526-D871DE8EEA64}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {4ADD0BBC-B900-4715-9526-D871DE8EEA64}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4ADD0BBC-B900-4715-9526-D871DE8EEA64}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4ADD0BBC-B900-4715-9526-D871DE8EEA64}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {4ADD0BBC-B900-4715-9526-D871DE8EEA64}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {4ADD0BBC-B900-4715-9526-D871DE8EEA64}.Release|x86.ActiveCfg = Release|Any CPU
+ {C54FE8FA-7986-4C94-B872-D5BFF7C6C74E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C54FE8FA-7986-4C94-B872-D5BFF7C6C74E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C54FE8FA-7986-4C94-B872-D5BFF7C6C74E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {C54FE8FA-7986-4C94-B872-D5BFF7C6C74E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {C54FE8FA-7986-4C94-B872-D5BFF7C6C74E}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {C54FE8FA-7986-4C94-B872-D5BFF7C6C74E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C54FE8FA-7986-4C94-B872-D5BFF7C6C74E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C54FE8FA-7986-4C94-B872-D5BFF7C6C74E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {C54FE8FA-7986-4C94-B872-D5BFF7C6C74E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {C54FE8FA-7986-4C94-B872-D5BFF7C6C74E}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8cef92b2/src/Lucene.Net.Analysis.Common/Lucene.Net.Analysis.Common.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Lucene.Net.Analysis.Common.csproj b/src/Lucene.Net.Analysis.Common/Lucene.Net.Analysis.Common.csproj
index 630a364..ff84887 100644
--- a/src/Lucene.Net.Analysis.Common/Lucene.Net.Analysis.Common.csproj
+++ b/src/Lucene.Net.Analysis.Common/Lucene.Net.Analysis.Common.csproj
@@ -35,193 +35,9 @@
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
- <Compile Include="Analysis\CharFilter\BaseCharFilter.cs" />
- <Compile Include="Analysis\CharFilter\HTMLStripCharFilterFactory.cs" />
- <Compile Include="Analysis\CharFilter\MappingCharFilter.cs" />
- <Compile Include="Analysis\CharFilter\MappingCharFilterFactory.cs" />
- <Compile Include="Analysis\CharFilter\NormalizeCharMap.cs" />
- <Compile Include="Analysis\CommonGrams\CommonGramsFilter.cs" />
- <Compile Include="Analysis\CommonGrams\CommonGramsFilterFactory.cs" />
- <Compile Include="Analysis\CommonGrams\CommonGramsQueryFilter.cs" />
- <Compile Include="Analysis\CommonGrams\CommonGramsQueryFilterFactory.cs" />
- <Compile Include="Analysis\Compound\CompoundWordTokenFilterBase.cs" />
- <Compile Include="Analysis\Compound\DictionaryCompoundWordTokenFilter.cs" />
- <Compile Include="Analysis\Compound\DictionaryCompoundWordTokenFilterFactory.cs" />
- <Compile Include="Analysis\Compound\HyphenationCompoundWordTokenFilter.cs" />
- <Compile Include="Analysis\Compound\HyphenationCompoundWordTokenFilterFactory.cs" />
- <Compile Include="Analysis\Compound\Hyphenation\ByteVector.cs" />
- <Compile Include="Analysis\Compound\Hyphenation\CharVector.cs" />
- <Compile Include="Analysis\Compound\Hyphenation\Hyphen.cs" />
- <Compile Include="Analysis\Compound\Hyphenation\Hyphenation.cs" />
- <Compile Include="Analysis\Compound\Hyphenation\HyphenationTree.cs" />
- <Compile Include="Analysis\Compound\Hyphenation\PatternConsumer.cs" />
- <Compile Include="Analysis\Compound\Hyphenation\PatternParser.cs" />
- <Compile Include="Analysis\Compound\Hyphenation\TernaryTree.cs" />
- <Compile Include="Analysis\Core\KeywordAnalyzer.cs" />
- <Compile Include="Analysis\Core\KeywordTokenizer.cs" />
- <Compile Include="Analysis\Core\KeywordTokenizerFactory.cs" />
- <Compile Include="Analysis\Core\LetterTokenizer.cs" />
- <Compile Include="Analysis\Core\LetterTokenizerFactory.cs" />
- <Compile Include="Analysis\Core\LowerCaseFilter.cs" />
- <Compile Include="Analysis\Core\LowerCaseFilterFactory.cs" />
- <Compile Include="Analysis\Core\LowerCaseTokenizer.cs" />
- <Compile Include="Analysis\Core\LowerCaseTokenizerFactory.cs" />
- <Compile Include="Analysis\Core\SimpleAnalyzer.cs" />
- <Compile Include="Analysis\Core\StopAnalyzer.cs" />
- <Compile Include="Analysis\Core\StopFilter.cs" />
- <Compile Include="Analysis\Core\StopFilterFactory.cs" />
- <Compile Include="Analysis\Core\TypeTokenFilter.cs" />
- <Compile Include="Analysis\Core\TypeTokenFilterFactory.cs" />
- <Compile Include="Analysis\Core\UpperCaseFilter.cs" />
- <Compile Include="Analysis\Core\UpperCaseFilterFactory.cs" />
- <Compile Include="Analysis\Core\WhitespaceAnalyzer.cs" />
- <Compile Include="Analysis\Core\WhitespaceTokenizer.cs" />
- <Compile Include="Analysis\Core\WhitespaceTokenizerFactory.cs" />
- <Compile Include="Analysis\Miscellaneous\ASCIIFoldingFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\ASCIIFoldingFilterFactory.cs" />
- <Compile Include="Analysis\Miscellaneous\CapitalizationFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\CapitalizationFilterFactory.cs" />
- <Compile Include="Analysis\Miscellaneous\CodepointCountFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\CodepointCountFilterFactory.cs" />
- <Compile Include="Analysis\Miscellaneous\EmptyTokenStream.cs" />
- <Compile Include="Analysis\Miscellaneous\HyphenatedWordsFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\HyphenatedWordsFilterFactory.cs" />
- <Compile Include="Analysis\Miscellaneous\KeepWordFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\KeepWordFilterFactory.cs" />
- <Compile Include="Analysis\Miscellaneous\KeywordMarkerFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\KeywordMarkerFilterFactory.cs" />
- <Compile Include="Analysis\Miscellaneous\KeywordRepeatFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\KeywordRepeatFilterFactory.cs" />
- <Compile Include="Analysis\Miscellaneous\LengthFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\LengthFilterFactory.cs" />
- <Compile Include="Analysis\Miscellaneous\LimitTokenCountAnalyzer.cs" />
- <Compile Include="Analysis\Miscellaneous\LimitTokenCountFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\LimitTokenCountFilterFactory.cs" />
- <Compile Include="Analysis\Miscellaneous\LimitTokenPositionFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\LimitTokenPositionFilterFactory.cs" />
- <Compile Include="Analysis\Miscellaneous\Lucene47WordDelimiterFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\PatternAnalyzer.cs" />
- <Compile Include="Analysis\Miscellaneous\PatternKeywordMarkerFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\PerFieldAnalyzerWrapper.cs" />
- <Compile Include="Analysis\Miscellaneous\PrefixAndSuffixAwareTokenFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\PrefixAwareTokenFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\RemoveDuplicatesTokenFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\RemoveDuplicatesTokenFilterFactory.cs" />
- <Compile Include="Analysis\Miscellaneous\ScandinavianFoldingFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\ScandinavianFoldingFilterFactory.cs" />
- <Compile Include="Analysis\Miscellaneous\ScandinavianNormalizationFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\ScandinavianNormalizationFilterFactory.cs" />
- <Compile Include="Analysis\Miscellaneous\SetKeywordMarkerFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\SingleTokenTokenStream.cs" />
- <Compile Include="Analysis\Miscellaneous\StemmerOverrideFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\StemmerOverrideFilterFactory.cs" />
- <Compile Include="Analysis\Miscellaneous\TrimFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\TrimFilterFactory.cs" />
- <Compile Include="Analysis\Miscellaneous\TruncateTokenFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\TruncateTokenFilterFactory.cs" />
- <Compile Include="Analysis\Miscellaneous\WordDelimiterFilter.cs" />
- <Compile Include="Analysis\Miscellaneous\WordDelimiterFilterFactory.cs" />
- <Compile Include="Analysis\Miscellaneous\WordDelimiterIterator.cs" />
- <Compile Include="Analysis\Ngram\EdgeNGramFilterFactory.cs" />
- <Compile Include="Analysis\Ngram\EdgeNGramTokenFilter.cs" />
- <Compile Include="Analysis\Ngram\EdgeNGramTokenizer.cs" />
- <Compile Include="Analysis\Ngram\EdgeNGramTokenizerFactory.cs" />
- <Compile Include="Analysis\Ngram\Lucene43EdgeNGramTokenizer.cs" />
- <Compile Include="Analysis\Ngram\Lucene43NGramTokenizer.cs" />
- <Compile Include="Analysis\Ngram\NGramFilterFactory.cs" />
- <Compile Include="Analysis\Ngram\NGramTokenFilter.cs" />
- <Compile Include="Analysis\Ngram\NGramTokenizer.cs" />
- <Compile Include="Analysis\Ngram\NGramTokenizerFactory.cs" />
- <Compile Include="Analysis\Path\PathHierarchyTokenizer.cs" />
- <Compile Include="Analysis\Path\PathHierarchyTokenizerFactory.cs" />
- <Compile Include="Analysis\Path\ReversePathHierarchyTokenizer.cs" />
- <Compile Include="Analysis\Pattern\PatternCaptureGroupFilterFactory.cs" />
- <Compile Include="Analysis\Pattern\PatternCaptureGroupTokenFilter.cs" />
- <Compile Include="Analysis\Pattern\PatternReplaceCharFilter.cs" />
- <Compile Include="Analysis\Pattern\PatternReplaceCharFilterFactory.cs" />
- <Compile Include="Analysis\Pattern\PatternReplaceFilter.cs" />
- <Compile Include="Analysis\Pattern\PatternReplaceFilterFactory.cs" />
- <Compile Include="Analysis\Pattern\PatternTokenizer.cs" />
- <Compile Include="Analysis\Pattern\PatternTokenizerFactory.cs" />
- <Compile Include="Analysis\Payloads\AbstractEncoder.cs" />
- <Compile Include="Analysis\Payloads\DelimitedPayloadTokenFilter.cs" />
- <Compile Include="Analysis\Payloads\DelimitedPayloadTokenFilterFactory.cs" />
- <Compile Include="Analysis\Payloads\FloatEncoder.cs" />
- <Compile Include="Analysis\Payloads\IdentityEncoder.cs" />
- <Compile Include="Analysis\Payloads\IntegerEncoder.cs" />
- <Compile Include="Analysis\Payloads\NumericPayloadTokenFilter.cs" />
- <Compile Include="Analysis\Payloads\NumericPayloadTokenFilterFactory.cs" />
- <Compile Include="Analysis\Payloads\PayloadEncoder.cs" />
- <Compile Include="Analysis\Payloads\PayloadHelper.cs" />
- <Compile Include="Analysis\Payloads\TokenOffsetPayloadTokenFilter.cs" />
- <Compile Include="Analysis\Payloads\TokenOffsetPayloadTokenFilterFactory.cs" />
- <Compile Include="Analysis\Payloads\TypeAsPayloadTokenFilter.cs" />
- <Compile Include="Analysis\Payloads\TypeAsPayloadTokenFilterFactory.cs" />
- <Compile Include="Analysis\Position\PositionFilter.cs" />
- <Compile Include="Analysis\Position\PositionFilterFactory.cs" />
- <Compile Include="Analysis\Query\QueryAutoStopWordAnalyzer.cs" />
- <Compile Include="Analysis\Reverse\ReverseStringFilter.cs" />
- <Compile Include="Analysis\Reverse\ReverseStringFilterFactory.cs" />
- <Compile Include="Analysis\Shingle\ShingleAnalyzerWrapper.cs" />
- <Compile Include="Analysis\Shingle\ShingleFilter.cs" />
- <Compile Include="Analysis\Shingle\ShingleFilterFactory.cs" />
- <Compile Include="Analysis\Sinks\DateRecognizerSinkFilter.cs" />
- <Compile Include="Analysis\Sinks\TeeSinkTokenFilter.cs" />
- <Compile Include="Analysis\Sinks\TokenRangeSinkFilter.cs" />
- <Compile Include="Analysis\Sinks\TokenTypeSinkFilter.cs" />
- <Compile Include="Analysis\Standard\ClassicAnalyzer.cs" />
- <Compile Include="Analysis\Standard\ClassicFilter.cs" />
- <Compile Include="Analysis\Standard\ClassicFilterFactory.cs" />
- <Compile Include="Analysis\Standard\ClassicTokenizer.cs" />
- <Compile Include="Analysis\Standard\ClassicTokenizerFactory.cs" />
- <Compile Include="Analysis\Standard\ClassicTokenizerImpl.cs" />
- <Compile Include="Analysis\Standard\StandardAnalyzer.cs" />
- <Compile Include="Analysis\Standard\StandardFilter.cs" />
- <Compile Include="Analysis\Standard\StandardFilterFactory.cs" />
- <Compile Include="Analysis\Standard\StandardTokenizer.cs" />
- <Compile Include="Analysis\Standard\StandardTokenizerFactory.cs" />
- <Compile Include="Analysis\Standard\StandardTokenizerImpl.cs" />
- <Compile Include="Analysis\Standard\StandardTokenizerInterface.cs" />
- <Compile Include="Analysis\Standard\UAX29URLEmailAnalyzer.cs" />
- <Compile Include="Analysis\Standard\UAX29URLEmailTokenizer.cs" />
- <Compile Include="Analysis\Standard\UAX29URLEmailTokenizerFactory.cs" />
- <Compile Include="Analysis\Synonym\FSTSynonymFilterFactory.cs" />
- <Compile Include="Analysis\Synonym\SolrSynonymParser.cs" />
- <Compile Include="Analysis\Synonym\SynonymFilter.cs" />
- <Compile Include="Analysis\Synonym\SynonymFilterFactory.cs" />
- <Compile Include="Analysis\Synonym\SynonymMap.cs" />
- <Compile Include="Analysis\Synonym\WordnetSynonymParser.cs" />
- <Compile Include="Analysis\Util\AbstractAnalysisFactory.cs" />
- <Compile Include="Analysis\Util\AnalysisSPILoader.cs" />
- <Compile Include="Analysis\Util\CharacterUtils.cs" />
- <Compile Include="Analysis\Util\CharArrayIterator.cs" />
- <Compile Include="Analysis\Util\CharArrayMap.cs" />
- <Compile Include="Analysis\Util\CharArraySet.cs" />
- <Compile Include="Analysis\Util\CharFilterFactory.cs" />
- <Compile Include="Analysis\Util\CharTokenizer.cs" />
- <Compile Include="Analysis\Util\ClasspathResourceLoader.cs" />
- <Compile Include="Analysis\Util\ElisionFilter.cs" />
- <Compile Include="Analysis\Util\ElisionFilterFactory.cs" />
- <Compile Include="Analysis\Util\FilesystemResourceLoader.cs" />
- <Compile Include="Analysis\Util\FilteringTokenFilter.cs" />
- <Compile Include="Analysis\Util\MultiTermAwareComponent.cs" />
- <Compile Include="Analysis\Util\OpenStringBuilder.cs" />
- <Compile Include="Analysis\Util\ResourceLoader.cs" />
- <Compile Include="Analysis\Util\ResourceLoaderAware.cs" />
- <Compile Include="Analysis\Util\RollingCharBuffer.cs" />
- <Compile Include="Analysis\Util\SegmentingTokenizerBase.cs" />
- <Compile Include="Analysis\Util\StemmerUtil.cs" />
- <Compile Include="Analysis\Util\StopwordAnalyzerBase.cs" />
- <Compile Include="Analysis\Util\TokenFilterFactory.cs" />
- <Compile Include="Analysis\Util\TokenizerFactory.cs" />
- <Compile Include="Analysis\Util\WordlistLoader.cs" />
- <Compile Include="Analysis\Wikipedia\WikipediaTokenizer.cs" />
- <Compile Include="Analysis\Wikipedia\WikipediaTokenizerFactory.cs" />
- <Compile Include="Collation\CollationAttributeFactory.cs" />
- <Compile Include="Collation\CollationKeyAnalyzer.cs" />
- <Compile Include="Collation\CollationKeyFilter.cs" />
- <Compile Include="Collation\CollationKeyFilterFactory.cs" />
- <Compile Include="Collation\TokenAttributes\CollatedTermAttributeImpl.cs" />
+ <Compile Include="Analysis\Util\CharacterUtils.cs">
+ <SubType>Code</SubType>
+ </Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8cef92b2/src/Lucene.Net.Core/Support/Character.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/Character.cs b/src/Lucene.Net.Core/Support/Character.cs
index f1bd183..134ded7 100644
--- a/src/Lucene.Net.Core/Support/Character.cs
+++ b/src/Lucene.Net.Core/Support/Character.cs
@@ -158,6 +158,13 @@ namespace Lucene.Net.Support
return c1;
}
+ public static int CodePointAt(char high, char low)
+ {
+ return ((high << 10) + low) + (MIN_SUPPLEMENTARY_CODE_POINT
+ - (MIN_HIGH_SURROGATE << 10)
+ - MIN_LOW_SURROGATE);
+ }
+
public static int CodePointAt(ICharSequence seq, int index)
{
char c1 = seq.CharAt(index++);
@@ -201,5 +208,60 @@ namespace Lucene.Net.Support
}
return c1;
}
+
+ /// <summary>
+ /// Copy of the implementation from Character class in Java
+ ///
+ /// http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b27/java/lang/Character.java
+ /// </summary>
+ public static int OffsetByCodePoints(char[] a, int start, int count,
+ int index, int codePointOffset)
+ {
+ if (count > a.Length - start || start < 0 || count < 0
+ || index < start || index > start + count)
+ {
+ throw new IndexOutOfRangeException();
+ }
+ return OffsetByCodePointsImpl(a, start, count, index, codePointOffset);
+ }
+
+ static int OffsetByCodePointsImpl(char[] a, int start, int count,
+ int index, int codePointOffset)
+ {
+ int x = index;
+ if (codePointOffset >= 0)
+ {
+ int limit = start + count;
+ int i;
+ for (i = 0; x < limit && i < codePointOffset; i++)
+ {
+ if (Char.IsHighSurrogate(a[x++]) && x < limit && Char.IsLowSurrogate(a[x]))
+ {
+ x++;
+ }
+ }
+ if (i < codePointOffset)
+ {
+ throw new IndexOutOfRangeException();
+ }
+ }
+ else
+ {
+ int i;
+ for (i = codePointOffset; x > start && i < 0; i++)
+ {
+ if (Char.IsLowSurrogate(a[--x]) && x > start &&
+ Char.IsHighSurrogate(a[x - 1]))
+ {
+ x--;
+ }
+ }
+ if (i < 0)
+ {
+ throw new IndexOutOfRangeException();
+ }
+ }
+ return x;
+ }
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8cef92b2/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharacterUtils.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharacterUtils.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharacterUtils.cs
index fb0fd6e..7b94e9d 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharacterUtils.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharacterUtils.cs
@@ -1,290 +1,254 @@
using System;
+using System.IO;
+using Lucene.Net.Analysis.Util;
+using Lucene.Net.Support;
+using Lucene.Net.Util;
+using NUnit.Framework;
-namespace org.apache.lucene.analysis.util
+namespace Lucene.Net.Tests.Analysis.Common.Analysis.Util
{
- /*
- * 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 CharacterBuffer = org.apache.lucene.analysis.util.CharacterUtils.CharacterBuffer;
- using LuceneTestCase = org.apache.lucene.util.LuceneTestCase;
- using Version = org.apache.lucene.util.Version;
- using TestUtil = org.apache.lucene.util.TestUtil;
- using Test = org.junit.Test;
-
- /// <summary>
- /// TestCase for the <seealso cref="CharacterUtils"/> class.
- /// </summary>
- public class TestCharacterUtils : LuceneTestCase
- {
-
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
-//ORIGINAL LINE: @Test public void testCodePointAtCharSequenceInt()
- public virtual void testCodePointAtCharSequenceInt()
- {
- CharacterUtils java4 = CharacterUtils.getInstance(Version.LUCENE_30);
- string cpAt3 = "Abc\ud801\udc1c";
- string highSurrogateAt3 = "Abc\ud801";
- assertEquals((int) 'A', java4.codePointAt(cpAt3, 0));
- assertEquals((int) '\ud801', java4.codePointAt(cpAt3, 3));
- assertEquals((int) '\ud801', java4.codePointAt(highSurrogateAt3, 3));
- try
- {
- java4.codePointAt(highSurrogateAt3, 4);
- fail("string index out of bounds");
- }
- catch (System.IndexOutOfRangeException)
- {
- }
-
- CharacterUtils java5 = CharacterUtils.getInstance(TEST_VERSION_CURRENT);
- assertEquals((int) 'A', java5.codePointAt(cpAt3, 0));
- assertEquals(char.toCodePoint('\ud801', '\udc1c'), java5.codePointAt(cpAt3, 3));
- assertEquals((int) '\ud801', java5.codePointAt(highSurrogateAt3, 3));
- try
- {
- java5.codePointAt(highSurrogateAt3, 4);
- fail("string index out of bounds");
- }
- catch (System.IndexOutOfRangeException)
- {
- }
-
- }
-
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
-//ORIGINAL LINE: @Test public void testCodePointAtCharArrayIntInt()
- public virtual void testCodePointAtCharArrayIntInt()
- {
- CharacterUtils java4 = CharacterUtils.getInstance(Version.LUCENE_30);
- char[] cpAt3 = "Abc\ud801\udc1c".ToCharArray();
- char[] highSurrogateAt3 = "Abc\ud801".ToCharArray();
- assertEquals((int) 'A', java4.codePointAt(cpAt3, 0, 2));
- assertEquals((int) '\ud801', java4.codePointAt(cpAt3, 3, 5));
- assertEquals((int) '\ud801', java4.codePointAt(highSurrogateAt3, 3, 4));
-
- CharacterUtils java5 = CharacterUtils.getInstance(TEST_VERSION_CURRENT);
- assertEquals((int) 'A', java5.codePointAt(cpAt3, 0, 2));
- assertEquals(char.toCodePoint('\ud801', '\udc1c'), java5.codePointAt(cpAt3, 3, 5));
- assertEquals((int) '\ud801', java5.codePointAt(highSurrogateAt3, 3, 4));
- }
-
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
-//ORIGINAL LINE: @Test public void testCodePointCount()
- public virtual void testCodePointCount()
- {
- CharacterUtils java4 = CharacterUtils.Java4Instance;
- CharacterUtils java5 = CharacterUtils.getInstance(TEST_VERSION_CURRENT);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final String s = org.apache.lucene.util.TestUtil.randomUnicodeString(random());
- string s = TestUtil.randomUnicodeString(random());
- assertEquals(s.Length, java4.codePointCount(s));
- assertEquals(char.codePointCount(s, 0, s.Length), java5.codePointCount(s));
- }
-
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
-//ORIGINAL LINE: @Test public void testOffsetByCodePoint()
- public virtual void testOffsetByCodePoint()
- {
- CharacterUtils java4 = CharacterUtils.Java4Instance;
- CharacterUtils java5 = CharacterUtils.getInstance(TEST_VERSION_CURRENT);
- for (int i = 0; i < 10; ++i)
- {
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final char[] s = org.apache.lucene.util.TestUtil.randomUnicodeString(random()).toCharArray();
- char[] s = TestUtil.randomUnicodeString(random()).toCharArray();
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int index = org.apache.lucene.util.TestUtil.nextInt(random(), 0, s.length);
- int index = TestUtil.Next(random(), 0, s.Length);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int offset = random().nextInt(7) - 3;
- int offset = random().Next(7) - 3;
- try
- {
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int o = java4.offsetByCodePoints(s, 0, s.length, index, offset);
- int o = java4.offsetByCodePoints(s, 0, s.Length, index, offset);
- assertEquals(o, index + offset);
- }
- catch (System.IndexOutOfRangeException)
- {
- assertTrue((index + offset) < 0 || (index + offset) > s.Length);
- }
-
- int o;
- try
- {
- o = java5.offsetByCodePoints(s, 0, s.Length, index, offset);
- }
- catch (System.IndexOutOfRangeException)
- {
- try
- {
- char.offsetByCodePoints(s, 0, s.Length, index, offset);
- fail();
- }
- catch (System.IndexOutOfRangeException)
- {
- // OK
- }
- o = -1;
- }
- if (o >= 0)
- {
- assertEquals(char.offsetByCodePoints(s, 0, s.Length, index, offset), o);
- }
- }
- }
-
- public virtual void testConversions()
- {
- CharacterUtils java4 = CharacterUtils.Java4Instance;
- CharacterUtils java5 = CharacterUtils.getInstance(TEST_VERSION_CURRENT);
- testConversions(java4);
- testConversions(java5);
- }
-
- private void testConversions(CharacterUtils charUtils)
- {
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final char[] orig = org.apache.lucene.util.TestUtil.randomUnicodeString(random(), 100).toCharArray();
- char[] orig = TestUtil.randomUnicodeString(random(), 100).toCharArray();
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int[] buf = new int[orig.length];
- int[] buf = new int[orig.Length];
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final char[] restored = new char[buf.length];
- char[] restored = new char[buf.Length];
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int o1 = org.apache.lucene.util.TestUtil.nextInt(random(), 0, Math.min(5, orig.length));
- int o1 = TestUtil.Next(random(), 0, Math.Min(5, orig.Length));
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int o2 = org.apache.lucene.util.TestUtil.nextInt(random(), 0, o1);
- int o2 = TestUtil.Next(random(), 0, o1);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int o3 = org.apache.lucene.util.TestUtil.nextInt(random(), 0, o1);
- int o3 = TestUtil.Next(random(), 0, o1);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int codePointCount = charUtils.toCodePoints(orig, o1, orig.length - o1, buf, o2);
- int codePointCount = charUtils.toCodePoints(orig, o1, orig.Length - o1, buf, o2);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int charCount = charUtils.toChars(buf, o2, codePointCount, restored, o3);
- int charCount = charUtils.toChars(buf, o2, codePointCount, restored, o3);
- assertEquals(orig.Length - o1, charCount);
- assertArrayEquals(Arrays.copyOfRange(orig, o1, o1 + charCount), Arrays.copyOfRange(restored, o3, o3 + charCount));
- }
-
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
-//ORIGINAL LINE: @Test public void testNewCharacterBuffer()
- public virtual void testNewCharacterBuffer()
- {
- CharacterBuffer newCharacterBuffer = CharacterUtils.newCharacterBuffer(1024);
- assertEquals(1024, newCharacterBuffer.Buffer.length);
- assertEquals(0, newCharacterBuffer.Offset);
- assertEquals(0, newCharacterBuffer.Length);
-
- newCharacterBuffer = CharacterUtils.newCharacterBuffer(2);
- assertEquals(2, newCharacterBuffer.Buffer.length);
- assertEquals(0, newCharacterBuffer.Offset);
- assertEquals(0, newCharacterBuffer.Length);
-
- try
- {
- newCharacterBuffer = CharacterUtils.newCharacterBuffer(1);
- fail("length must be >= 2");
- }
- catch (System.ArgumentException)
- {
- }
- }
-
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
-//ORIGINAL LINE: @Test public void testFillNoHighSurrogate() throws java.io.IOException
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
- public virtual void testFillNoHighSurrogate()
- {
- Version[] versions = new Version[] {Version.LUCENE_30, TEST_VERSION_CURRENT};
- foreach (Version version in versions)
- {
- CharacterUtils instance = CharacterUtils.getInstance(version);
- Reader reader = new StringReader("helloworld");
- CharacterBuffer buffer = CharacterUtils.newCharacterBuffer(6);
- assertTrue(instance.fill(buffer,reader));
- assertEquals(0, buffer.Offset);
- assertEquals(6, buffer.Length);
- assertEquals("hellow", new string(buffer.Buffer));
- assertFalse(instance.fill(buffer,reader));
- assertEquals(4, buffer.Length);
- assertEquals(0, buffer.Offset);
-
- assertEquals("orld", new string(buffer.Buffer, buffer.Offset, buffer.Length));
- assertFalse(instance.fill(buffer,reader));
- }
- }
-
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
-//ORIGINAL LINE: @Test public void testFillJava15() throws java.io.IOException
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
- public virtual void testFillJava15()
- {
- string input = "1234\ud801\udc1c789123\ud801\ud801\udc1c\ud801";
- CharacterUtils instance = CharacterUtils.getInstance(TEST_VERSION_CURRENT);
- Reader reader = new StringReader(input);
- CharacterBuffer buffer = CharacterUtils.newCharacterBuffer(5);
- assertTrue(instance.fill(buffer, reader));
- assertEquals(4, buffer.Length);
- assertEquals("1234", new string(buffer.Buffer, buffer.Offset, buffer.Length));
- assertTrue(instance.fill(buffer, reader));
- assertEquals(5, buffer.Length);
- assertEquals("\ud801\udc1c789", new string(buffer.Buffer));
- assertTrue(instance.fill(buffer, reader));
- assertEquals(4, buffer.Length);
- assertEquals("123\ud801", new string(buffer.Buffer, buffer.Offset, buffer.Length));
- assertFalse(instance.fill(buffer, reader));
- assertEquals(3, buffer.Length);
- assertEquals("\ud801\udc1c\ud801", new string(buffer.Buffer, buffer.Offset, buffer.Length));
- assertFalse(instance.fill(buffer, reader));
- assertEquals(0, buffer.Length);
- }
-
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
-//ORIGINAL LINE: @Test public void testFillJava14() throws java.io.IOException
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
- public virtual void testFillJava14()
- {
- string input = "1234\ud801\udc1c789123\ud801\ud801\udc1c\ud801";
- CharacterUtils instance = CharacterUtils.getInstance(Version.LUCENE_30);
- Reader reader = new StringReader(input);
- CharacterBuffer buffer = CharacterUtils.newCharacterBuffer(5);
- assertTrue(instance.fill(buffer, reader));
- assertEquals(5, buffer.Length);
- assertEquals("1234\ud801", new string(buffer.Buffer, buffer.Offset, buffer.Length));
- assertTrue(instance.fill(buffer, reader));
- assertEquals(5, buffer.Length);
- assertEquals("\udc1c7891", new string(buffer.Buffer));
- buffer = CharacterUtils.newCharacterBuffer(6);
- assertTrue(instance.fill(buffer, reader));
- assertEquals(6, buffer.Length);
- assertEquals("23\ud801\ud801\udc1c\ud801", new string(buffer.Buffer, buffer.Offset, buffer.Length));
- assertFalse(instance.fill(buffer, reader));
-
- }
-
- }
+ /*
+ * 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.
+ */
+ /// <summary>
+ /// TestCase for the <seealso cref="CharacterUtils"/> class.
+ /// </summary>
+ [TestFixture]
+ public class TestCharacterUtils : LuceneTestCase
+ {
+ [Test]
+ public virtual void TestCodePointAtCharSequenceInt()
+ {
+ var java4 = CharacterUtils.GetInstance(LuceneVersion.LUCENE_30);
+ var cpAt3 = "Abc\ud801\udc1c";
+ var highSurrogateAt3 = "Abc\ud801";
+ assertEquals((int)'A', java4.CodePointAt(cpAt3, 0));
+ assertEquals((int)'\ud801', java4.CodePointAt(cpAt3, 3));
+ assertEquals((int)'\ud801', java4.CodePointAt(highSurrogateAt3, 3));
+ try
+ {
+ java4.CodePointAt(highSurrogateAt3, 4);
+ fail("string index out of bounds");
+ }
+ catch (IndexOutOfRangeException)
+ {
+ }
+
+ var java5 = CharacterUtils.GetInstance(TEST_VERSION_CURRENT);
+ assertEquals((int)'A', java5.CodePointAt(cpAt3, 0));
+ assertEquals(Character.CodePointAt('\ud801', '\udc1c'), java5.CodePointAt(cpAt3, 3));
+ assertEquals((int)'\ud801', java5.CodePointAt(highSurrogateAt3, 3));
+ try
+ {
+ java5.CodePointAt(highSurrogateAt3, 4);
+ fail("string index out of bounds");
+ }
+ catch (System.IndexOutOfRangeException)
+ {
+ }
+
+ }
+
+ [Test]
+ public virtual void TestCodePointAtCharArrayIntInt()
+ {
+ var java4 = CharacterUtils.GetInstance(LuceneVersion.LUCENE_30);
+ var cpAt3 = "Abc\ud801\udc1c".ToCharArray();
+ var highSurrogateAt3 = "Abc\ud801".ToCharArray();
+ assertEquals((int)'A', java4.CodePointAt(cpAt3, 0, 2));
+ assertEquals((int)'\ud801', java4.CodePointAt(cpAt3, 3, 5));
+ assertEquals((int)'\ud801', java4.CodePointAt(highSurrogateAt3, 3, 4));
+
+ var java5 = CharacterUtils.GetInstance(TEST_VERSION_CURRENT);
+ assertEquals((int)'A', java5.CodePointAt(cpAt3, 0, 2));
+ assertEquals(Character.ToCodePoint('\ud801', '\udc1c'), java5.CodePointAt(cpAt3, 3, 5));
+ assertEquals((int)'\ud801', java5.CodePointAt(highSurrogateAt3, 3, 4));
+ }
+
+ [Test]
+ public virtual void TestCodePointCount()
+ {
+ var java4 = CharacterUtils.Java4Instance;
+ var java5 = CharacterUtils.GetInstance(TEST_VERSION_CURRENT);
+
+ var s = TestUtil.RandomUnicodeString(Random());
+ assertEquals(s.Length, java4.CodePointCount(s));
+ assertEquals(Character.CodePointCount(s, 0, s.Length), java5.CodePointCount(s));
+ }
+
+ [Test]
+ public virtual void TestOffsetByCodePoint()
+ {
+ var java4 = CharacterUtils.Java4Instance;
+ var java5 = CharacterUtils.GetInstance(TEST_VERSION_CURRENT);
+ for (int i = 0; i < 10; ++i)
+ {
+ var s = TestUtil.RandomUnicodeString(Random()).toCharArray();
+ var index = TestUtil.NextInt(Random(), 0, s.Length);
+ var offset = Random().Next(7) - 3;
+ try
+ {
+ var to = java4.OffsetByCodePoints(s, 0, s.Length, index, offset);
+ assertEquals(to, index + offset);
+ }
+ catch (System.IndexOutOfRangeException)
+ {
+ assertTrue((index + offset) < 0 || (index + offset) > s.Length);
+ }
+
+ int o;
+ try
+ {
+ o = java5.OffsetByCodePoints(s, 0, s.Length, index, offset);
+ }
+ catch (System.IndexOutOfRangeException)
+ {
+ try
+ {
+ Character.OffsetByCodePoints(s, 0, s.Length, index, offset);
+ fail();
+ }
+ catch (System.IndexOutOfRangeException)
+ {
+ // OK
+ }
+ o = -1;
+ }
+ if (o >= 0)
+ {
+ assertEquals(Character.OffsetByCodePoints(s, 0, s.Length, index, offset), o);
+ }
+ }
+ }
+
+ [Test]
+ public virtual void TestConversions()
+ {
+ var java4 = CharacterUtils.Java4Instance;
+ var java5 = CharacterUtils.GetInstance(TEST_VERSION_CURRENT);
+ TestConversions(java4);
+ TestConversions(java5);
+ }
+
+ private void TestConversions(CharacterUtils charUtils)
+ {
+ var orig = TestUtil.RandomUnicodeString(Random(), 100).toCharArray();
+
+ var buf = new int[orig.Length];
+
+ var restored = new char[buf.Length];
+
+ var o1 = TestUtil.NextInt(Random(), 0, Math.Min(5, orig.Length));
+ var o2 = TestUtil.NextInt(Random(), 0, o1);
+ var o3 = TestUtil.NextInt(Random(), 0, o1);
+ var codePointCount = charUtils.toCodePoints(orig, o1, orig.Length - o1, buf, o2);
+ var charCount = charUtils.toChars(buf, o2, codePointCount, restored, o3);
+ assertEquals(orig.Length - o1, charCount);
+ assertArrayEquals(Arrays.CopyOfRange(orig, o1, o1 + charCount), Arrays.CopyOfRange(restored, o3, o3 + charCount));
+ }
+
+ [Test]
+ public virtual void TestNewCharacterBuffer()
+ {
+ var newCharacterBuffer = CharacterUtils.NewCharacterBuffer(1024);
+ assertEquals(1024, newCharacterBuffer.Buffer.Length);
+ assertEquals(0, newCharacterBuffer.Offset);
+ assertEquals(0, newCharacterBuffer.Length);
+
+ newCharacterBuffer = CharacterUtils.NewCharacterBuffer(2);
+ assertEquals(2, newCharacterBuffer.Buffer.Length);
+ assertEquals(0, newCharacterBuffer.Offset);
+ assertEquals(0, newCharacterBuffer.Length);
+
+ try
+ {
+ CharacterUtils.NewCharacterBuffer(1);
+ fail("length must be >= 2");
+ }
+ catch (System.ArgumentException)
+ {
+ }
+ }
+
+ [Test]
+ public virtual void TestFillNoHighSurrogate()
+ {
+ var versions = new LuceneVersion[] { LuceneVersion.LUCENE_30, TEST_VERSION_CURRENT };
+ foreach (var version in versions)
+ {
+ var instance = CharacterUtils.GetInstance(version);
+ var reader = new StringReader("helloworld");
+ var buffer = CharacterUtils.NewCharacterBuffer(6);
+ assertTrue(instance.Fill(buffer, reader));
+ assertEquals(0, buffer.Offset);
+ assertEquals(6, buffer.Length);
+ assertEquals("hellow", new string(buffer.Buffer));
+ assertFalse(instance.Fill(buffer, reader));
+ assertEquals(4, buffer.Length);
+ assertEquals(0, buffer.Offset);
+
+ assertEquals("orld", new string(buffer.Buffer, buffer.Offset, buffer.Length));
+ assertFalse(instance.Fill(buffer, reader));
+ }
+ }
+
+ [Test]
+ public virtual void TestFillJava15()
+ {
+ const string input = "1234\ud801\udc1c789123\ud801\ud801\udc1c\ud801";
+ var instance = CharacterUtils.GetInstance(TEST_VERSION_CURRENT);
+ var reader = new StringReader(input);
+ var buffer = CharacterUtils.NewCharacterBuffer(5);
+ assertTrue(instance.Fill(buffer, reader));
+ assertEquals(4, buffer.Length);
+ assertEquals("1234", new string(buffer.Buffer, buffer.Offset, buffer.Length));
+ assertTrue(instance.Fill(buffer, reader));
+ assertEquals(5, buffer.Length);
+ assertEquals("\ud801\udc1c789", new string(buffer.Buffer));
+ assertTrue(instance.Fill(buffer, reader));
+ assertEquals(4, buffer.Length);
+ assertEquals("123\ud801", new string(buffer.Buffer, buffer.Offset, buffer.Length));
+ assertFalse(instance.Fill(buffer, reader));
+ assertEquals(3, buffer.Length);
+ assertEquals("\ud801\udc1c\ud801", new string(buffer.Buffer, buffer.Offset, buffer.Length));
+ assertFalse(instance.Fill(buffer, reader));
+ assertEquals(0, buffer.Length);
+ }
+
+ [Test]
+ public virtual void TestFillJava14()
+ {
+ var input = "1234\ud801\udc1c789123\ud801\ud801\udc1c\ud801";
+ var instance = CharacterUtils.GetInstance(LuceneVersion.LUCENE_30);
+ var reader = new StringReader(input);
+ var buffer = CharacterUtils.NewCharacterBuffer(5);
+ assertTrue(instance.Fill(buffer, reader));
+ assertEquals(5, buffer.Length);
+ assertEquals("1234\ud801", new string(buffer.Buffer, buffer.Offset, buffer.Length));
+ assertTrue(instance.Fill(buffer, reader));
+ assertEquals(5, buffer.Length);
+ assertEquals("\udc1c7891", new string(buffer.Buffer));
+ buffer = CharacterUtils.NewCharacterBuffer(6);
+ assertTrue(instance.Fill(buffer, reader));
+ assertEquals(6, buffer.Length);
+ assertEquals("23\ud801\ud801\udc1c\ud801", new string(buffer.Buffer, buffer.Offset, buffer.Length));
+ assertFalse(instance.Fill(buffer, reader));
+ }
+
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8cef92b2/src/Lucene.Net.Tests.Analysis.Common/Lucene.Net.Tests.Analysis.Common.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Lucene.Net.Tests.Analysis.Common.csproj b/src/Lucene.Net.Tests.Analysis.Common/Lucene.Net.Tests.Analysis.Common.csproj
index cd7c90a..bbb9b68 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Lucene.Net.Tests.Analysis.Common.csproj
+++ b/src/Lucene.Net.Tests.Analysis.Common/Lucene.Net.Tests.Analysis.Common.csproj
@@ -30,15 +30,24 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Analysis\Util\TestCharacterUtils.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\Lucene.Net.Analysis.Common\Lucene.Net.Analysis.Common.csproj">
+ <Project>{4ADD0BBC-B900-4715-9526-D871DE8EEA64}</Project>
+ <Name>Lucene.Net.Analysis.Common</Name>
+ </ProjectReference>
<ProjectReference Include="..\Lucene.Net.Core\Lucene.Net.csproj">
<Project>{5d4ad9be-1ffb-41ab-9943-25737971bf57}</Project>
<Name>Lucene.Net</Name>