Package: OutputTestUtil
OutputTestUtil
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
OutputTestUtil() |
|
|
|
|
|
||||||||||||||||||||
compare(String, String) |
|
|
|
|
|
||||||||||||||||||||
deSerialize(String) |
|
|
|
|
|
||||||||||||||||||||
testUpdate(String, String) |
|
|
|
|
|
Coverage
1: package org.overture.codegen.tests.output.util;
2:
3: import java.io.File;
4: import java.io.FileNotFoundException;
5: import java.io.FileOutputStream;
6: import java.io.IOException;
7: import java.io.PrintStream;
8:
9: import org.junit.Assert;
10: import org.overture.codegen.utils.GeneralUtils;
11: import org.overture.parser.lex.LexException;
12: import org.overture.parser.syntax.ParserException;
13:
14: public class OutputTestUtil
15: {
16:         public static final String UPDATE_PROPERTY_PREFIX = "tests.javagen.override.";
17:         public static final String UPDATE_ALL_OUTPUT_TESTS_PROPERTY = UPDATE_PROPERTY_PREFIX
18:                         + "all";
19:
20:         public static void compare(String expected, String actual)
21:         {
22:                 expected = expected.trim().replaceAll("\\r", "");
23:                 actual = actual.trim().replaceAll("\\r", "");
24:                 
25:                 Assert.assertEquals("Unexpected code produced by the Java code generator", expected, actual.trim());
26:         }
27:
28:         public static String deSerialize(String resultPath)
29:                         throws FileNotFoundException, IOException
30:         {
31:                 return GeneralUtils.readFromFile(new File(resultPath));
32:         }
33:
34:         public static void testUpdate(String actual, String resultPath)
35:                         throws ParserException, LexException, IOException
36:         {
37:                 PrintStream out = new PrintStream(new FileOutputStream(new File(resultPath)));
38:                 out.print(actual);
39:                 out.close();
40:         }
41: }