// https://github.com/ericraider33/pnyx.net/issues/1 public void bug1() { SedReplace replace = new SedReplace("set[ ]*", "_", ""); Assert.Equal("y _x", replace.transformLine("y set x")); Assert.Equal("_x", replace.transformLine("set x")); replace = new SedReplace("set[ ]*", "_", "i"); Assert.Equal("y _x", replace.transformLine("y set x")); Assert.Equal("_x", replace.transformLine("set x")); }
public void basic() { SedReplace replace = new SedReplace("eoe", "XXX", "g"); Assert.Equal("my text XXX is here", replace.transformLine("my text eoe is here")); Assert.Equal("my XXX XXX XXX", replace.transformLine("my eoe eoe eoe")); Assert.Equal("XXXXXXXXX", replace.transformLine("eoeeoeeoe")); replace = new SedReplace("eoe", "XXX", null); // same as "1" Assert.Equal("my text XXX is here", replace.transformLine("my text eoe is here")); Assert.Equal("my XXX eoe eoe", replace.transformLine("my eoe eoe eoe")); Assert.Equal("XXXeoeeoe", replace.transformLine("eoeeoeeoe")); replace = new SedReplace("eoe", "XXX", "2"); Assert.Equal("my text eoe is here", replace.transformLine("my text eoe is here")); Assert.Equal("my eoe XXX eoe", replace.transformLine("my eoe eoe eoe")); Assert.Equal("eoeXXXeoe", replace.transformLine("eoeeoeeoe")); replace = new SedReplace("eoe", "XXX", "g2"); Assert.Equal("my text eoe is here", replace.transformLine("my text eoe is here")); Assert.Equal("my eoe XXX XXX", replace.transformLine("my eoe eoe eoe")); Assert.Equal("eoeXXXXXX", replace.transformLine("eoeeoeeoe")); }
private void verify(String pattern, String replacement, String flags, String source, String expected) { SedReplace replace = new SedReplace(pattern, replacement, flags); Assert.Equal(expected, replace.transformLine(source)); }