2 * Copyright (C) 2008, Google Inc.
6 * Redistribution and use in source and binary forms, with or
7 * without modification, are permitted provided that the following
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * - Neither the name of the Git Development Community nor the
19 * names of its contributors may be used to endorse or promote
20 * products derived from this software without specific prior
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
24 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
35 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 package org
.spearce
.jgit
.util
;
40 import junit
.framework
.TestCase
;
42 public class IntListTest
extends TestCase
{
43 public void testEmpty_DefaultCapacity() {
44 final IntList i
= new IntList();
45 assertEquals(0, i
.size());
48 fail("Accepted 0 index on empty list");
49 } catch (ArrayIndexOutOfBoundsException e
) {
54 public void testEmpty_SpecificCapacity() {
55 final IntList i
= new IntList(5);
56 assertEquals(0, i
.size());
59 fail("Accepted 0 index on empty list");
60 } catch (ArrayIndexOutOfBoundsException e
) {
65 public void testAdd_SmallGroup() {
66 final IntList i
= new IntList();
68 for (int v
= 0; v
< n
; v
++)
70 assertEquals(n
, i
.size());
72 for (int v
= 0; v
< n
; v
++)
73 assertEquals(10 + v
, i
.get(v
));
76 fail("Accepted out of bound index on list");
77 } catch (ArrayIndexOutOfBoundsException e
) {
82 public void testAdd_ZeroCapacity() {
83 final IntList i
= new IntList(0);
84 assertEquals(0, i
.size());
86 assertEquals(1, i
.get(0));
89 public void testAdd_LargeGroup() {
90 final IntList i
= new IntList();
92 for (int v
= 0; v
< n
; v
++)
94 assertEquals(n
, i
.size());
96 for (int v
= 0; v
< n
; v
++)
97 assertEquals(10 + v
, i
.get(v
));
100 fail("Accepted out of bound index on list");
101 } catch (ArrayIndexOutOfBoundsException e
) {
106 public void testClear() {
107 final IntList i
= new IntList();
109 for (int v
= 0; v
< n
; v
++)
111 assertEquals(n
, i
.size());
114 assertEquals(0, i
.size());
117 fail("Accepted 0 index on empty list");
118 } catch (ArrayIndexOutOfBoundsException e
) {
123 public void testToString() {
124 final IntList i
= new IntList();
126 assertEquals("[1]", i
.toString());
129 assertEquals("[1, 13, 5]", i
.toString());