package org.testng.internal;

import java.util.List;

import org.testng.annotations.Test;

import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static org.testng.Assert.assertEquals;
import static org.testng.internal.Utils.join;

/**
 * Unit tests for {@link Utils}.
 *
 * @author Tomas Pollak
 */
public class UtilsTest {
	private static final char INVALID_CHAR = 0xFFFE;
	private static final char REPLACEMENT_CHAR = 0xFFFD;

	@Test
	public void escapeUnicode() {
		assertEquals(Utils.escapeUnicode("test"), "test");
		assertEquals(Utils.escapeUnicode(String.valueOf(INVALID_CHAR)),
				String.valueOf(REPLACEMENT_CHAR));

	}

	@Test
	public void joinTwoStringsWithJoin() throws Exception {
		List<String> twoStrings = asList("one", "two");
		assertEquals("one, two", join(twoStrings, ","));
	}

	@Test
	public void createEmptyStringWhenJoiningEmptyListWithJoin() throws Exception {
		List<String> emptyList = emptyList();
		assertEquals("", join(emptyList, ","));
	}

	@Test
	public void joinTwoStringsWithJoinStrings() throws Exception {
		List<String> twoStrings = asList("one", "two");
		assertEquals("one,two", Utils.join(twoStrings, ","));
	}

	@Test
	public void createEmptyStringWhenJoiningEmptyListWithJoinStrings() throws Exception {
		List<String> emptyList = emptyList();
		assertEquals("", Utils.join(emptyList, ","));
	}
}

@@ -666,177 +666,8 @@
 %09%7D%0A%0A
-%09@Test%0A%09public void joinTwoStringsWithJoin() throws Exception %7B%0A%09%09List%3CString%3E twoStrings = asList(%22one%22, %22two%22);%0A%09%09assertEquals(%22one, two%22, join(twoStrings, %22,%22));%0A%09%7D%0A%0A
 %09@Te

Test fix.