You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by el...@apache.org on 2013/04/01 02:05:00 UTC
svn commit: r1463069 - in
/labs/mavibot/branches/mavibot-multivalue-support/mavibot/src:
main/java/org/apache/mavibot/btree/comparator/
test/java/org/apache/mavibot/btree/comparator/
Author: elecharny
Date: Mon Apr 1 00:05:00 2013
New Revision: 1463069
URL: http://svn.apache.org/r1463069
Log:
o Added a test for the Char comparator
o Fixed the CharComparator
Added:
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/test/java/org/apache/mavibot/btree/comparator/CharComparatorTest.java
Modified:
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/comparator/CharComparator.java
labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/test/java/org/apache/mavibot/btree/comparator/ByteComparatorTest.java
Modified: labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/comparator/CharComparator.java
URL: http://svn.apache.org/viewvc/labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/comparator/CharComparator.java?rev=1463069&r1=1463068&r2=1463069&view=diff
==============================================================================
--- labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/comparator/CharComparator.java (original)
+++ labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/main/java/org/apache/mavibot/btree/comparator/CharComparator.java Mon Apr 1 00:05:00 2013
@@ -46,14 +46,25 @@ public class CharComparator implements C
if ( char1 == null )
{
- throw new IllegalArgumentException( "The first object to compare must not be null" );
+ if ( char2 == null )
+ {
+ return 0;
+ }
+ else
+ {
+ return -1;
+ }
}
-
- if ( char2 == null )
+ else
{
- throw new IllegalArgumentException( "The second object to compare must not be null" );
+ if ( char2 == null )
+ {
+ return 1;
+ }
+ else
+ {
+ return char1.compareTo( char2 );
+ }
}
-
- return char1.compareTo( char2 );
}
}
Modified: labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/test/java/org/apache/mavibot/btree/comparator/ByteComparatorTest.java
URL: http://svn.apache.org/viewvc/labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/test/java/org/apache/mavibot/btree/comparator/ByteComparatorTest.java?rev=1463069&r1=1463068&r2=1463069&view=diff
==============================================================================
--- labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/test/java/org/apache/mavibot/btree/comparator/ByteComparatorTest.java (original)
+++ labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/test/java/org/apache/mavibot/btree/comparator/ByteComparatorTest.java Mon Apr 1 00:05:00 2013
@@ -33,7 +33,7 @@ import org.junit.Test;
public class ByteComparatorTest
{
@Test
- public void testBteComparator()
+ public void testByteComparator()
{
ByteComparator comparator = new ByteComparator();
Added: labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/test/java/org/apache/mavibot/btree/comparator/CharComparatorTest.java
URL: http://svn.apache.org/viewvc/labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/test/java/org/apache/mavibot/btree/comparator/CharComparatorTest.java?rev=1463069&view=auto
==============================================================================
--- labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/test/java/org/apache/mavibot/btree/comparator/CharComparatorTest.java (added)
+++ labs/mavibot/branches/mavibot-multivalue-support/mavibot/src/test/java/org/apache/mavibot/btree/comparator/CharComparatorTest.java Mon Apr 1 00:05:00 2013
@@ -0,0 +1,49 @@
+/*
+ * 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.mavibot.btree.comparator;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+
+/**
+ * Test the CharComparator class
+ *
+ * @author <a href="mailto:labs@labs.apache.org">Mavibot labs Project</a>
+ */
+public class CharComparatorTest
+{
+ @Test
+ public void testCharComparator()
+ {
+ CharComparator comparator = new CharComparator();
+
+ assertEquals( 0, comparator.compare( null, null ) );
+ assertEquals( 0, comparator.compare( 'a', 'a' ) );
+ assertEquals( 0, comparator.compare( 'é', 'é' ) );
+ assertEquals( 1, comparator.compare( 'a', null ) );
+ assertEquals( -32, comparator.compare( 'A', 'a' ) );
+ assertEquals( 32, comparator.compare( 'a', 'A' ) );
+ assertEquals( -1, comparator.compare( null, 'a' ) );
+ assertEquals( -1, comparator.compare( 'a', 'b' ) );
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org