EMMA Coverage Report (generated Mon Nov 01 16:48:29 PDT 2010)
[all classes][com.google.caja.util]

COVERAGE SUMMARY FOR SOURCE FILE [AbbreviatorTest.java]

nameclass, %method, %block, %line, %
AbbreviatorTest.java100% (1/1)100% (4/4)100% (180/180)100% (24/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AbbreviatorTest100% (1/1)100% (4/4)100% (180/180)100% (24/24)
AbbreviatorTest (): void 100% (1/1)100% (3/3)100% (1/1)
testAbbreviator (): void 100% (1/1)100% (116/116)100% (14/14)
testOne (): void 100% (1/1)100% (13/13)100% (3/3)
testSetContainsSuffixOfOtherMember (): void 100% (1/1)100% (48/48)100% (6/6)

1// Copyright (C) 2009 Google Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14 
15package com.google.caja.util;
16 
17import java.util.Arrays;
18import java.util.Collections;
19import java.util.HashSet;
20 
21import junit.framework.TestCase;
22 
23public class AbbreviatorTest extends TestCase {
24  public final void testOne() {
25    Abbreviator a = new Abbreviator(
26        Collections.singleton("test:///foo/bar"), "/");
27    assertEquals("bar", a.unambiguousAbbreviationFor("test:///foo/bar"));
28  }
29 
30  public final void testAbbreviator() {
31    Abbreviator a = new Abbreviator(
32        new HashSet<String>(Arrays.asList(
33            "/a/b/c", "/a/d/e", "/a/d/f", "/a/g/h/c",
34            "/h/i", "/h/j/", "/", "/c", "/d", "x", "")),
35       "/");
36    assertEquals("b/c", a.unambiguousAbbreviationFor("/a/b/c"));
37    assertEquals("h/c", a.unambiguousAbbreviationFor("/a/g/h/c"));
38    assertEquals("e", a.unambiguousAbbreviationFor("/a/d/e"));
39    assertEquals("f", a.unambiguousAbbreviationFor("/a/d/f"));
40    assertEquals("i", a.unambiguousAbbreviationFor("/h/i"));
41    assertEquals("j/", a.unambiguousAbbreviationFor("/h/j/"));
42    assertEquals("/", a.unambiguousAbbreviationFor("/"));
43    assertEquals("/c", a.unambiguousAbbreviationFor("/c"));
44    assertEquals("d", a.unambiguousAbbreviationFor("/d"));
45    assertEquals("x", a.unambiguousAbbreviationFor("x"));
46    assertEquals("", a.unambiguousAbbreviationFor(""));
47    assertEquals("/notpresent", a.unambiguousAbbreviationFor("/notpresent"));
48  }
49 
50  public final void testSetContainsSuffixOfOtherMember() {
51    Abbreviator a = new Abbreviator(
52        new HashSet<String>(Arrays.asList(
53            "foo:bar/z", "foo:foo:baz/z", "foo:baz/z", "foo:bar:far/z")),
54       ":");
55    assertEquals("bar/z", a.unambiguousAbbreviationFor("foo:bar/z"));
56    assertEquals("foo:baz/z", a.unambiguousAbbreviationFor("foo:baz/z"));
57    assertEquals(
58        "foo:foo:baz/z", a.unambiguousAbbreviationFor("foo:foo:baz/z"));
59    assertEquals("far/z", a.unambiguousAbbreviationFor("foo:bar:far/z"));
60  }
61}

[all classes][com.google.caja.util]
EMMA 2.0.5312 (C) Vladimir Roubtsov