You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by de...@apache.org on 2017/09/17 12:29:48 UTC
[myfaces-trinidad] 07/30: Checkpoint: introduce new immutable Range
API to replace lame (mutable) internal Range class.
This is an automated email from the ASF dual-hosted git repository.
deki pushed a commit to branch andys-skin-pregen
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git
commit 0e15c40037380831cc8f59276c285f0acf859bee
Author: Andy Schwartz <an...@apache.org>
AuthorDate: Tue Mar 13 03:52:04 2012 +0000
Checkpoint: introduce new immutable Range API to replace lame (mutable) internal Range class.
---
.../apache/myfaces/trinidad/util/RangeTest.java | 123 +++++++++++++++++++++
1 file changed, 123 insertions(+)
diff --git a/trinidad-api/src/test/java/org/apache/myfaces/trinidad/util/RangeTest.java b/trinidad-api/src/test/java/org/apache/myfaces/trinidad/util/RangeTest.java
new file mode 100644
index 0000000..541c94e
--- /dev/null
+++ b/trinidad-api/src/test/java/org/apache/myfaces/trinidad/util/RangeTest.java
@@ -0,0 +1,123 @@
+/*
+ * 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.
+ */
+package org.apache.myfaces.trinidad.util;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class RangeTest extends TestCase
+{
+ public static final Test suite()
+ {
+ return new TestSuite(RangeTest.class);
+ }
+
+ public static void main(String[] args)
+ throws Throwable
+ {
+ junit.textui.TestRunner.run(suite());
+ }
+ public RangeTest(String string)
+ {
+ super(string);
+ }
+
+ public void testOf()
+ {
+ String start = "a";
+ String end = "z";
+
+ Range<String> range = Range.of(start, end);
+ assertEquals(start, range.getStart());
+ assertEquals(end, range.getEnd());
+ }
+
+ public void testOfNullStart()
+ {
+ try
+ {
+ Range.of(null, "z");
+ fail("IllegalArgumentException expected");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // this is expected
+ }
+ }
+
+ public void testOfNullEnd()
+ {
+ try
+ {
+ Range.of("a", null);
+ fail("IllegalArgumentException expected");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // this is expected
+ }
+ }
+
+ public void testOfStartGreaterThanEnd()
+ {
+ assertTrue(Range.of("z", "a").isEmpty());
+ }
+
+ public void testIntersect()
+ {
+ Range<String> r1 = Range.of("a", "m");
+ Range<String> r2 = Range.of("l", "z");
+ Range<String> intersection = r1.intersect(r2);
+
+ assertEquals(intersection.getStart(), r2.getStart());
+ assertEquals(intersection.getEnd(), r1.getEnd());
+ }
+
+ public void testEmptyIntersect()
+ {
+ Range<String> r1 = Range.of("a", "l");
+ Range<String> r2 = Range.of("m", "z");
+
+ assertTrue(r1.intersect(r2).isEmpty());
+ }
+
+ public void testSelfIntersect()
+ {
+ Range r1 = Range.of("a", "c");
+
+ assertEquals(r1.intersect(r1), r1);
+ }
+
+ public void testContains()
+ {
+ String start = "b";
+ String end = "d";
+ String middle = "c";
+ String before = "a";
+ String after = "e";
+
+ Range<String> r1 = Range.of(start, end);
+ assertTrue(r1.contains(start));
+ assertTrue(r1.contains(middle));
+ assertTrue(r1.contains(end));
+ assertFalse(r1.contains(before));
+ assertFalse(r1.contains(after));
+ }
+}
--
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.