Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EED1A79DC for ; Thu, 1 Dec 2011 15:25:43 +0000 (UTC) Received: (qmail 21918 invoked by uid 500); 1 Dec 2011 15:25:43 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 21842 invoked by uid 500); 1 Dec 2011 15:25:43 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 21835 invoked by uid 99); 1 Dec 2011 15:25:43 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Dec 2011 15:25:43 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Dec 2011 15:25:41 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id F0C9A23889ED for ; Thu, 1 Dec 2011 15:25:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1209119 - /commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/FractionFormatTest.java Date: Thu, 01 Dec 2011 15:25:19 -0000 To: commits@commons.apache.org From: erans@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111201152519.F0C9A23889ED@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: erans Date: Thu Dec 1 15:25:19 2011 New Revision: 1209119 URL: http://svn.apache.org/viewvc?rev=1209119&view=rev Log: Added a few unit tests. Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/FractionFormatTest.java Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/FractionFormatTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/FractionFormatTest.java?rev=1209119&r1=1209118&r2=1209119&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/FractionFormatTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/FractionFormatTest.java Thu Dec 1 15:25:19 2011 @@ -137,6 +137,44 @@ public class FractionFormatTest { } @Test + public void testParseOne1() { + String source = "1 / 1"; + Fraction c = properFormat.parse(source); + Assert.assertNotNull(c); + Assert.assertEquals(1, c.getNumerator()); + Assert.assertEquals(1, c.getDenominator()); + } + + @Test + public void testParseOne2() { + String source = "10 / 10"; + Fraction c = properFormat.parse(source); + Assert.assertNotNull(c); + Assert.assertEquals(1, c.getNumerator()); + Assert.assertEquals(1, c.getDenominator()); + } + + @Test + public void testParseZero1() { + String source = "0 / 1"; + Fraction c = properFormat.parse(source); + Assert.assertNotNull(c); + Assert.assertEquals(0, c.getNumerator()); + Assert.assertEquals(1, c.getDenominator()); + } + + @Test + public void testParseZero2() { + String source = "-0 / 1"; + Fraction c = properFormat.parse(source); + Assert.assertNotNull(c); + Assert.assertEquals(0, c.getNumerator()); + Assert.assertEquals(1, c.getDenominator()); + // This test shows that the sign is not preserved. + Assert.assertEquals(Double.POSITIVE_INFINITY, 1d / c.doubleValue(), 0); + } + + @Test public void testParseInvalid() { String source = "a"; String msg = "should not be able to parse '10 / a'.";