@Test public void testTooManyWarnings() { // It should stop accumulating warnings after `count` of them. for (int i = 0; i < WARNING_MAX_COUNT + 5; i++) { diagCollector.addDiag( Diag.warning( new SimpleLocation(String.format("testTooManyWarnings:%d", i)), "%s", "This is a warning message")); } // We should have `count` warnings plus the "too many" warning in the diagnostics. Assert.assertEquals(WARNING_MAX_COUNT + 1, diagCollector.getDiags().size()); Assert.assertEquals(0, diagCollector.getErrorCount()); }
@Test public void testTooManyMixedDiags() { try { for (int i = 0; i < WARNING_MAX_COUNT + 5; i++) { diagCollector.addDiag( Diag.warning( new SimpleLocation(String.format("testTooManyMixedDiags:%d", i)), "%s", "This is a warning message")); } for (int i = 0; i < ERROR_MAX_COUNT + 5; i++) { diagCollector.addDiag( Diag.error( new SimpleLocation(String.format("testTooManyMixedDiags:%d", i)), "%s", "This is an error message")); } Assert.fail("Expected TooManyDiagsException was not thrown"); } catch (TooManyDiagsException ex) { // fall through to assertions } // We should have `warnCount` warnings plus the "too many" warning in the diagnostics, plus // `errorCount` errors and the "too many" error. Assert.assertEquals( WARNING_MAX_COUNT + 1 + ERROR_MAX_COUNT + 1, diagCollector.getDiags().size()); Assert.assertEquals(ERROR_MAX_COUNT + 1, diagCollector.getErrorCount()); } }
@Test public void testTooManyErrors() { try { for (int i = 0; i < ERROR_MAX_COUNT + 5; i++) { diagCollector.addDiag( Diag.error( new SimpleLocation(String.format("testTooManyErrors:%d", i)), "%s", "This is an error message")); } Assert.fail("Expected TooManyDiagsException was not thrown"); } catch (TooManyDiagsException ex) { // fall through to assertions } // We should have `count` errors plus the "too many" error in the diagnostics. Assert.assertEquals(ERROR_MAX_COUNT + 1, diagCollector.getDiags().size()); Assert.assertEquals(ERROR_MAX_COUNT + 1, diagCollector.getErrorCount()); }