Mercurial > hg > truffle
diff test/testlibrary/OutputAnalyzerTest.java @ 9077:480d934f62a8
Merge
author | mgerdin |
---|---|
date | Thu, 11 Apr 2013 16:35:34 +0200 |
parents | 3b890cd4da64 |
children | 9e11762cee52 |
line wrap: on
line diff
--- a/test/testlibrary/OutputAnalyzerTest.java Wed Apr 10 14:26:49 2013 +0200 +++ b/test/testlibrary/OutputAnalyzerTest.java Thu Apr 11 16:35:34 2013 +0200 @@ -36,6 +36,11 @@ String stdout = "aaaaaa"; String stderr = "bbbbbb"; + // Regexps used for testing pattern matching of the test input + String stdoutPattern = "[a]"; + String stderrPattern = "[b]"; + String nonExistingPattern = "[c]"; + OutputAnalyzer output = new OutputAnalyzer(stdout, stderr); if (!stdout.equals(output.getStdout())) { @@ -99,10 +104,73 @@ } try { - output.stderrShouldNotContain(stderr); - throw new Exception("shouldContain() failed to throw exception"); + output.stderrShouldNotContain(stderr); + throw new Exception("shouldContain() failed to throw exception"); + } catch (RuntimeException e) { + // expected + } + + // Should match + try { + output.shouldMatch(stdoutPattern); + output.stdoutShouldMatch(stdoutPattern); + output.shouldMatch(stderrPattern); + output.stderrShouldMatch(stderrPattern); + } catch (RuntimeException e) { + throw new Exception("shouldMatch() failed", e); + } + + try { + output.shouldMatch(nonExistingPattern); + throw new Exception("shouldMatch() failed to throw exception"); + } catch (RuntimeException e) { + // expected + } + + try { + output.stdoutShouldMatch(stderrPattern); + throw new Exception( + "stdoutShouldMatch() failed to throw exception"); } catch (RuntimeException e) { - // expected + // expected + } + + try { + output.stderrShouldMatch(stdoutPattern); + throw new Exception( + "stderrShouldMatch() failed to throw exception"); + } catch (RuntimeException e) { + // expected + } + + // Should not match + try { + output.shouldNotMatch(nonExistingPattern); + output.stdoutShouldNotMatch(nonExistingPattern); + output.stderrShouldNotMatch(nonExistingPattern); + } catch (RuntimeException e) { + throw new Exception("shouldNotMatch() failed", e); + } + + try { + output.shouldNotMatch(stdoutPattern); + throw new Exception("shouldNotMatch() failed to throw exception"); + } catch (RuntimeException e) { + // expected + } + + try { + output.stdoutShouldNotMatch(stdoutPattern); + throw new Exception("shouldNotMatch() failed to throw exception"); + } catch (RuntimeException e) { + // expected + } + + try { + output.stderrShouldNotMatch(stderrPattern); + throw new Exception("shouldNotMatch() failed to throw exception"); + } catch (RuntimeException e) { + // expected } } }