EMMA Coverage Report (generated Sat Oct 08 11:41:37 CEST 2011)
[all classes][net.sf.jomic.tools]

COVERAGE SUMMARY FOR SOURCE FILE [NumberedNameComparatorTest.java]

nameclass, %method, %block, %line, %
NumberedNameComparatorTest.java100% (1/1)100% (6/6)100% (91/91)100% (21/21)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class NumberedNameComparatorTest100% (1/1)100% (6/6)100% (91/91)100% (21/21)
NumberedNameComparatorTest (): void 100% (1/1)100% (3/3)100% (1/1)
setUp (): void 100% (1/1)100% (8/8)100% (4/4)
tearDown (): void 100% (1/1)100% (6/6)100% (3/3)
testComparator (): void 100% (1/1)100% (19/19)100% (4/4)
testComparator (String, String, boolean, int): void 100% (1/1)100% (42/42)100% (6/6)
testComparator (String, String, int, int): void 100% (1/1)100% (13/13)100% (3/3)

1// Jomic - a viewer for comic book archives.
2// Copyright (C) 2004-2011 Thomas Aglassinger
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 as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16package net.sf.jomic.tools;
17 
18import junit.framework.TestCase;
19 
20/**
21 *  TestCase for NumeredNameComparator.
22 *
23 * @author    Thomas Aglassinger
24 */
25public class NumberedNameComparatorTest extends TestCase
26{
27    private StringTools stringTools;
28 
29    protected void setUp()
30        throws Exception {
31        super.setUp();
32        stringTools = StringTools.instance();
33        TestTools.instance();
34    }
35 
36    public void testComparator() {
37        testComparator("p/n1.s", "p/n1.s", 0, 0);
38        testComparator("p/n1.s", "p/n2.s", -1, -1);
39        testComparator("p/n2.s", "p/n1.s", 1, 1);
40    }
41 
42    protected void tearDown()
43        throws Exception {
44        stringTools = null;
45        super.tearDown();
46    }
47 
48    private void testComparator(String some, String other, boolean demoronized, int expected) {
49        NumberedName someName = new NumberedName(some);
50        NumberedName otherName = new NumberedName(other);
51        NumberedNameComparator comparator = new NumberedNameComparator(demoronized);
52        int actual = comparator.compare(someName, otherName);
53 
54        assertEquals("some=" + stringTools.sourced(some) + ", other=" + stringTools.sourced(other),
55                expected, actual);
56    }
57 
58    private void testComparator(String some, String other, int expectedNonDemoronized, int expectedDemoronized) {
59        testComparator(some, other, false, expectedNonDemoronized);
60        testComparator(some, other, false, expectedDemoronized);
61    }
62}

[all classes][net.sf.jomic.tools]
EMMA 2.0.4217 (C) Vladimir Roubtsov