Merge pull request #1896 from eugenp/BAEL-839
BAEL-839 - minor test changes
This commit is contained in:
commit
02d153b953
|
@ -1,10 +1,12 @@
|
|||
package com.baeldung.regexp;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class EscapingCharsManualTest {
|
||||
public class EscapingCharsTest {
|
||||
@Test
|
||||
public void givenRegexWithDot_whenMatchingStr_thenMatches() {
|
||||
String strInput = "foof";
|
||||
|
@ -38,33 +40,28 @@ public class EscapingCharsManualTest {
|
|||
String strRegex = "|";
|
||||
EscapingChars e = new EscapingChars();
|
||||
|
||||
assertEquals(4,
|
||||
e.splitAndCountWordsUsingQuoteMethod(strInput, strRegex));
|
||||
assertEquals(4, e.splitAndCountWordsUsingQuoteMethod(strInput, strRegex));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenRegexWithDollar_whenReplacing_thenNotReplace() {
|
||||
String strInput = "I gave $50 to my brother."
|
||||
+ "He bought candy for $35. Now he has $15 left.";
|
||||
String strInput = "I gave $50 to my brother.He bought candy for $35. Now he has $15 left.";
|
||||
String strRegex = "$";
|
||||
String strReplacement = "£";
|
||||
String output = "I gave £50 to my brother."
|
||||
+ "He bought candy for £35. Now he has £15 left.";
|
||||
String strReplacement = "<EFBFBD>";
|
||||
String output = "I gave <20>50 to my brother.He bought candy for <20>35. Now he has <20>15 left.";
|
||||
EscapingChars e = new EscapingChars();
|
||||
|
||||
assertEquals(output,
|
||||
e.changeCurrencySymbol(strInput, strRegex, strReplacement));
|
||||
assertThat(output, not(equalTo(e.changeCurrencySymbol(strInput, strRegex, strReplacement))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenRegexWithDollarEsc_whenReplacing_thenReplace() {
|
||||
String strInput = "I gave $50 to my brother. He bought candy for $35. Now he has $15 left.";
|
||||
String strRegex = "\\$";
|
||||
String strReplacement = "£";
|
||||
String output = "I gave £50 to my brother. He bought candy for £35. Now he has £15 left.";
|
||||
String strReplacement = "<EFBFBD>";
|
||||
String output = "I gave <EFBFBD>50 to my brother. He bought candy for <20>35. Now he has <20>15 left.";
|
||||
EscapingChars e = new EscapingChars();
|
||||
|
||||
assertEquals(output,
|
||||
e.changeCurrencySymbol(strInput, strRegex, strReplacement));
|
||||
assertEquals(output, e.changeCurrencySymbol(strInput, strRegex, strReplacement));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue