Repository navigation
Expand file tree
/
Copy pathConvertorTester.java
More file actions
75 lines (63 loc) · 2.15 KB
/
Copy pathConvertorTester.java
File metadata and controls
75 lines (63 loc) · 2.15 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
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
/**
* This class aims to test the Convertor class. In main is a test case where a
* .txt file is written and converted to a .cmp file, while a .cmp file is
* written and converted to a .txt file. The client should look at the file
* created in their directory to check the success of the conversion.
*
* @author Samuel Fu ssf2130 COMS1007
*
*/
public class ConvertorTester {
private Convertor convertor = new Convertor();
private FileOutput fileOutput = new FileOutput();
private ArrayList<String> lineList = new ArrayList<String>();
private String fileName = "";
/**
* Makes two converstion tests
*
* @param args
* @throws FileNotFoundException
* @throws IOException
*/
public static void main(String[] args) throws FileNotFoundException, IOException {
ConvertorTester convertorTester = new ConvertorTester();
convertorTester.txtToCmpTester();
convertorTester.cmpToTxtTester();
}
/**
* Creates a file txtToCmpTest.txt with the following lines and converts the
* file to .cmp. Check directory for the new file.
*
* @throws FileNotFoundException
* @throws IOException
*/
private void txtToCmpTester() throws FileNotFoundException, IOException {
fileName = "txtToCmpTest";
lineList = new ArrayList<String>();
lineList.add("my name is Samuel Fu");
lineList.add("hello Samuel Fu");
lineList.add("hello world");
fileOutput.saveFileToDirectory(fileName + ".txt", lineList);
convertor.txtToCmp(fileName); // check .cmp file for success
}
/**
* Creates a file cmpToTxt.cmp with the following lines and converts the file to
* .txt. Check directory for the new file.
*
* @throws FileNotFoundException
* @throws IOException
*/
private void cmpToTxtTester() throws FileNotFoundException, IOException {
fileName = "cmpToTxtTest";
lineList = new ArrayList<String>();
lineList.add("my name is Samuel Fu hello world");
lineList.add("0 1 2 3 4");
lineList.add("5 3 4");
lineList.add("5 6");
fileOutput.saveFileToDirectory(fileName + ".cmp", lineList);
convertor.cmpToTxt(fileName); // check .txt file for success
}
}