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 599AF18BDC for ; Tue, 11 Aug 2015 10:48:24 +0000 (UTC) Received: (qmail 97049 invoked by uid 500); 11 Aug 2015 10:48:19 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 96979 invoked by uid 500); 11 Aug 2015 10:48:19 -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 96968 invoked by uid 99); 11 Aug 2015 10:48:19 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Aug 2015 10:48:19 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id F3B54E03C8; Tue, 11 Aug 2015 10:48:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sebb@apache.org To: commits@commons.apache.org Message-Id: <7b1c159610594903a7b42c8b746da9b1@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [lang] Split up and simplify tests Date: Tue, 11 Aug 2015 10:48:18 +0000 (UTC) Repository: commons-lang Updated Branches: refs/heads/master 6849dfc8a -> 68acbc803 Split up and simplify tests Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/68acbc80 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/68acbc80 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/68acbc80 Branch: refs/heads/master Commit: 68acbc803e416a38616bc25505cb88dde81af5ca Parents: 6849dfc Author: Sebb Authored: Tue Aug 11 11:48:14 2015 +0100 Committer: Sebb Committed: Tue Aug 11 11:48:14 2015 +0100 ---------------------------------------------------------------------- .../commons/lang3/CharSequenceUtilsTest.java | 25 ++++++++------------ 1 file changed, 10 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/68acbc80/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java index 8779aa7..176ad72 100644 --- a/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java @@ -61,21 +61,16 @@ public class CharSequenceUtilsTest { Assert.assertEquals("12", CharSequenceUtils.subSequence("012", 1)); Assert.assertEquals("2", CharSequenceUtils.subSequence("012", 2)); Assert.assertEquals(StringUtils.EMPTY, CharSequenceUtils.subSequence("012", 3)); - // - // Exception expected - // - try { - Assert.assertEquals(null, CharSequenceUtils.subSequence(StringUtils.EMPTY, -1)); - Assert.fail("Expected " + IndexOutOfBoundsException.class.getName()); - } catch (final IndexOutOfBoundsException e) { - // Expected - } - try { - Assert.assertEquals(null, CharSequenceUtils.subSequence(StringUtils.EMPTY, 1)); - Assert.fail("Expected " + IndexOutOfBoundsException.class.getName()); - } catch (final IndexOutOfBoundsException e) { - // Expected - } } + @Test(expected=IndexOutOfBoundsException.class) + public void testSubSequenceNegativeStart() { + Assert.assertEquals(null, CharSequenceUtils.subSequence(StringUtils.EMPTY, -1)); + } + + @Test(expected=IndexOutOfBoundsException.class) + public void testSubSequenceTooLong() { + Assert.assertEquals(null, CharSequenceUtils.subSequence(StringUtils.EMPTY, 1)); + } + }