2 * Svjatoslav Commons - shared library of common functionality.
3 * Copyright ©2012-2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 3 of the GNU Lesser General Public License
7 * or later as published by the Free Software Foundation.
10 package eu.svjatoslav.commons.string;
12 import org.junit.Test;
14 import static org.junit.Assert.assertEquals;
16 public class String2Test {
19 public void testCutLeft() {
21 final String2 s = new String2("this is a test");
23 assertEquals("this ", s.trimLeft(5));
24 assertEquals("is ", s.trimLeft(3));
25 assertEquals("a ", s.trimLeft(2));
26 assertEquals("test", s.trimLeft(25));
27 assertEquals("", s.trimLeft(5));
32 public void testEnforceLength() {
33 final String2 s = new String2("12345678");
35 assertEquals("123", s.toString());
38 assertEquals("123 ", s.toString());
42 public void testSuffixAndPrefix() {
43 final String2 s = new String2("experiment");
44 s.addPrefix("The ").addSuffix(" !");
46 assertEquals("The experiment !", s.toString());