Created
February 18, 2012 16:28
-
-
Save oleg/1860060 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package logic; | |
public class WordWrap { | |
public static String wrap(String input, int length) { | |
return null; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package logic; | |
import org.junit.Test; | |
public class WordWrapTest { | |
@Test | |
public void testName() throws Exception { | |
WordWrap.wrap(null, 10); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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