-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIrisTest2.java
More file actions
128 lines (108 loc) · 4.02 KB
/
IrisTest2.java
File metadata and controls
128 lines (108 loc) · 4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package irisdriver;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author TxusLópez
*/
public class IrisTest2 {
Iris test;
public IrisTest2() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
try {
test = new Iris("D:\\tree(J48_cv).model");
} catch (Exception e){
fail("Iris class creation failed: " + e.getMessage());
}
}
@After
public void tearDown() {
test.close();
}
/**
* Test of close method, of class Iris.
*/
@Test
public void testClose() {
try {
System.out.println("close");
//Iris instance = new Iris();
//instance.close();
// TODO review the generated test code and remove the default call to fail.
//fail("The test case is a prototype.");
} catch (Exception ex) {
Logger.getLogger(IrisTest2.class.getName()).log(Level.SEVERE, null, ex);
}
}
/**
* Test of classifySpecies method, of class Iris.
*/
@Test
public void testClassifySpecies() throws Exception {
System.out.println("classifySpecies");
Hashtable<String, String> testValues = new Hashtable<String, String>();
testValues.put("Sepal.Length", "4.92929274813475");
testValues.put("Sepal.Width", "3.02115558560619");
testValues.put("Petal.Length", "1.66111228600889");
testValues.put("Petal.Width", "0.494913257610669");
if(test.classifySpecies(testValues) != "setosa")
fail("setosa Test A failed.");
testValues.clear();
testValues.put("Sepal.Length", "5.01546360901192");
testValues.put("Sepal.Width", "2.88881892726493");
testValues.put("Petal.Length", "1.21569048438709");
testValues.put("Petal.Width", "-0.0217150655097085");
if(test.classifySpecies(testValues) != "setosa")
fail("setosa Test B failed.");
testValues.clear();
testValues.put("Sepal.Length", "5.89395864793917");
testValues.put("Sepal.Width", "3.29989993511548");
testValues.put("Petal.Length", "3.83039227615041");
testValues.put("Petal.Width", "1.37570550945425");
if(test.classifySpecies(testValues) != "versicolor")
fail("versicolor Test A failed.");
testValues.clear();
testValues.put("Sepal.Length", "5.6267275495847");
testValues.put("Sepal.Width", "2.89811069873405");
testValues.put("Petal.Length", "5.24972276380846");
testValues.put("Petal.Width", "1.37410752993031");
if(test.classifySpecies(testValues) != "versicolor")
fail("versicolor Test B failed.");
testValues.clear();
testValues.put("Sepal.Length", "6.34320263841694");
testValues.put("Sepal.Width", "2.66808487957697");
testValues.put("Petal.Length", "5.85453759164497");
testValues.put("Petal.Width", "2.37517354329087");
if(test.classifySpecies(testValues) != "virginica")
fail("virginica Test A failed.");
testValues.clear();
testValues.put("Sepal.Length", "6.85295094185716");
testValues.put("Sepal.Width", "2.51646353971598");
testValues.put("Petal.Length", "4.21432509213448");
testValues.put("Petal.Width", "1.74441756575054");
if(test.classifySpecies(testValues) != "virginica")
fail("virginica Test B failed.");
testValues.clear();
}
}