X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Futil%2FStringUtilsTest.java;h=2342afe0b4f4ae66e8093e71497fddbf9086c49f;hb=4a43369c96bc932961492509c4008972d4d566e5;hp=0a0fac0ef6cfce1b0d8abe7d3dadddf5625be308;hpb=3412b273e964fb1a9d22564b04a5f0c827ec2461;p=jalview.git diff --git a/test/jalview/util/StringUtilsTest.java b/test/jalview/util/StringUtilsTest.java index 0a0fac0..2342afe 100644 --- a/test/jalview/util/StringUtilsTest.java +++ b/test/jalview/util/StringUtilsTest.java @@ -1,24 +1,44 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.util; import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; import static org.testng.AssertJUnit.assertNull; -import org.testng.annotations.Test; +import static org.testng.AssertJUnit.assertTrue; + import java.util.Arrays; +import org.testng.annotations.Test; + public class StringUtilsTest { - @Test + @Test(groups = { "Functional" }) public void testInsertCharAt() { char[] c1 = "ABC".toCharArray(); - char[] expected = new char[] - { 'A', 'B', 'C', 'w', 'w' }; + char[] expected = new char[] { 'A', 'B', 'C', 'w', 'w' }; assertTrue(Arrays.equals(expected, StringUtils.insertCharAt(c1, 3, 2, 'w'))); - expected = new char[] - { 'A', 'B', 'C', 'w', 'w' }; + expected = new char[] { 'A', 'B', 'C', 'w', 'w' }; assertTrue(Arrays.equals(expected, StringUtils.insertCharAt(c1, 4, 2, 'w'))); assertTrue(Arrays.equals(expected, @@ -29,32 +49,32 @@ public class StringUtilsTest StringUtils.insertCharAt(c1, 7, 2, 'w'))); } - @Test + @Test(groups = { "Functional" }) public void testDeleteChars() { char[] c1 = "ABC".toCharArray(); // delete second position - assertTrue(Arrays.equals(new char[] - { 'A', 'C' }, StringUtils.deleteChars(c1, 1, 2))); + assertTrue(Arrays.equals(new char[] { 'A', 'C' }, + StringUtils.deleteChars(c1, 1, 2))); // delete positions 1 and 2 - assertTrue(Arrays.equals(new char[] - { 'C' }, StringUtils.deleteChars(c1, 0, 2))); + assertTrue(Arrays.equals(new char[] { 'C' }, + StringUtils.deleteChars(c1, 0, 2))); // delete positions 1-3 - assertTrue(Arrays.equals(new char[] - {}, StringUtils.deleteChars(c1, 0, 3))); + assertTrue(Arrays.equals(new char[] {}, + StringUtils.deleteChars(c1, 0, 3))); // delete position 3 - assertTrue(Arrays.equals(new char[] - { 'A', 'B' }, StringUtils.deleteChars(c1, 2, 3))); + assertTrue(Arrays.equals(new char[] { 'A', 'B' }, + StringUtils.deleteChars(c1, 2, 3))); // out of range deletion is ignore assertTrue(Arrays.equals(c1, StringUtils.deleteChars(c1, 3, 4))); } - @Test + @Test(groups = { "Functional" }) public void testGetLastToken() { assertNull(StringUtils.getLastToken(null, null)); @@ -67,7 +87,7 @@ public class StringUtilsTest "file://localhost:8080/data/examples/file1.dat", "/")); } - @Test + @Test(groups = { "Functional" }) public void testSeparatorListToArray() { String[] result = StringUtils.separatorListToArray( @@ -79,7 +99,7 @@ public class StringUtilsTest */ result = StringUtils.separatorListToArray("minsize='2', sep=','", ","); assertEquals("[minsize='2', sep=',']", Arrays.toString(result)); - + /* * String delimited by | containing a quoted | (should not be treated as * delimiter) @@ -88,18 +108,22 @@ public class StringUtilsTest .separatorListToArray("abc='|'d|ef|g", "|"))); } - @Test + @Test(groups = { "Functional" }) public void testArrayToSeparatorList() { assertEquals("*", StringUtils.arrayToSeparatorList(null, "*")); - assertEquals("*", StringUtils.arrayToSeparatorList(new String[] - {}, "*")); - assertEquals("a*bc*cde", StringUtils.arrayToSeparatorList(new String[] - { "a", "bc", "cde" }, "*")); - assertEquals("a*cde", StringUtils.arrayToSeparatorList(new String[] - { "a", null, "cde" }, "*")); - assertEquals("a**cde", StringUtils.arrayToSeparatorList(new String[] - { "a", "", "cde" }, "*")); + assertEquals("*", + StringUtils.arrayToSeparatorList(new String[] {}, "*")); + assertEquals( + "a*bc*cde", + StringUtils.arrayToSeparatorList(new String[] { "a", "bc", + "cde" }, "*")); + assertEquals( + "a*cde", + StringUtils.arrayToSeparatorList(new String[] { "a", null, + "cde" }, "*")); + assertEquals("a**cde", StringUtils.arrayToSeparatorList(new String[] { + "a", "", "cde" }, "*")); // delimiter within token is not (yet) escaped assertEquals("a*b*c*cde", StringUtils.arrayToSeparatorList(new String[] { "a", "b*c", "cde" }, "*"));