
package com.exedio.cope.lib;

public class TrimTest extends AbstractLibTest
{
	private void assertTrim(final String expected, final String actualLongString, final int maxLength)
	{
		final String actual = Database.trimString(actualLongString, maxLength);
		assertEquals(">"+expected+"< >"+actual+"<", expected, actual);
		if(actualLongString.length()>maxLength)
			assertEquals(maxLength, actual.length());
		else
			assertEquals(actualLongString.length(), actual.length());
	}

	public void testTrim()
	{
		assertTrim("F", "FirstSecondThird", 1);
		assertTrim("FS", "FirstSecondThird", 2);
		assertTrim("FST", "FirstSecondThird", 3);
		assertTrim("FiST", "FirstSecondThird", 4);
		assertTrim("FiSeT", "FirstSecondThird", 5);
		assertTrim("FirsSecThi", "FirstSecondThird", 10);
		assertTrim("FirsSecoThi", "FirstSecondThird", 11);
		assertTrim("FirsSecoThir", "FirstSecondThird", 12);
		assertTrim("FirstSecoThir", "FirstSecondThird", 13);
		assertTrim("FirstSeconThir", "FirstSecondThird", 14);
		assertTrim("FirstSeconThird", "FirstSecondThird", 15);
		assertTrim("FirstSecondThird", "FirstSecondThird", 16);
		assertTrim("FirstSecondThird", "FirstSecondThird", 18);

		assertTrim("1irs2ec3hi", "1irst2econd3hird", 10);
		assertTrim("_irs_ec_hi", "_irst_econd_hird", 10);
	}

}

@@ -1267,15 +1267,523 @@
 d%22, 10);
+%0A%0A%09%09assertTrim(%22ShortVeryverylongShort%22, %22ShortVeryverylongShort%22, 22);%0A%09%09assertTrim(%22ShortVeryverylonShort%22, %22ShortVeryverylongShort%22, 21);%0A%09%09assertTrim(%22ShortVeryveryloShort%22, %22ShortVeryverylongShort%22, 20);%0A%09%09assertTrim(%22ShortVeryvShort%22, %22ShortVeryverylongShort%22,15);%0A%09%09assertTrim(%22ShortVeryvShor%22, %22ShortVeryverylongShort%22,14);%0A%09%09assertTrim(%22ShortVeryShor%22, %22ShortVeryverylongShort%22,13);%0A%09%09assertTrim(%22ShorVeryShor%22, %22ShortVeryverylongShort%22,12);%0A%09%09assertTrim(%22ShorVerySho%22, %22ShortVeryverylongShort%22,11);
 %0A%09%7D%0A%0A%7D%0A

test with very different word lengths