commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1144047 - in /commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/collections: ./ FibonacciNumbersTestCase.java
Date Thu, 07 Jul 2011 21:19:04 GMT
Author: simonetripodi
Date: Thu Jul  7 21:19:04 2011
New Revision: 1144047

URL: http://svn.apache.org/viewvc?rev=1144047&view=rev
Log:
added the Fibonacci numbers calculator test case - implementation is based on cached data
to improve performances

Added:
    commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/collections/
    commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/collections/FibonacciNumbersTestCase.java
  (with props)

Added: commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/collections/FibonacciNumbersTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/collections/FibonacciNumbersTestCase.java?rev=1144047&view=auto
==============================================================================
--- commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/collections/FibonacciNumbersTestCase.java
(added)
+++ commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/collections/FibonacciNumbersTestCase.java
Thu Jul  7 21:19:04 2011
@@ -0,0 +1,49 @@
+package org.apache.commons.graph.collections;
+
+/*
+ * 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.
+ */
+
+import static org.apache.commons.graph.collections.FibonacciNumbers.fibonacci;
+
+import static junit.framework.Assert.assertEquals;
+import org.junit.Test;
+
+public final class FibonacciNumbersTestCase
+{
+
+    @Test
+    public void nthFibonacciNumberAssertion()
+    {
+        assertEquals( 0, fibonacci( 0 ) );
+        assertEquals( 1, fibonacci( 1 ) );
+        assertEquals( 1, fibonacci( 2 ) );
+        assertEquals( 8, fibonacci( 6 ) );
+        assertEquals( 144, fibonacci( 12 ) );
+    }
+
+    @Test
+    public void nthNotPreviouslyExplicitlyRequestedFibonacciNumberAssertion()
+    {
+        assertEquals( 2, fibonacci( 3 ) );
+        assertEquals( 3, fibonacci( 4 ) );
+        assertEquals( 5, fibonacci( 5 ) );
+        assertEquals( 8, fibonacci( 6 ) );
+    }
+
+}

Propchange: commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/collections/FibonacciNumbersTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/collections/FibonacciNumbersTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/collections/FibonacciNumbersTestCase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message