Skip to content

Commit

Permalink
added test for string strip
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamhead committed Feb 4, 2017
1 parent b7000a7 commit 871ad22
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.github.dreamhead.moco.util;

import org.junit.Test;

import static com.github.dreamhead.moco.util.StringUtil.strip;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

public class StringUtilTest {
@Test
public void should_strip_null_to_empty_string() {
assertThat(strip(null), is(""));
}

@Test
public void should_strip_empty_to_empty_string() {
assertThat(strip(""), is(""));
}

@Test
public void should_strip_ordinary_string_as_it_is() {
assertThat(strip("foo"), is("foo"));
assertThat(strip("bar"), is("bar"));
}

@Test
public void should_strip_string_with_leading_whitespace() {
assertThat(strip(" foo"), is("foo"));
assertThat(strip(" bar"), is("bar"));
}

@Test
public void should_strip_string_with_end_whitespace() {
assertThat(strip("foo "), is("foo"));
assertThat(strip("bar "), is("bar"));
}

@Test
public void should_strip_string_with_both_leading_and_end_whitespace() {
assertThat(strip(" foo "), is("foo"));
assertThat(strip(" bar "), is("bar"));
}
}

0 comments on commit 871ad22

Please sign in to comment.