public void WhenOFSUsed_ExpectDelimitedOutput(string input, string pattern, string expected) { PrintTokensInSourceFiles engine = new PrintTokensInSourceFiles() { sw = new WriteToString() }; ParseCommandFile commands = new ParseCommandFile(pattern); string result = engine.ApplyCommandsToInputFileList(commands, new List<string> { input }); Assert.AreEqual(expected, result); }
public void WhenNonRegexTokenGiven_ExpectSimpleOutput(string expected, string scantoken, string input) { PrintTokensInSourceFiles engine = new PrintTokensInSourceFiles() { sw = new WriteToString() }; ParseCommandFile commands = new ParseCommandFile(scantoken); string results = engine.ApplyCommandsToInputFileList(commands, new List<string> { input }); Assert.AreEqual(expected, results); }
public void WhenNoScanTokenGiven_ExpectNoChange() { PrintTokensInSourceFiles engine = new PrintTokensInSourceFiles { sw = new WriteToString() }; ParseCommandFile commands = new ParseCommandFile("bye"); string results = engine.ApplyCommandsToInputFileList(commands, new List<string> { "today bye bye birdie" }); Assert.AreEqual("bye\nbye\n", results); }
public void WhenNoMatchFound_ExpectNoOutput() { PrintTokensInSourceFiles engine = new PrintTokensInSourceFiles() { sw = new WriteToString() }; ParseCommandFile commands = new ParseCommandFile("abc"); string results = engine.ApplyCommandsToInputFileList(commands, new List<string> { "def" }); Assert.AreEqual("", results); }
public void WhenInvalidTokenGiven_ExpectException() { PrintTokensInSourceFiles engine = new PrintTokensInSourceFiles() { sw = new WriteToString() }; ParseCommandFile commands = new ParseCommandFile("a[bc"); string results = engine.ApplyCommandsToInputFileList(commands, new List<string> { "def" }); Assert.AreEqual("", results); }
public void WhenAnchorMatchFound_ExpectOutput() { PrintTokensInSourceFiles engine = new PrintTokensInSourceFiles() { sw = new WriteToString() }; ParseCommandFile commands = new ParseCommandFile("/world/ [0-9]+"); string results = engine.ApplyCommandsToInputFileList(commands, new List<string> { "def", "89 hello world", "hello 09182 worlds" }); Assert.AreEqual("89\n09182\n", results); }
public void WhenRegexAnchorMatchFound_ExpectOutput() { PrintTokensInSourceFiles engine = new PrintTokensInSourceFiles() { sw = new WriteToString() }; ParseCommandFile commands = new ParseCommandFile("/([l]{3})/ [0-9]+"); string results = engine.ApplyCommandsToInputFileList(commands, new List<string> { "def", "55 hello ", "helllo 555 worlds"}); Assert.AreEqual("555\n", results); }
public void WhenOnlyScanTokensGiven_ExpectScannerEnabled() { PrintTokensInSourceFiles engine = new PrintTokensInSourceFiles { sw = new WriteToString() }; ParseCommandFile commands = new ParseCommandFile("a; b; c"); Assert.AreEqual(ParseCommandFile.RunningAs.Scanner, commands.kgrepMode); }
public void WhenReplacementTokenGiven_ExpectScannerDisabled() { PrintTokensInSourceFiles engine = new PrintTokensInSourceFiles { sw = new WriteToString() }; ParseCommandFile commands = new ParseCommandFile("a; b; b~c"); Assert.AreEqual(ParseCommandFile.RunningAs.ReplaceAll, commands.kgrepMode); }
public void WhenOFSused_LetItBecomeDefaultUntilChanged() { PrintTokensInSourceFiles engine = new PrintTokensInSourceFiles() { sw = new WriteToString() }; ParseCommandFile commands = new ParseCommandFile("(.);OFS=' ';(.);(.); OFS='+';(.)"); string results = engine.ApplyCommandsToInputFileList(commands, new List<string> { "de" }); Assert.AreEqual("d\ne\nd e\nd e\nd+e\n", results); }