X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=svjatoslav_commons.git;a=blobdiff_plain;f=src%2Ftest%2Fjava%2Feu%2Fsvjatoslav%2Fcommons%2Fstring%2FString2Test.java;h=0e31c82d2cb5009af36d0ae6c1bf3f9271ba4479;hp=db1c12133d3e3fe044db659ace9d8b82009f32ed;hb=b8bd1e820265fc15c39c1ee8c06289ea8b8e2c1c;hpb=9bf004ce4e9b5edff36c65fcc8cc0f303390d7fc diff --git a/src/test/java/eu/svjatoslav/commons/string/String2Test.java b/src/test/java/eu/svjatoslav/commons/string/String2Test.java index db1c121..0e31c82 100755 --- a/src/test/java/eu/svjatoslav/commons/string/String2Test.java +++ b/src/test/java/eu/svjatoslav/commons/string/String2Test.java @@ -1,7 +1,7 @@ /* * Svjatoslav Commons - shared library of common functionality. - * Copyright ©2012-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 3 of the GNU Lesser General Public License * or later as published by the Free Software Foundation. @@ -16,18 +16,28 @@ import static org.junit.Assert.assertEquals; public class String2Test { @Test - public void testCutLeft() { + public void testTrimPrefix() { final String2 s = new String2("this is a test"); - assertEquals("this ", s.trimLeft(5)); - assertEquals("is ", s.trimLeft(3)); - assertEquals("a ", s.trimLeft(2)); - assertEquals("test", s.trimLeft(25)); - assertEquals("", s.trimLeft(5)); + assertEquals("is a test", s.trimPrefix(5).toString()); + assertEquals("a test", s.trimPrefix(3).toString()); + assertEquals("test", s.trimPrefix(2).toString()); + assertEquals("", s.trimPrefix(500).toString()); + } + + @Test + public void testTrimSuffix() { + final String2 s = new String2("this is a test"); + + assertEquals("this is a", s.trimSuffix(5).toString()); + assertEquals("this is", s.trimSuffix(2).toString()); + assertEquals("this", s.trimSuffix(3).toString()); + assertEquals("", s.trimSuffix(500).toString()); } + @Test public void testEnforceLength() { final String2 s = new String2("12345678");