2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
6 * The Java Pathfinder core (jpf-core) platform is licensed under the
7 * Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0.
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 package gov.nasa.jpf.util;
21 import gov.nasa.jpf.util.test.TestJPF;
23 import org.junit.Test;
26 * unit test for gov.nasa.jpf.util.LocationSpec
28 public class LocationSpecTest extends TestJPF {
31 public void testSingleLocation() {
32 LocationSpec ls = LocationSpec.createLocationSpec("Foobar.java:42");
33 System.out.println("# testing: " + ls);
35 assertTrue(ls.matchesFile("Foobar.java"));
36 assertTrue(!ls.isLineInterval());
37 assertTrue(ls.getLine() == 42);
39 assertFalse(ls.matchesFile("Bull"));
41 assertTrue(ls.matchesFile("/x/y/Foobar.java"));
45 public void testAbsoluteLocation() {
46 LocationSpec ls = LocationSpec.createLocationSpec("/x/y/z/Foobar.java:42");
47 System.out.println("# testing: " + ls);
49 assertTrue(ls.matchesFile("/x/y/z/Foobar.java"));
53 public void testPlatformLocation() {
54 LocationSpec ls = LocationSpec.createLocationSpec("C:\\x\\y\\z\\Foobar.java:42");
55 System.out.println("# testing: " + ls);
57 assertTrue(ls.matchesFile("C:\\x\\y\\z\\Foobar.java"));
58 assertTrue(ls.getLine() == 42);
63 public void testRelativeLocation() {
64 LocationSpec ls = LocationSpec.createLocationSpec("x/y/z/Foobar.java:42");
65 System.out.println("# testing: " + ls);
67 assertTrue(ls.matchesFile("x/y/z/Foobar.java"));
71 public void testWildcards() {
72 LocationSpec ls = LocationSpec.createLocationSpec("x/*/Foo*.java:42");
73 System.out.println("# testing: " + ls);
75 assertTrue(ls.matchesFile("x/y/z/Foobar.java"));
76 assertTrue(ls.matchesFile("Fooboo.java"));
80 public void testAbsoluteRange(){
81 LocationSpec ls = LocationSpec.createLocationSpec("Foobar.java:42-48");
82 System.out.println("# testing: " + ls);
84 assertTrue(ls.isLineInterval());
85 assertTrue(ls.getFromLine() == 42);
86 assertTrue(ls.getToLine() == 48);
90 public void testRelativeRange(){
91 LocationSpec ls = LocationSpec.createLocationSpec("Foobar.java:42+6");
92 System.out.println("# testing: " + ls);
94 assertTrue(ls.isLineInterval());
95 assertTrue(ls.getFromLine() == 42);
96 assertTrue(ls.getToLine() == 48);
100 public void testOpenRange(){
101 LocationSpec ls = LocationSpec.createLocationSpec("Foobar.java:42+");
102 System.out.println("# testing: " + ls);
104 assertTrue(ls.isLineInterval());
105 assertTrue(ls.getFromLine() == 42);
106 assertTrue(ls.getToLine() == Integer.MAX_VALUE);