1 package com.puppycrawl.tools.checkstyle.filters; 2 3 import junit.framework.TestCase; 4 5 6 public class IntRangeFilterTest extends TestCase 7 { 8 public void testDecide() 9 { 10 final IntFilter filter = new IntRangeFilter(0, 10); 11 assertFalse("less than", filter.accept(new Integer (-1))); 12 assertTrue("in range", filter.accept(new Integer (0))); 13 assertTrue("in range", filter.accept(new Integer (5))); 14 assertTrue("in range", filter.accept(new Integer (10))); 15 assertFalse("greater than", filter.accept(new Integer (11))); 16 } 17 18 public void testDecideSingle() 19 { 20 final IntFilter filter = new IntRangeFilter(0, 0); 21 assertFalse("less than", filter.accept(new Integer (-1))); 22 assertTrue("in range", filter.accept(new Integer (0))); 23 assertFalse("greater than", filter.accept(new Integer (1))); 24 } 25 26 public void testDecideEmpty() 27 { 28 final IntFilter filter = new IntRangeFilter(10, 0); 29 assertFalse("out", filter.accept(new Integer (-1))); 30 assertFalse("out", filter.accept(new Integer (0))); 31 assertFalse("out", filter.accept(new Integer (5))); 32 assertFalse("out", filter.accept(new Integer (10))); 33 assertFalse("out", filter.accept(new Integer (11))); 34 } 35 36 public void testEquals() 37 { 38 final IntFilter filter = new IntRangeFilter(0, 2); 39 final IntFilter filter2 = new IntRangeFilter(0, 2); 40 final IntFilter filter3 = new IntRangeFilter(0, 1); 41 final IntFilter filter4 = new IntRangeFilter(1, 2); 42 assertEquals("[0,2] == [0,2]", filter, filter2); 43 assertFalse("[0,2] != [0,1]", filter.equals(filter3)); 44 assertFalse("[0,2] != [1,2]", filter.equals(filter4)); 45 assertFalse("[0,2] != this", filter.equals(this)); 46 assertFalse("[0,2] != null", filter.equals(null)); 47 } 48 } 49 | Popular Tags |