1 |
|
package alitest; |
2 |
|
|
3 |
|
import java.io.*; |
4 |
|
import static org.junit.Assert.*; |
5 |
|
import org.junit.*; |
6 |
|
import static fi.jyu.mit.ohj2.VertaaTiedosto.*; |
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
@version |
12 |
|
|
13 |
|
|
14 |
|
@SuppressWarnings({ "PMD" }) |
|
|
| 98,3% |
Uncovered Elements: 1 (60) |
Complexity: 6 |
Complexity Density: 0,11 |
|
15 |
|
public class VertaaTiedostoTest { |
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
@throws |
23 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0,06 |
1
PASS
|
|
24 |
1
|
@Test... |
25 |
|
public void testVertaaFileFile34() throws IOException { |
26 |
1
|
kirjoitaTiedosto("hiljaa1.txt", "33 hiljaa 1 hiipii\nhyvä 33 tulee\n"); |
27 |
1
|
kirjoitaTiedosto("hiljaa2.txt", "33 hiljaa 1 hiipii\nhyvä 33 tulee\n"); |
28 |
1
|
assertEquals("From: VertaaTiedosto line: 41", null, vertaaFileFile("hiljaa1.txt","hiljaa2.txt")); |
29 |
1
|
kirjoitaTiedosto("hiljaa2.txt", "33 hiljaa 1 hiipii\nhyvä 33 tulee"); |
30 |
1
|
assertEquals("From: VertaaTiedosto line: 44", null, vertaaFileFile("hiljaa1.txt","hiljaa2.txt")); |
31 |
1
|
kirjoitaTiedosto("hiljaa2.txt", "33 hiljaa 1 hiipii\nhyvä 33 tulee\n\n\n"); |
32 |
1
|
assertEquals("From: VertaaTiedosto line: 47", "Rivi 3: hiljaa1.txt loppui ensin, hiljaa2.txt on ", vertaaFileFile("hiljaa1.txt","hiljaa2.txt")); |
33 |
1
|
kirjoitaTiedosto("hiljaa2.txt", "33 hiljaa 1 hiipii\nhyvä 34 tulee\n"); |
34 |
1
|
assertEquals("From: VertaaTiedosto line: 50", "Ero riveissä 2: hyvä 33 tulee ja hyvä 34 tulee", vertaaFileFile("hiljaa1.txt","hiljaa2.txt")); |
35 |
1
|
kirjoitaTiedosto("hiljaa2.txt", "33 hiljaa 1 hiipii\n"); |
36 |
1
|
assertEquals("From: VertaaTiedosto line: 53", "Rivi 2: hiljaa2.txt loppui ensin, hiljaa1.txt on hyvä 33 tulee", vertaaFileFile("hiljaa1.txt","hiljaa2.txt")); |
37 |
1
|
kirjoitaTiedosto("hiljaa2.txt", "33 hiljaa 1 hiipii\nhyvä 33 tulee\nja 34 tulee\n"); |
38 |
1
|
assertEquals("From: VertaaTiedosto line: 56", "Rivi 3: hiljaa1.txt loppui ensin, hiljaa2.txt on ja 34 tulee", vertaaFileFile("hiljaa1.txt","hiljaa2.txt")); |
39 |
1
|
assertEquals("From: VertaaTiedosto line: 57", "Tiedosto ei aukea: hiljaa3.txt", vertaaFileFile("hiljaa1.txt","hiljaa3.txt")); |
40 |
1
|
assertEquals("From: VertaaTiedosto line: 58", "Tiedosto ei aukea: hiljaa4.txt", vertaaFileFile("hiljaa4.txt","hiljaa2.txt")); |
41 |
1
|
tuhoaTiedosto("hiljaa1.txt"); |
42 |
1
|
tuhoaTiedosto("hiljaa2.txt"); |
43 |
|
} |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
@throws |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0,09 |
1
PASS
|
|
51 |
1
|
@Test... |
52 |
|
public void testVertaaFileString99() throws IOException { |
53 |
1
|
kirjoitaTiedosto("hiljaa1.txt", "33 hiljaa 1 hiipii\nhyvä 33 tulee\n"); |
54 |
1
|
assertEquals("From: VertaaTiedosto line: 105", null, vertaaFileString("hiljaa1.txt","33 hiljaa 1 hiipii\nhyvä 33 tulee\n")); |
55 |
1
|
assertEquals("From: VertaaTiedosto line: 107", null, vertaaFileString("hiljaa1.txt","33 hiljaa 1 hiipii\nhyvä 33 tulee")); |
56 |
1
|
assertEquals("From: VertaaTiedosto line: 109", "Rivi 3: hiljaa1.txt loppui ensin, jono on ", vertaaFileString("hiljaa1.txt","33 hiljaa 1 hiipii\nhyvä 33 tulee\n\n")); |
57 |
1
|
assertEquals("From: VertaaTiedosto line: 111", "Rivi 3: hiljaa1.txt loppui ensin, jono on ", vertaaFileString("hiljaa1.txt","33 hiljaa 1 hiipii\nhyvä 33 tulee\n\n\n")); |
58 |
1
|
assertEquals("From: VertaaTiedosto line: 113", "Ero riveissä 2: hyvä 33 tulee ja hyvä 34 tulee", vertaaFileString("hiljaa1.txt","33 hiljaa 1 hiipii\nhyvä 34 tulee\n")); |
59 |
1
|
assertEquals("From: VertaaTiedosto line: 115", "Rivi 2: Jono loppui ensin, hiljaa1.txt on hyvä 33 tulee", vertaaFileString("hiljaa1.txt","33 hiljaa 1 hiipii\n")); |
60 |
1
|
assertEquals("From: VertaaTiedosto line: 117", "Rivi 3: hiljaa1.txt loppui ensin, jono on ja 34 tulee", vertaaFileString("hiljaa1.txt","33 hiljaa 1 hiipii\nhyvä 33 tulee\nja 34 tulee\n")); |
61 |
1
|
assertEquals("From: VertaaTiedosto line: 118", "Jono on null", vertaaFileString("hiljaa1.txt",null)); |
62 |
1
|
assertEquals("From: VertaaTiedosto line: 119", "Tiedosto ei aukea: hiljaa4.txt", vertaaFileString("hiljaa4.txt","hiljaa2.txt")); |
63 |
1
|
tuhoaTiedosto("hiljaa1.txt"); |
64 |
|
} |
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
@throws |
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0,1 |
1
PASS
|
|
72 |
1
|
@Test... |
73 |
|
public void testVertaaString2157() throws IOException { |
74 |
1
|
assertEquals("From: VertaaTiedosto line: 161", "Rivi 1: 1. loppui ensin, 2. on ", vertaaString2("","\n")); |
75 |
1
|
assertEquals("From: VertaaTiedosto line: 162", null, vertaaString2("kissa\n","kissa")); |
76 |
1
|
assertEquals("From: VertaaTiedosto line: 163", "Rivi 2: 2. loppui ensin, 1. on ", vertaaString2("\n\n","\n")); |
77 |
1
|
assertEquals("From: VertaaTiedosto line: 164", null, vertaaString2("\r\n","\n")); |
78 |
1
|
assertEquals("From: VertaaTiedosto line: 165", "Rivi 2: 1. loppui ensin, 2. on ", vertaaString2("\r\n","\n\n")); |
79 |
1
|
assertEquals("From: VertaaTiedosto line: 166", null, vertaaString2("33 hiljaa 1 hiipii\r\nhyvä 33 tulee\r\n","33 hiljaa 1 hiipii\nhyvä 33 tulee\n")); |
80 |
1
|
assertEquals("From: VertaaTiedosto line: 167", "Ero riveissä 1: a b ja a c", vertaaString2("a b","a c")); |
81 |
1
|
assertEquals("From: VertaaTiedosto line: 168", null, vertaaString2(null,null)); |
82 |
1
|
assertEquals("From: VertaaTiedosto line: 169", "1. on null", vertaaString2(null," ")); |
83 |
1
|
assertEquals("From: VertaaTiedosto line: 170", "2. on null", vertaaString2(" ",null)); |
84 |
|
} |
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
@throws |
91 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0,09 |
1
PASS
|
|
92 |
1
|
@Test... |
93 |
|
public void testVertaaString201() throws IOException { |
94 |
1
|
assertEquals("From: VertaaTiedosto line: 205", "Rivi 2: 2. loppui ensin, 1. on ", vertaaString("kissa\n","kissa")); |
95 |
1
|
assertEquals("From: VertaaTiedosto line: 206", "Rivi 1: 1. loppui ensin, 2. on ", vertaaString("","\n")); |
96 |
1
|
assertEquals("From: VertaaTiedosto line: 207", "Rivi 3: 2. loppui ensin, 1. on ", vertaaString("\n\n","\n")); |
97 |
1
|
assertEquals("From: VertaaTiedosto line: 208", null, vertaaString("\r\n","\n")); |
98 |
1
|
assertEquals("From: VertaaTiedosto line: 209", null, vertaaString("\r","\n")); |
99 |
1
|
assertEquals("From: VertaaTiedosto line: 210", "Rivi 3: 1. loppui ensin, 2. on ", vertaaString("\r\n","\n\n")); |
100 |
1
|
assertEquals("From: VertaaTiedosto line: 211", null, vertaaString("33 hiljaa 1 hiipii\r\nhyvä 33 tulee\r\n","33 hiljaa 1 hiipii\nhyvä 33 tulee\n")); |
101 |
1
|
assertEquals("From: VertaaTiedosto line: 212", "Ero riveissä 1: a b ja a c", vertaaString("a b","a c")); |
102 |
1
|
assertEquals("From: VertaaTiedosto line: 213", null, vertaaString(null,null)); |
103 |
1
|
assertEquals("From: VertaaTiedosto line: 214", "1. on null", vertaaString(null," ")); |
104 |
1
|
assertEquals("From: VertaaTiedosto line: 215", "2. on null", vertaaString(" ",null)); |
105 |
|
} |
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
@throws |
112 |
|
|
|
|
| 83,3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0,33 |
1
PASS
|
|
113 |
1
|
@Test... |
114 |
|
public void testKirjoitaTiedosto250() throws IOException { |
115 |
1
|
kirjoitaTiedosto("hiljaa1.txt", "33 hiljaa 1 hiipii\nhyvä 33 tulee\n"); |
116 |
1
|
tuhoaTiedosto("hiljaa1.txt"); |
117 |
1
|
try { |
118 |
1
|
kirjoitaTiedosto("ö:\\ö.ö", "33 hiljaa 1 hiipii\nhyvä 33 tulee\n"); |
119 |
0
|
fail("VertaaTiedosto: 254 Did not throw IOException"); |
120 |
1
|
} catch(IOException e){ e.getMessage(); } |
121 |
|
} |
122 |
|
} |