Package: TestHandler

TestHandler

nameinstructionbranchcomplexitylinemethod
TestHandler(Release, Dialect)
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
getFile(File, String)
M: 21 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
initVdmEnv()
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
toString()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
writeToFile(String, File)
M: 24 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * VDM Code Generator
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.codegen.tests.exec.util.testhandlers;
23:
24: import java.io.BufferedWriter;
25: import java.io.File;
26: import java.io.FileOutputStream;
27: import java.io.IOException;
28: import java.io.OutputStreamWriter;
29: import java.io.PrintWriter;
30:
31: import org.overture.ast.lex.Dialect;
32: import org.overture.codegen.tests.util.JavaToolsUtils;
33: import org.overture.config.Release;
34: import org.overture.config.Settings;
35:
36: public class TestHandler
37: {
38:         private Release release;
39:         private Dialect dialect;
40:
41:         public TestHandler(Release release, Dialect dialect)
42:         {
43:                 this.release = release;
44:                 this.dialect = dialect;
45:                 initVdmEnv();
46:         }
47:
48:         public void initVdmEnv()
49:         {
50:                 Settings.release = release;
51:                 Settings.dialect = dialect;
52:         }
53:
54:         public void writeToFile(String toWrite, File file) throws IOException
55:         {
56:                 PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file, false), "UTF-8"));
57:                 BufferedWriter out = new BufferedWriter(writer);
58:                 out.write(toWrite);
59:                 out.close();
60:         }
61:
62:         public File getFile(File parent, String className) throws IOException
63:         {
64:                 File file = new File(parent, className
65:                                 + JavaToolsUtils.JAVA_FILE_EXTENSION);
66:
67:•                if (!file.exists())
68:                 {
69:                         file.createNewFile();
70:                 }
71:
72:                 return file;
73:         }
74:
75:         @Override
76:         public String toString()
77:         {
78:                 return getClass().getSimpleName();
79:         }
80: }