Skip to content

Instantly share code, notes, and snippets.

@oleg
Created February 18, 2012 16:28
Show Gist options
  • Save oleg/1860060 to your computer and use it in GitHub Desktop.
Save oleg/1860060 to your computer and use it in GitHub Desktop.
package logic;
public class WordWrap {
public static String wrap(String input, int length) {
return null;
}
}
package logic;
import org.junit.Test;
public class WordWrapTest {
@Test
public void testName() throws Exception {
WordWrap.wrap(null, 10);
}
}
package logic;
import org.junit.Test;
import static logic.WordWrap.wrap;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
public class WordWrapTest {
@Test
public void wrap_null_return_empty_string() throws Exception {
assertThat(wrap(null, 10), is(""));
}
@Test
public void wrap_empty_string_returns_empty_string() throws Exception {
assertThat(wrap("", 10), is(""));
}
@Test(expected = IllegalArgumentException.class)
public void length_less_than_one__throw_invalid_argument() throws Exception {
wrap("xxx", 0);
}
@Test
public void one_short_word_dosent_wrap() throws Exception {
assertThat(wrap("привет", 10), is("привет"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment