GlueGen: src/junit/com/jogamp/common/util/TestIteratorIndexCORE.java Source File

GlueGen v2.6.0-rc-20250722 GlueGen, Native Binding Generator for Java™ (public API).

TestIteratorIndexCORE.java
Go to the documentation of this file.
1/**
2 * Copyright 2010 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29package com.jogamp.common.util;
30
31import java.util.*;
32import java.io.IOException;
33
34import org.junit.Test;
35
36import com.jogamp.common.os.Platform;
37import com.jogamp.junit.util.SingletonJunitCase;
38
39import org.junit.FixMethodOrder;
40import org.junit.runners.MethodSorters;
41
42@FixMethodOrder(MethodSorters.NAME_ASCENDING)
43public class TestIteratorIndexCORE extends SingletonJunitCase {
44
45 static int elems = 10;
46 static int loop = ( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) ? 20 : 9999999;
47
48 public void populate(final List<Integer> l, int len) {
49 while(len>0) {
50 l.add(new Integer(len--));
51 }
52 }
53
54 @Test
55 public void test01ArrayListIterator() {
56 int sum=0;
57 final ArrayList<Integer> l = new ArrayList<Integer>();
58 populate(l, elems);
59
60 for(int j=loop; j>0; j--) {
61 for(final Iterator<Integer> iter = l.iterator(); iter.hasNext(); ) {
62 final Integer i = iter.next();
63 sum+=i.intValue();
64 }
65 }
66 System.err.println("test01-arraylist-iterator sum: "+sum);
67 }
68
69 @Test
70 public void test0ArrayListIndex() {
71 int sum=0;
72 final ArrayList<Integer> l = new ArrayList<Integer>();
73 populate(l, elems);
74
75 for(int j=loop; j>0; j--) {
76 for(int k = 0; k < l.size(); k++) {
77 final Integer i = l.get(k);
78 sum+=i.intValue();
79 }
80 }
81 System.err.println("test01-arraylist-index sum: "+sum);
82 }
83
84 @Test
85 public void test01LinkedListListIterator() {
86 int sum=0;
87 final LinkedList<Integer> l = new LinkedList<Integer>();
88 populate(l, elems);
89
90 for(int j=loop; j>0; j--) {
91 for(final Iterator<Integer> iter = l.iterator(); iter.hasNext(); ) {
92 final Integer i = iter.next();
93 sum+=i.intValue();
94 }
95 }
96 System.err.println("test01-linkedlist-iterator sum: "+sum);
97 }
98
99 @Test
100 public void test01LinkedListListIndex() {
101 int sum=0;
102 final LinkedList<Integer> l = new LinkedList<Integer>();
103 populate(l, elems);
104
105 for(int j=loop; j>0; j--) {
106 for(int k = 0; k < l.size(); k++) {
107 final Integer i = l.get(k);
108 sum+=i.intValue();
109 }
110 }
111 System.err.println("test01-linkedlist-index sum: "+sum);
112 }
113
114 public static void main(final String args[]) throws IOException {
115 final String tstname = TestIteratorIndexCORE.class.getName();
116 org.junit.runner.JUnitCore.main(tstname);
117 }
118
119}
com.jogamp.common.os.Platform
Utility class for querying platform specific properties.
Definition: Platform.java:58
com.jogamp.common.os.Platform.getCPUFamily
static CPUFamily getCPUFamily()
Returns the CPU family.
Definition: Platform.java:408
com.jogamp.common.util.TestIteratorIndexCORE
Definition: TestIteratorIndexCORE.java:43
com.jogamp.common.util.TestIteratorIndexCORE.main
static void main(final String args[])
Definition: TestIteratorIndexCORE.java:114
com.jogamp.common.util.TestIteratorIndexCORE.test0ArrayListIndex
void test0ArrayListIndex()
Definition: TestIteratorIndexCORE.java:70
com.jogamp.common.util.TestIteratorIndexCORE.populate
void populate(final List< Integer > l, int len)
Definition: TestIteratorIndexCORE.java:48
com.jogamp.common.util.TestIteratorIndexCORE.test01LinkedListListIndex
void test01LinkedListListIndex()
Definition: TestIteratorIndexCORE.java:100
com.jogamp.common.util.TestIteratorIndexCORE.test01LinkedListListIterator
void test01LinkedListListIterator()
Definition: TestIteratorIndexCORE.java:85
com.jogamp.common.util.TestIteratorIndexCORE.test01ArrayListIterator
void test01ArrayListIterator()
Definition: TestIteratorIndexCORE.java:55
com.jogamp.junit.util.SingletonJunitCase
Definition: SingletonJunitCase.java:39