Debian Codegraph @

test/func/route/SimpleRouteTest.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2008 Steve Ratcliffe
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 or
6 * version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13 /* Create date: 16-Feb-2009 */
14 package func.route;
15
16 import java.io.FileNotFoundException;
17 import java.util.List;
18
19 import uk.me.parabola.imgfmt.fs.DirectoryEntry;
20 import uk.me.parabola.imgfmt.fs.FileSystem;
21 import uk.me.parabola.mkgmap.main.Main;
22
23 import func.Base;
24 import func.lib.Args;
25 import func.lib.RangeMatcher;
26 import org.junit.Test;
27
28 import static org.junit.Assert .*;
29
30 public class SimpleRouteTest extends Base {
31
32 /**
33 * Simple test to ensure that nothing has changed. Of course
34 * if the output should have changed, then this will have to be altered
35 * to match.
36 */
37 @Test
38 public void testSize() throws FileNotFoundException {
39 Main.mainNoSystemExit(Args.TEST_STYLE_ARG, "--preserve-element-order",
40 "--route", Args.TEST_RESOURCE_OSM + "uk-test-1.osm.gz", Args.TEST_RESOURCE_MP + "test1.mp");
41
42 FileSystem fs = openFs(Args.DEF_MAP_ID + ".img");
43 assertNotNull("file exists", fs);
44
45 List<DirectoryEntry> entries = fs.list();
46 int count = 0;
47 for (DirectoryEntry ent : entries) {
48 String ext = ent.getExt();
49
50 int size = ent.getSize();
51 switch (ext) {
52 case "RGN":
53 count++;
54 System.out.println("RGN size " + size);
55 assertThat("RGN size", size, new RangeMatcher(126035));
56 break;
57 case "TRE":
58 count++;
59 System.out.println("TRE size " + size);
60 // Size varies depending on svn modified status
61 assertThat("TRE size", size, new RangeMatcher(1413, 2));
62 break;
63 case "LBL":
64 count++;
65 assertEquals("LBL size", 28742, size);
66 break;
67 case "NET":
68 count++;
69 assertEquals("NET size", 66591, size);
70 break;
71 case "NOD":
72 count++;
73 System.out.println("NOD size " + size);
74 assertEquals("NOD size", 169689, size);
75 break;
76 }
77 }
78 assertTrue("enough checks run", count == 5);
79
80 fs = openFs(Args.DEF_MAP_FILENAME2);
81 assertNotNull("file exists", fs);
82
83 entries = fs.list();
84 count = 0;
85 for (DirectoryEntry ent : entries) {
86 String ext = ent.getExt();
87
88 int size = ent.getSize();
89 switch (ext) {
90 case "RGN":
91 count++;
92 System.out.println("RGN size " + size);
93 assertThat("RGN size", size, new RangeMatcher(2743,3));
94 break;
95 case "TRE":
96 count++;
97 System.out.println("TRE size " + size);
98 // Size varies depending on svn modified status
99 assertThat("TRE size", size, new RangeMatcher(770, 2));
100 break;
101 case "LBL":
102 count++;
103 assertEquals("LBL size", 999, size);
104 break;
105 case "NET":
106 count++;
107 assertEquals("NET size", 1301, size);
108 break;
109 case "NOD":
110 count++;
111 System.out.println("NOD size " + size);
112 assertEquals("NOD size", 3584, size);
113 break;
114 }
115 }
116 assertTrue("enough checks run", count == 5);
117 }
118 }