From da85aa084dbf1490cd2b7566286289006a1483fc Mon Sep 17 00:00:00 2001 From: student Date: Mon, 20 Mar 2017 11:49:33 -0400 Subject: Add partial testing on descapeString --- .../bjc/utils/test/parserutils/TokenUtilsTest.java | 74 ++++++++++++++++++++++ .../parserutils/TokenUtilsTest_removeDQuoted.java | 74 ---------------------- 2 files changed, 74 insertions(+), 74 deletions(-) create mode 100644 BJC-Utils2/src/test/java/bjc/utils/test/parserutils/TokenUtilsTest.java delete mode 100644 BJC-Utils2/src/test/java/bjc/utils/test/parserutils/TokenUtilsTest_removeDQuoted.java (limited to 'BJC-Utils2/src/test/java/bjc') diff --git a/BJC-Utils2/src/test/java/bjc/utils/test/parserutils/TokenUtilsTest.java b/BJC-Utils2/src/test/java/bjc/utils/test/parserutils/TokenUtilsTest.java new file mode 100644 index 0000000..371a50a --- /dev/null +++ b/BJC-Utils2/src/test/java/bjc/utils/test/parserutils/TokenUtilsTest.java @@ -0,0 +1,74 @@ +package bjc.utils.test.parserutils; + +import static org.junit.Assert.*; + +import java.util.List; + +import static org.hamcrest.CoreMatchers.*; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import static bjc.utils.parserutils.TokenUtils.*; + +public class TokenUtilsTest_removeDQuoted { + @Rule + public ExpectedException exp; + + public TokenUtilsTest_removeDQuoted(ExpectedException exp) { + this.exp = exp; + } + + /* + * Check handling of mismatched strings with no matching strings. + */ + @Test + public void testRemoveDQuoted_MismatchedStringNoMatch() throws IllegalArgumentException { + exp.expect(IllegalArgumentException.class); + exp.expectMessage(containsString("Opening quote was at position 0")); + + removeDQuotedStrings("\"hello"); + } + + /* + * Check handling of mismatched strings with a matching string. + */ + @Test + public void testRemoveDQuoted_MismatchedStringMatch() throws IllegalArgumentException { + exp.expect(IllegalArgumentException.class); + exp.expectMessage(containsString("Opening quote was at position 7")); + + removeDQuotedStrings("\"hello\"\""); + } + + /* + * Check handling of strings with a single embedded string. + */ + @Test + public void testRemoveDQuoted_SingleString() { + List onSingleMatchString = removeDQuotedStrings("hello\"there\""); + + assertThat(onSingleMatchString, hasItems("hello", "\"there\"")); + } + + /* + * Check handling of strings without embedded strings. + */ + @Test + public void testRemoveDQuote_NoString() { + List onNonmatchingString = removeDQuotedStrings("hello"); + + assertThat(onNonmatchingString, hasItems("hello")); + } + + /* + * Check handling of empty strings. + */ + @Test + public void testRemoveDQuote_EmptyString() { + List onEmptyString = removeDQuotedStrings(""); + + assertThat(onEmptyString, hasItems("")); + } +} \ No newline at end of file diff --git a/BJC-Utils2/src/test/java/bjc/utils/test/parserutils/TokenUtilsTest_removeDQuoted.java b/BJC-Utils2/src/test/java/bjc/utils/test/parserutils/TokenUtilsTest_removeDQuoted.java deleted file mode 100644 index 371a50a..0000000 --- a/BJC-Utils2/src/test/java/bjc/utils/test/parserutils/TokenUtilsTest_removeDQuoted.java +++ /dev/null @@ -1,74 +0,0 @@ -package bjc.utils.test.parserutils; - -import static org.junit.Assert.*; - -import java.util.List; - -import static org.hamcrest.CoreMatchers.*; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static bjc.utils.parserutils.TokenUtils.*; - -public class TokenUtilsTest_removeDQuoted { - @Rule - public ExpectedException exp; - - public TokenUtilsTest_removeDQuoted(ExpectedException exp) { - this.exp = exp; - } - - /* - * Check handling of mismatched strings with no matching strings. - */ - @Test - public void testRemoveDQuoted_MismatchedStringNoMatch() throws IllegalArgumentException { - exp.expect(IllegalArgumentException.class); - exp.expectMessage(containsString("Opening quote was at position 0")); - - removeDQuotedStrings("\"hello"); - } - - /* - * Check handling of mismatched strings with a matching string. - */ - @Test - public void testRemoveDQuoted_MismatchedStringMatch() throws IllegalArgumentException { - exp.expect(IllegalArgumentException.class); - exp.expectMessage(containsString("Opening quote was at position 7")); - - removeDQuotedStrings("\"hello\"\""); - } - - /* - * Check handling of strings with a single embedded string. - */ - @Test - public void testRemoveDQuoted_SingleString() { - List onSingleMatchString = removeDQuotedStrings("hello\"there\""); - - assertThat(onSingleMatchString, hasItems("hello", "\"there\"")); - } - - /* - * Check handling of strings without embedded strings. - */ - @Test - public void testRemoveDQuote_NoString() { - List onNonmatchingString = removeDQuotedStrings("hello"); - - assertThat(onNonmatchingString, hasItems("hello")); - } - - /* - * Check handling of empty strings. - */ - @Test - public void testRemoveDQuote_EmptyString() { - List onEmptyString = removeDQuotedStrings(""); - - assertThat(onEmptyString, hasItems("")); - } -} \ No newline at end of file -- cgit v1.2.3