You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2017/09/22 05:55:34 UTC
[11/11] lucenenet git commit: Lucene.Net.Tests.Support: Added
TestStringExtensions class and TestTrimEnd() test
Lucene.Net.Tests.Support: Added TestStringExtensions class and TestTrimEnd() test
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/2368a020
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/2368a020
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/2368a020
Branch: refs/heads/master
Commit: 2368a020d1f140ff8be983a08d8b5f9504d67322
Parents: 302a51e
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Fri Sep 22 01:20:13 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Fri Sep 22 12:45:45 2017 +0700
----------------------------------------------------------------------
.../Support/TestStringExtensions.cs | 59 ++++++++++++++++++++
1 file changed, 59 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2368a020/src/Lucene.Net.Tests/Support/TestStringExtensions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Support/TestStringExtensions.cs b/src/Lucene.Net.Tests/Support/TestStringExtensions.cs
new file mode 100644
index 0000000..5ea5801
--- /dev/null
+++ b/src/Lucene.Net.Tests/Support/TestStringExtensions.cs
@@ -0,0 +1,59 @@
+using NUnit.Framework;
+
+namespace Lucene.Net.Support
+{
+ /*
+ * 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.
+ */
+
+ public class TestStringExtensions
+ {
+ [Test]
+ public void TestTrimEnd()
+ {
+ // Zero length
+ CollectionAssert.AreEqual(new string[0], new string[0].TrimEnd());
+ CollectionAssert.AreEqual(new string[0], new string[] { "" }.TrimEnd());
+ CollectionAssert.AreEqual(new string[0], new string[] { "", "" }.TrimEnd());
+
+ CollectionAssert.AreEqual(new string[0], new string[] { "", "", null }.TrimEnd());
+ CollectionAssert.AreEqual(new string[0], new string[] { null }.TrimEnd());
+ CollectionAssert.AreEqual(new string[0], new string[] { null, null }.TrimEnd());
+
+ // End trimming
+ CollectionAssert.AreEqual(new string[] { "foo" }, new string[] { "foo", "" }.TrimEnd());
+ CollectionAssert.AreEqual(new string[] { "foo" }, new string[] { "foo", "", "" }.TrimEnd());
+ CollectionAssert.AreEqual(new string[] { "foo" }, new string[] { "foo", "", "", "" }.TrimEnd());
+
+ CollectionAssert.AreEqual(new string[] { "foo", "bar" }, new string[] { "foo", "bar", "" }.TrimEnd());
+ CollectionAssert.AreEqual(new string[] { "foo", "bar" }, new string[] { "foo", "bar", "", "" }.TrimEnd());
+ CollectionAssert.AreEqual(new string[] { "foo", "bar" }, new string[] { "foo", "bar", "", "", "" }.TrimEnd());
+
+ // End trimming without trimming beginning or middle entries
+ CollectionAssert.AreEqual(new string[] { "", "foo" }, new string[] { "", "foo" }.TrimEnd());
+ CollectionAssert.AreEqual(new string[] { "", "foo", "bar" }, new string[] { "", "foo", "bar" }.TrimEnd());
+ CollectionAssert.AreEqual(new string[] { "foo", "", "bar" }, new string[] { "foo", "", "bar" }.TrimEnd());
+
+ CollectionAssert.AreEqual(new string[] { "", "foo" }, new string[] { "", "foo", "" }.TrimEnd());
+ CollectionAssert.AreEqual(new string[] { "", "foo", "bar" }, new string[] { "", "foo", "bar", "" }.TrimEnd());
+ CollectionAssert.AreEqual(new string[] { "foo", "", "bar" }, new string[] { "foo", "", "bar", "" }.TrimEnd());
+
+ CollectionAssert.AreEqual(new string[] { "", "foo" }, new string[] { "", "foo", "", "" }.TrimEnd());
+ CollectionAssert.AreEqual(new string[] { "", "foo", "bar" }, new string[] { "", "foo", "bar", "", "" }.TrimEnd());
+ CollectionAssert.AreEqual(new string[] { "foo", "", "bar" }, new string[] { "foo", "", "bar", "", "" }.TrimEnd());
+ }
+ }
+}