Code cleanup and formatting. Migrated to java 1.8.
[svjatoslav_commons.git] / src / test / java / eu / svjatoslav / commons / string / String2Test.java
1 /*
2  * Svjatoslav Commons - shared library of common functionality.
3  * Copyright ©2012-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
4  * 
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.
8  */
9
10 package eu.svjatoslav.commons.string;
11
12 import org.junit.Test;
13
14 import static org.junit.Assert.assertEquals;
15
16 public class String2Test {
17
18     @Test
19     public void testCutLeft() {
20
21         final String2 s = new String2("this is a test");
22
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));
28
29     }
30
31     @Test
32     public void testEnforceLength() {
33         final String2 s = new String2("12345678");
34         s.enforceLength(3);
35         assertEquals("123", s.toString());
36
37         s.enforceLength(5);
38         assertEquals("123  ", s.toString());
39     }
40
41     @Test
42     public void testSuffixAndPrefix() {
43         final String2 s = new String2("experiment");
44         s.addPrefix("The ").addSuffix(" !");
45
46         assertEquals("The experiment !", s.toString());
47     }
48
49 }