1 | /* |
---|
2 | * This program is free software; you can redistribute it and/or modify |
---|
3 | * it under the terms of the GNU General Public License as published by |
---|
4 | * the Free Software Foundation; either version 2 of the License, or |
---|
5 | * (at your option) any later version. |
---|
6 | * |
---|
7 | * This program is distributed in the hope that it will be useful, |
---|
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
10 | * GNU General Public License for more details. |
---|
11 | * |
---|
12 | * You should have received a copy of the GNU General Public License |
---|
13 | * along with this program; if not, write to the Free Software |
---|
14 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
15 | */ |
---|
16 | |
---|
17 | /* |
---|
18 | * Copyright (C) 2006 University of Waikato, Hamilton, New Zealand |
---|
19 | */ |
---|
20 | |
---|
21 | package weka.filters.unsupervised.attribute; |
---|
22 | |
---|
23 | import weka.core.Attribute; |
---|
24 | import weka.core.Instances; |
---|
25 | import weka.filters.AbstractFilterTest; |
---|
26 | import weka.filters.Filter; |
---|
27 | |
---|
28 | import junit.framework.Test; |
---|
29 | import junit.framework.TestSuite; |
---|
30 | |
---|
31 | /** |
---|
32 | * Tests NumericToNominal. Run from the command line with:<p> |
---|
33 | * java weka.filters.unsupervised.attribute.NumericToNominalTest |
---|
34 | * |
---|
35 | * @author FracPete (fracpete at waikato dot ac dot nz) |
---|
36 | * @version $Revision: 1.2 $ |
---|
37 | */ |
---|
38 | public class NumericToNominalTest extends AbstractFilterTest { |
---|
39 | |
---|
40 | public NumericToNominalTest(String name) { |
---|
41 | super(name); |
---|
42 | } |
---|
43 | |
---|
44 | /** Creates a default NumericToNominal */ |
---|
45 | public Filter getFilter() { |
---|
46 | return new NumericToNominal(); |
---|
47 | } |
---|
48 | |
---|
49 | public void testTypical() { |
---|
50 | Instances result = useFilter(); |
---|
51 | // Number of attributes and instances shouldn't change |
---|
52 | assertEquals(m_Instances.numAttributes(), result.numAttributes()); |
---|
53 | assertEquals(m_Instances.numInstances(), result.numInstances()); |
---|
54 | // no date and numeric attributes should remain |
---|
55 | if (result.checkForAttributeType(Attribute.DATE)) |
---|
56 | fail("Date attribute(s) left over!"); |
---|
57 | if (result.checkForAttributeType(Attribute.NUMERIC)) |
---|
58 | fail("Numeric attribute(s) left over!"); |
---|
59 | } |
---|
60 | |
---|
61 | public static Test suite() { |
---|
62 | return new TestSuite(NumericToNominalTest.class); |
---|
63 | } |
---|
64 | |
---|
65 | public static void main(String[] args){ |
---|
66 | junit.textui.TestRunner.run(suite()); |
---|
67 | } |
---|
68 | } |
---|