1 ////////////////////////////////////////////////////////////////////////////////
2 // checkstyle: Checks Java source code for adherence to a set of rules.
3 // Copyright (C) 2001-2015 the original author or authors.
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ////////////////////////////////////////////////////////////////////////////////
19 package com.puppycrawl.tools.checkstyle.filters;
20
21 import static org.junit.Assert.assertFalse;
22 import static org.junit.Assert.assertTrue;
23 import org.junit.Before;
24 import org.junit.Test;
25
26 /** Tests SuppressElementFilter */
27 // TODO: this test should be removed/rewritten
28 public class FilterSetTest
29 {
30 private CSVFilter filter;
31
32 @Before
33 public void setUp()
34 {
35 filter = new CSVFilter("");
36 }
37
38 @Test
39 public void testEmptyChain()
40 {
41 assertFalse("0", filter.accept(Integer.valueOf(0)));
42 }
43
44 @Test
45 public void testOneFilter()
46 {
47 filter.addFilter(new IntMatchFilter(0));
48 assertTrue("0", filter.accept(Integer.valueOf(0)));
49 assertFalse("1", filter.accept(Integer.valueOf(1)));
50 }
51
52 @Test
53 public void testMultipleFilter()
54 {
55 filter.addFilter(new IntMatchFilter(0));
56 filter.addFilter(new IntRangeFilter(0, 2));
57 assertTrue("0", filter.accept(Integer.valueOf(0)));
58 assertTrue("1", filter.accept(Integer.valueOf(1)));
59 filter.addFilter(new IntRangeFilter(3, 4));
60 assertTrue("0 is in [3,4]", filter.accept(Integer.valueOf(0)));
61 }
62 }