1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.criteria.impl

File RangeFactoryTest.java

 

Code metrics

0
22
10
1
111
59
10
0.45
2.2
10
1

Classes

Class Line # Actions
RangeFactoryTest 30 22 0% 10 0
1.0100%
 

Contributing tests

This file is covered by 6 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20   
21    package com.xpn.xwiki.criteria.impl;
22   
23    import junit.framework.TestCase;
24    import com.xpn.xwiki.criteria.impl.Range;
25    import com.xpn.xwiki.criteria.impl.RangeFactory;
26   
27    /**
28    * Unit tests for the {@link com.xpn.xwiki.criteria.impl.RangeFactory} class.
29    */
 
30    public class RangeFactoryTest extends TestCase
31    {
32    /**
33    * Test for {@link RangeFactory#ALL}
34    */
 
35  1 toggle public void testAll()
36    {
37  1 doRangeTest(RangeFactory.ALL, 0, 0);
38    }
39   
40    /**
41    * Test for {@link RangeFactory#FIRST}
42    */
 
43  1 toggle public void testFirst()
44    {
45  1 doRangeTest(RangeFactory.FIRST, 0, 1);
46    }
47   
48    /**
49    * Test for {@link RangeFactory#LAST}
50    */
 
51  1 toggle public void testLast()
52    {
53  1 doRangeTest(RangeFactory.LAST, 0, -1);
54    }
55   
56    /**
57    * Test for {@link RangeFactory#createRange(int, int)}
58    */
 
59  1 toggle public void testCreateRange()
60    {
61  1 doCreateRangeTest(0, 0);
62  1 doCreateRangeTest(0, 3);
63  1 doCreateRangeTest(0, -4);
64  1 doCreateRangeTest(-10, 0);
65  1 doCreateRangeTest(-10, 5);
66  1 doCreateRangeTest(-10, -9);
67    }
68   
 
69  6 toggle private void doCreateRangeTest(int start, int size)
70    {
71  6 doRangeTest(RangeFactory.createRange(start, size), start, size);
72    }
73   
74    /**
75    * Test for {@link RangeFactory#createHeadRange(int)}
76    */
 
77  1 toggle public void testCreateHeadRange()
78    {
79  1 doCreateHeadRangeTest(0);
80  1 doCreateHeadRangeTest(3);
81  1 doCreateHeadRangeTest(-7);
82    }
83   
 
84  3 toggle private void doCreateHeadRangeTest(int size)
85    {
86  3 doRangeTest(RangeFactory.createHeadRange(size), 0, Math.abs(size));
87    }
88   
89    /**
90    * Test for {@link RangeFactory#createTailRange(int)}
91    */
 
92  1 toggle public void testCreateTailRange()
93    {
94  1 doCreateTailRangeTest(0);
95  1 doCreateTailRangeTest(3);
96  1 doCreateTailRangeTest(-7);
97    }
98   
 
99  3 toggle private void doCreateTailRangeTest(int size)
100    {
101  3 doRangeTest(RangeFactory.createTailRange(size), 0, -Math.abs(size));
102    }
103   
 
104  15 toggle private void doRangeTest(Range i, int start, int size)
105    {
106  15 assertEquals(i.getStart(), start);
107  15 assertEquals(i.getSize(), size);
108  15 assertEquals(i.getAbsoluteStart(), Math.abs(start));
109  15 assertEquals(i.getAbsoluteSize(), Math.abs(size));
110    }
111    }