1 package com.puppycrawl.tools.checkstyle.filters; 2 3 import junit.framework.TestCase; 4 5 6 public class CSVFilterTest extends TestCase 7 { 8 public void testDecideSingle() 9 { 10 final IntFilter filter = new CSVFilter("0"); 11 assertFalse("less than", filter.accept(new Integer (-1))); 12 assertTrue("equal", filter.accept(new Integer (0))); 13 assertFalse("greater than", filter.accept(new Integer (1))); 14 } 15 16 public void testDecidePair() 17 { 18 final IntFilter filter = new CSVFilter("0, 2"); 19 assertFalse("less than", filter.accept(new Integer (-1))); 20 assertTrue("equal 0", filter.accept(new Integer (0))); 21 assertFalse("greater than", filter.accept(new Integer (1))); 22 assertTrue("equal 2", filter.accept(new Integer (2))); 23 } 24 25 public void testDecideRange() 26 { 27 final IntFilter filter = new CSVFilter("0-2"); 28 assertFalse("less than", filter.accept(new Integer (-1))); 29 assertTrue("equal 0", filter.accept(new Integer (0))); 30 assertTrue("equal 1", filter.accept(new Integer (1))); 31 assertTrue("equal 2", filter.accept(new Integer (2))); 32 assertFalse("greater than", filter.accept(new Integer (3))); 33 } 34 35 public void testDecideEmptyRange() 36 { 37 final IntFilter filter = new CSVFilter("2-0"); 38 assertFalse("less than", filter.accept(new Integer (-1))); 39 assertFalse("equal 0", filter.accept(new Integer (0))); 40 assertFalse("equal 1", filter.accept(new Integer (1))); 41 assertFalse("equal 2", filter.accept(new Integer (2))); 42 assertFalse("greater than", filter.accept(new Integer (3))); 43 } 44 45 public void testDecideRangePlusValue() 46 { 47 final IntFilter filter = new CSVFilter("0-2, 10"); 48 assertFalse("less than", filter.accept(new Integer (-1))); 49 assertTrue("equal 0", filter.accept(new Integer (0))); 50 assertTrue("equal 1", filter.accept(new Integer (1))); 51 assertTrue("equal 2", filter.accept(new Integer (2))); 52 assertFalse("greater than", filter.accept(new Integer (3))); 53 assertTrue("equal 10", filter.accept(new Integer (10))); 54 } 55 } 56 | Popular Tags |