Source Code Cross Referenced for DataBufferIntTest.java in  » Apache-Harmony-Java-SE » java-package » java » awt » image » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » java package » java.awt.image 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
0003:         *  contributor license agreements.  See the NOTICE file distributed with
0004:         *  this work for additional information regarding copyright ownership.
0005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
0006:         *  (the "License"); you may not use this file except in compliance with
0007:         *  the License.  You may obtain a copy of the License at
0008:         *
0009:         *     http://www.apache.org/licenses/LICENSE-2.0
0010:         *
0011:         *  Unless required by applicable law or agreed to in writing, software
0012:         *  distributed under the License is distributed on an "AS IS" BASIS,
0013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014:         *  See the License for the specific language governing permissions and
0015:         *  limitations under the License.
0016:         */
0017:        /**
0018:         * @author Igor V. Stolyarov
0019:         * @version $Revision$
0020:         */package java.awt.image;
0021:
0022:        import java.awt.image.DataBuffer;
0023:        import java.awt.image.DataBufferInt;
0024:        import junit.framework.TestCase;
0025:
0026:        public class DataBufferIntTest extends TestCase {
0027:
0028:            DataBufferInt db1, db2, db3, db4, db5, db6;
0029:            int numBanks = 4;
0030:            int arraySize = 20;
0031:            int size = 10;
0032:
0033:            public static void main(String[] args) {
0034:                junit.textui.TestRunner.run(DataBufferIntTest.class);
0035:            }
0036:
0037:            /*
0038:             * @see TestCase#setUp()
0039:             */
0040:            @Override
0041:            protected void setUp() throws Exception {
0042:                super .setUp();
0043:                int dataArrays[][] = new int[numBanks][];
0044:                for (int i = 0; i < numBanks; i++) {
0045:                    dataArrays[i] = new int[arraySize];
0046:                }
0047:
0048:                int dataArray[] = new int[arraySize];
0049:                int offsets[] = new int[numBanks];
0050:                for (int i = 0; i < numBanks; i++) {
0051:                    offsets[i] = i;
0052:                }
0053:
0054:                db1 = new DataBufferInt(dataArrays, size);
0055:                db2 = new DataBufferInt(dataArrays, size, offsets);
0056:                db3 = new DataBufferInt(dataArray, size);
0057:                db4 = new DataBufferInt(dataArray, size, numBanks);
0058:                db5 = new DataBufferInt(size);
0059:                db6 = new DataBufferInt(size, numBanks);
0060:            }
0061:
0062:            /**
0063:             * Constructor for DataBufferIntTest.
0064:             * @param name
0065:             */
0066:            public DataBufferIntTest(String name) {
0067:                super (name);
0068:            }
0069:
0070:            public final void testGetDataType() {
0071:                assertEquals(DataBuffer.TYPE_INT, db1.getDataType());
0072:                assertEquals(DataBuffer.TYPE_INT, db2.getDataType());
0073:                assertEquals(DataBuffer.TYPE_INT, db3.getDataType());
0074:                assertEquals(DataBuffer.TYPE_INT, db4.getDataType());
0075:                assertEquals(DataBuffer.TYPE_INT, db5.getDataType());
0076:                assertEquals(DataBuffer.TYPE_INT, db6.getDataType());
0077:            }
0078:
0079:            public final void testGetDataTypeSize() {
0080:                assertEquals(32, DataBuffer.getDataTypeSize(db1.getDataType()));
0081:                assertEquals(32, DataBuffer.getDataTypeSize(db2.getDataType()));
0082:                assertEquals(32, DataBuffer.getDataTypeSize(db3.getDataType()));
0083:                assertEquals(32, DataBuffer.getDataTypeSize(db4.getDataType()));
0084:                assertEquals(32, DataBuffer.getDataTypeSize(db5.getDataType()));
0085:                assertEquals(32, DataBuffer.getDataTypeSize(db6.getDataType()));
0086:            }
0087:
0088:            public final void testGetNumBanks() {
0089:                assertEquals(numBanks, db1.getNumBanks());
0090:                assertEquals(numBanks, db2.getNumBanks());
0091:                assertEquals(1, db3.getNumBanks());
0092:                assertEquals(1, db4.getNumBanks());
0093:                assertEquals(1, db5.getNumBanks());
0094:                assertEquals(numBanks, db6.getNumBanks());
0095:            }
0096:
0097:            public final void testGetSize() {
0098:                assertEquals(size, db1.getSize());
0099:                assertEquals(size, db2.getSize());
0100:                assertEquals(size, db3.getSize());
0101:                assertEquals(size, db4.getSize());
0102:                assertEquals(size, db5.getSize());
0103:                assertEquals(size, db6.getSize());
0104:            }
0105:
0106:            public final void testGetOffset() {
0107:                assertEquals(0, db1.getOffset());
0108:                assertEquals(0, db2.getOffset());
0109:                assertEquals(0, db3.getOffset());
0110:                assertEquals(numBanks, db4.getOffset());
0111:                assertEquals(0, db5.getOffset());
0112:                assertEquals(0, db6.getOffset());
0113:            }
0114:
0115:            public final void testGetOffsets() {
0116:                int offsets[];
0117:
0118:                offsets = db1.getOffsets();
0119:                for (int i = 0; i < db1.getNumBanks(); i++) {
0120:                    assertEquals(0, offsets[i]);
0121:                }
0122:
0123:                offsets = db2.getOffsets();
0124:                for (int i = 0; i < db2.getNumBanks(); i++) {
0125:                    assertEquals(i, offsets[i]);
0126:                }
0127:
0128:                offsets = db3.getOffsets();
0129:                for (int i = 0; i < db3.getNumBanks(); i++) {
0130:                    assertEquals(0, offsets[i]);
0131:                }
0132:
0133:                offsets = db4.getOffsets();
0134:                for (int i = 0; i < db4.getNumBanks(); i++) {
0135:                    assertEquals(numBanks, offsets[i]);
0136:                }
0137:
0138:                offsets = db5.getOffsets();
0139:                for (int i = 0; i < db5.getNumBanks(); i++) {
0140:                    assertEquals(0, offsets[i]);
0141:                }
0142:
0143:                offsets = db6.getOffsets();
0144:                for (int i = 0; i < db6.getNumBanks(); i++) {
0145:                    assertEquals(0, offsets[i]);
0146:                }
0147:            }
0148:
0149:            public final void testGetBankData() {
0150:                int bankData[][];
0151:
0152:                bankData = db1.getBankData();
0153:                assertEquals(numBanks, bankData.length);
0154:
0155:                bankData = db2.getBankData();
0156:                assertEquals(numBanks, bankData.length);
0157:
0158:                bankData = db3.getBankData();
0159:                assertEquals(1, bankData.length);
0160:
0161:                bankData = db4.getBankData();
0162:                assertEquals(1, bankData.length);
0163:
0164:                bankData = db5.getBankData();
0165:                assertEquals(1, bankData.length);
0166:
0167:                bankData = db6.getBankData();
0168:                assertEquals(numBanks, bankData.length);
0169:
0170:            }
0171:
0172:            public final void testGetData() {
0173:                int data[];
0174:
0175:                data = db1.getData();
0176:                assertEquals(arraySize, data.length);
0177:
0178:                data = db2.getData();
0179:                assertEquals(arraySize, data.length);
0180:
0181:                data = db3.getData();
0182:                assertEquals(arraySize, data.length);
0183:
0184:                data = db4.getData();
0185:                assertEquals(arraySize, data.length);
0186:
0187:                data = db5.getData();
0188:                assertEquals(size, data.length);
0189:
0190:                data = db6.getData();
0191:                assertEquals(size, data.length);
0192:            }
0193:
0194:            public final void testGetDataBank() {
0195:                int data[];
0196:
0197:                for (int i = 0; i < db1.getNumBanks(); i++) {
0198:                    data = db1.getData(i);
0199:                    assertEquals(arraySize, data.length);
0200:                }
0201:
0202:                for (int i = 0; i < db2.getNumBanks(); i++) {
0203:                    data = db2.getData(i);
0204:                    assertEquals(arraySize, data.length);
0205:                }
0206:
0207:                for (int i = 0; i < db3.getNumBanks(); i++) {
0208:                    data = db3.getData(i);
0209:                    assertEquals(arraySize, data.length);
0210:                }
0211:
0212:                for (int i = 0; i < db4.getNumBanks(); i++) {
0213:                    data = db4.getData(i);
0214:                    assertEquals(arraySize, data.length);
0215:                }
0216:
0217:                for (int i = 0; i < db5.getNumBanks(); i++) {
0218:                    data = db5.getData(i);
0219:                    assertEquals(size, data.length);
0220:                }
0221:
0222:                for (int i = 0; i < db6.getNumBanks(); i++) {
0223:                    data = db6.getData(i);
0224:                    assertEquals(size, data.length);
0225:                }
0226:            }
0227:
0228:            public final void testSetElemBank() {
0229:                int data[];
0230:                int offsets[];
0231:
0232:                for (int i = 0; i < db1.getNumBanks(); i++) {
0233:                    for (int j = 0; j < db1.getSize(); j++) {
0234:                        db1.setElem(i, j, j);
0235:                    }
0236:                }
0237:                offsets = db1.getOffsets();
0238:                for (int i = 0; i < db1.getNumBanks(); i++) {
0239:                    data = db1.getData(i);
0240:                    for (int j = 0; j < size; j++) {
0241:                        assertEquals(j, data[offsets[i] + j]);
0242:                    }
0243:                }
0244:
0245:                for (int i = 0; i < db2.getNumBanks(); i++) {
0246:                    for (int j = 0; j < db2.getSize(); j++) {
0247:                        db2.setElem(i, j, j);
0248:                    }
0249:                }
0250:                offsets = db2.getOffsets();
0251:                for (int i = 0; i < db2.getNumBanks(); i++) {
0252:                    data = db2.getData(i);
0253:                    for (int j = 0; j < size; j++) {
0254:                        assertEquals(j, data[offsets[i] + j]);
0255:                    }
0256:                }
0257:
0258:                for (int i = 0; i < db3.getNumBanks(); i++) {
0259:                    for (int j = 0; j < db3.getSize(); j++) {
0260:                        db3.setElem(i, j, j);
0261:                    }
0262:                }
0263:                offsets = db3.getOffsets();
0264:                for (int i = 0; i < db3.getNumBanks(); i++) {
0265:                    data = db3.getData(i);
0266:                    for (int j = 0; j < size; j++) {
0267:                        assertEquals(j, data[offsets[i] + j]);
0268:                    }
0269:                }
0270:
0271:                for (int i = 0; i < db4.getNumBanks(); i++) {
0272:                    for (int j = 0; j < db4.getSize(); j++) {
0273:                        db4.setElem(i, j, j);
0274:                    }
0275:                }
0276:                offsets = db4.getOffsets();
0277:                for (int i = 0; i < db4.getNumBanks(); i++) {
0278:                    data = db4.getData(i);
0279:                    for (int j = 0; j < size; j++) {
0280:                        assertEquals(j, data[offsets[i] + j]);
0281:                    }
0282:                }
0283:
0284:                for (int i = 0; i < db5.getNumBanks(); i++) {
0285:                    for (int j = 0; j < db5.getSize(); j++) {
0286:                        db5.setElem(i, j, j);
0287:                    }
0288:                }
0289:                offsets = db5.getOffsets();
0290:                for (int i = 0; i < db5.getNumBanks(); i++) {
0291:                    data = db5.getData(i);
0292:                    for (int j = 0; j < size; j++) {
0293:                        assertEquals(j, data[offsets[i] + j]);
0294:                    }
0295:                }
0296:
0297:                for (int i = 0; i < db6.getNumBanks(); i++) {
0298:                    for (int j = 0; j < db6.getSize(); j++) {
0299:                        db6.setElem(i, j, j);
0300:                    }
0301:                }
0302:                offsets = db6.getOffsets();
0303:                for (int i = 0; i < db6.getNumBanks(); i++) {
0304:                    data = db6.getData(i);
0305:                    for (int j = 0; j < size; j++) {
0306:                        assertEquals(j, data[offsets[i] + j]);
0307:                    }
0308:                }
0309:
0310:            }
0311:
0312:            public final void testSetElem() {
0313:                int data[];
0314:                int offset;
0315:
0316:                for (int i = 0; i < size; i++) {
0317:                    db1.setElem(i, i);
0318:                }
0319:                data = db1.getData();
0320:                offset = db1.getOffset();
0321:                for (int i = 0; i < size; i++) {
0322:                    assertEquals(i, data[offset + i]);
0323:                }
0324:
0325:                for (int i = 0; i < size; i++) {
0326:                    db2.setElem(i, i);
0327:                }
0328:                data = db2.getData();
0329:                offset = db2.getOffset();
0330:                for (int i = 0; i < size; i++) {
0331:                    assertEquals(i, data[offset + i]);
0332:                }
0333:
0334:                for (int i = 0; i < size; i++) {
0335:                    db3.setElem(i, i);
0336:                }
0337:                data = db3.getData();
0338:                offset = db3.getOffset();
0339:                for (int i = 0; i < size; i++) {
0340:                    assertEquals(i, data[offset + i]);
0341:                }
0342:
0343:                for (int i = 0; i < size; i++) {
0344:                    db4.setElem(i, i);
0345:                }
0346:                data = db4.getData();
0347:                offset = db4.getOffset();
0348:                for (int i = 0; i < size; i++) {
0349:                    assertEquals(i, data[offset + i]);
0350:                }
0351:
0352:                for (int i = 0; i < size; i++) {
0353:                    db5.setElem(i, i);
0354:                }
0355:                data = db5.getData();
0356:                offset = db5.getOffset();
0357:                for (int i = 0; i < size; i++) {
0358:                    assertEquals(i, data[offset + i]);
0359:                }
0360:
0361:                for (int i = 0; i < size; i++) {
0362:                    db6.setElem(i, i);
0363:                }
0364:                data = db6.getData();
0365:                offset = db6.getOffset();
0366:                for (int i = 0; i < size; i++) {
0367:                    assertEquals(i, data[offset + i]);
0368:                }
0369:            }
0370:
0371:            public final void testGetElemBank() {
0372:                int data[];
0373:                int offsets[];
0374:
0375:                offsets = db1.getOffsets();
0376:                for (int i = 0; i < db1.getNumBanks(); i++) {
0377:                    data = db1.getData(i);
0378:                    for (int j = 0; j < size; j++) {
0379:                        data[offsets[i] + j] = j;
0380:                    }
0381:                }
0382:                for (int i = 0; i < db1.getNumBanks(); i++) {
0383:                    for (int j = 0; j < size; j++) {
0384:                        assertEquals(j, db1.getElem(i, j));
0385:                    }
0386:                }
0387:
0388:                offsets = db2.getOffsets();
0389:                for (int i = 0; i < db2.getNumBanks(); i++) {
0390:                    data = db2.getData(i);
0391:                    for (int j = 0; j < size; j++) {
0392:                        data[offsets[i] + j] = j;
0393:                    }
0394:                }
0395:                for (int i = 0; i < db2.getNumBanks(); i++) {
0396:                    for (int j = 0; j < size; j++) {
0397:                        assertEquals(j, db2.getElem(i, j));
0398:                    }
0399:                }
0400:
0401:                offsets = db3.getOffsets();
0402:                for (int i = 0; i < db3.getNumBanks(); i++) {
0403:                    data = db3.getData(i);
0404:                    for (int j = 0; j < size; j++) {
0405:                        data[offsets[i] + j] = j;
0406:                    }
0407:                }
0408:                for (int i = 0; i < db3.getNumBanks(); i++) {
0409:                    for (int j = 0; j < size; j++) {
0410:                        assertEquals(j, db3.getElem(i, j));
0411:                    }
0412:                }
0413:
0414:                offsets = db4.getOffsets();
0415:                for (int i = 0; i < db4.getNumBanks(); i++) {
0416:                    data = db4.getData(i);
0417:                    for (int j = 0; j < size; j++) {
0418:                        data[offsets[i] + j] = j;
0419:                    }
0420:                }
0421:                for (int i = 0; i < db4.getNumBanks(); i++) {
0422:                    for (int j = 0; j < size; j++) {
0423:                        assertEquals(j, db4.getElem(i, j));
0424:                    }
0425:                }
0426:
0427:                offsets = db5.getOffsets();
0428:                for (int i = 0; i < db5.getNumBanks(); i++) {
0429:                    data = db5.getData(i);
0430:                    for (int j = 0; j < size; j++) {
0431:                        data[offsets[i] + j] = j;
0432:                    }
0433:                }
0434:                for (int i = 0; i < db5.getNumBanks(); i++) {
0435:                    for (int j = 0; j < size; j++) {
0436:                        assertEquals(j, db5.getElem(i, j));
0437:                    }
0438:                }
0439:
0440:                offsets = db6.getOffsets();
0441:                for (int i = 0; i < db6.getNumBanks(); i++) {
0442:                    data = db6.getData(i);
0443:                    for (int j = 0; j < size; j++) {
0444:                        data[offsets[i] + j] = j;
0445:                    }
0446:                }
0447:                for (int i = 0; i < db6.getNumBanks(); i++) {
0448:                    for (int j = 0; j < size; j++) {
0449:                        assertEquals(j, db6.getElem(i, j));
0450:                    }
0451:                }
0452:            }
0453:
0454:            public final void testGetElem() {
0455:                int data[];
0456:                int offset;
0457:
0458:                data = db1.getData();
0459:                offset = db1.getOffset();
0460:                for (int i = 0; i < size; i++) {
0461:                    data[offset + i] = i;
0462:                }
0463:                for (int i = 0; i < size; i++) {
0464:                    assertEquals(i, db1.getElem(i));
0465:                }
0466:
0467:                data = db2.getData();
0468:                offset = db2.getOffset();
0469:                for (int i = 0; i < size; i++) {
0470:                    data[offset + i] = i;
0471:                }
0472:                for (int i = 0; i < size; i++) {
0473:                    assertEquals(i, db2.getElem(i));
0474:                }
0475:
0476:                data = db3.getData();
0477:                offset = db3.getOffset();
0478:                for (int i = 0; i < size; i++) {
0479:                    data[offset + i] = i;
0480:                }
0481:                for (int i = 0; i < size; i++) {
0482:                    assertEquals(i, db3.getElem(i));
0483:                }
0484:
0485:                data = db4.getData();
0486:                offset = db4.getOffset();
0487:                for (int i = 0; i < size; i++) {
0488:                    data[offset + i] = i;
0489:                }
0490:                for (int i = 0; i < size; i++) {
0491:                    assertEquals(i, db4.getElem(i));
0492:                }
0493:
0494:                data = db5.getData();
0495:                offset = db5.getOffset();
0496:                for (int i = 0; i < size; i++) {
0497:                    data[offset + i] = i;
0498:                }
0499:                for (int i = 0; i < size; i++) {
0500:                    assertEquals(i, db5.getElem(i));
0501:                }
0502:
0503:                data = db6.getData();
0504:                offset = db6.getOffset();
0505:                for (int i = 0; i < size; i++) {
0506:                    data[offset + i] = i;
0507:                }
0508:                for (int i = 0; i < size; i++) {
0509:                    assertEquals(i, db6.getElem(i));
0510:                }
0511:            }
0512:
0513:            public final void testSetElemFloatBank() {
0514:                int data[];
0515:                int offsets[];
0516:
0517:                for (int i = 0; i < db1.getNumBanks(); i++) {
0518:                    for (int j = 0; j < db1.getSize(); j++) {
0519:                        db1.setElemFloat(i, j, j);
0520:                    }
0521:                }
0522:                offsets = db1.getOffsets();
0523:                for (int i = 0; i < db1.getNumBanks(); i++) {
0524:                    data = db1.getData(i);
0525:                    for (int j = 0; j < size; j++) {
0526:                        assertEquals(j, data[offsets[i] + j]);
0527:                    }
0528:                }
0529:
0530:                for (int i = 0; i < db2.getNumBanks(); i++) {
0531:                    for (int j = 0; j < db2.getSize(); j++) {
0532:                        db2.setElemFloat(i, j, j);
0533:                    }
0534:                }
0535:                offsets = db2.getOffsets();
0536:                for (int i = 0; i < db2.getNumBanks(); i++) {
0537:                    data = db2.getData(i);
0538:                    for (int j = 0; j < size; j++) {
0539:                        assertEquals(j, data[offsets[i] + j]);
0540:                    }
0541:                }
0542:
0543:                for (int i = 0; i < db3.getNumBanks(); i++) {
0544:                    for (int j = 0; j < db3.getSize(); j++) {
0545:                        db3.setElemFloat(i, j, j);
0546:                    }
0547:                }
0548:                offsets = db3.getOffsets();
0549:                for (int i = 0; i < db3.getNumBanks(); i++) {
0550:                    data = db3.getData(i);
0551:                    for (int j = 0; j < size; j++) {
0552:                        assertEquals(j, data[offsets[i] + j]);
0553:                    }
0554:                }
0555:
0556:                for (int i = 0; i < db4.getNumBanks(); i++) {
0557:                    for (int j = 0; j < db4.getSize(); j++) {
0558:                        db4.setElemFloat(i, j, j);
0559:                    }
0560:                }
0561:                offsets = db4.getOffsets();
0562:                for (int i = 0; i < db4.getNumBanks(); i++) {
0563:                    data = db4.getData(i);
0564:                    for (int j = 0; j < size; j++) {
0565:                        assertEquals(j, data[offsets[i] + j]);
0566:                    }
0567:                }
0568:
0569:                for (int i = 0; i < db5.getNumBanks(); i++) {
0570:                    for (int j = 0; j < db5.getSize(); j++) {
0571:                        db5.setElemFloat(i, j, j);
0572:                    }
0573:                }
0574:                offsets = db5.getOffsets();
0575:                for (int i = 0; i < db5.getNumBanks(); i++) {
0576:                    data = db5.getData(i);
0577:                    for (int j = 0; j < size; j++) {
0578:                        assertEquals(j, data[offsets[i] + j]);
0579:                    }
0580:                }
0581:
0582:                for (int i = 0; i < db6.getNumBanks(); i++) {
0583:                    for (int j = 0; j < db6.getSize(); j++) {
0584:                        db6.setElemFloat(i, j, j);
0585:                    }
0586:                }
0587:                offsets = db6.getOffsets();
0588:                for (int i = 0; i < db6.getNumBanks(); i++) {
0589:                    data = db6.getData(i);
0590:                    for (int j = 0; j < size; j++) {
0591:                        assertEquals(j, data[offsets[i] + j]);
0592:                    }
0593:                }
0594:
0595:            }
0596:
0597:            public final void testSetElemFloat() {
0598:                int data[];
0599:                int offset;
0600:
0601:                for (int i = 0; i < size; i++) {
0602:                    db1.setElemFloat(i, i);
0603:                }
0604:                data = db1.getData();
0605:                offset = db1.getOffset();
0606:                for (int i = 0; i < size; i++) {
0607:                    assertEquals(i, data[offset + i]);
0608:                }
0609:
0610:                for (int i = 0; i < size; i++) {
0611:                    db2.setElemFloat(i, i);
0612:                }
0613:                data = db2.getData();
0614:                offset = db2.getOffset();
0615:                for (int i = 0; i < size; i++) {
0616:                    assertEquals(i, data[offset + i]);
0617:                }
0618:
0619:                for (int i = 0; i < size; i++) {
0620:                    db3.setElemFloat(i, i);
0621:                }
0622:                data = db3.getData();
0623:                offset = db3.getOffset();
0624:                for (int i = 0; i < size; i++) {
0625:                    assertEquals(i, data[offset + i]);
0626:                }
0627:
0628:                for (int i = 0; i < size; i++) {
0629:                    db4.setElemFloat(i, i);
0630:                }
0631:                data = db4.getData();
0632:                offset = db4.getOffset();
0633:                for (int i = 0; i < size; i++) {
0634:                    assertEquals(i, data[offset + i]);
0635:                }
0636:
0637:                for (int i = 0; i < size; i++) {
0638:                    db5.setElemFloat(i, i);
0639:                }
0640:                data = db5.getData();
0641:                offset = db5.getOffset();
0642:                for (int i = 0; i < size; i++) {
0643:                    assertEquals(i, data[offset + i]);
0644:                }
0645:
0646:                for (int i = 0; i < size; i++) {
0647:                    db6.setElemFloat(i, i);
0648:                }
0649:                data = db6.getData();
0650:                offset = db6.getOffset();
0651:                for (int i = 0; i < size; i++) {
0652:                    assertEquals(i, data[offset + i]);
0653:                }
0654:            }
0655:
0656:            public final void testGetElemFloatBank() {
0657:                int data[];
0658:                int offsets[];
0659:
0660:                offsets = db1.getOffsets();
0661:                for (int i = 0; i < db1.getNumBanks(); i++) {
0662:                    data = db1.getData(i);
0663:                    for (int j = 0; j < size; j++) {
0664:                        data[offsets[i] + j] = j;
0665:                    }
0666:                }
0667:                for (int i = 0; i < db1.getNumBanks(); i++) {
0668:                    for (int j = 0; j < size; j++) {
0669:                        assertEquals(j, db1.getElemFloat(i, j), 0f);
0670:                    }
0671:                }
0672:
0673:                offsets = db2.getOffsets();
0674:                for (int i = 0; i < db2.getNumBanks(); i++) {
0675:                    data = db2.getData(i);
0676:                    for (int j = 0; j < size; j++) {
0677:                        data[offsets[i] + j] = j;
0678:                    }
0679:                }
0680:                for (int i = 0; i < db2.getNumBanks(); i++) {
0681:                    for (int j = 0; j < size; j++) {
0682:                        assertEquals(j, db2.getElem(i, j), 0f);
0683:                    }
0684:                }
0685:
0686:                offsets = db3.getOffsets();
0687:                for (int i = 0; i < db3.getNumBanks(); i++) {
0688:                    data = db3.getData(i);
0689:                    for (int j = 0; j < size; j++) {
0690:                        data[offsets[i] + j] = j;
0691:                    }
0692:                }
0693:                for (int i = 0; i < db3.getNumBanks(); i++) {
0694:                    for (int j = 0; j < size; j++) {
0695:                        assertEquals(j, db3.getElemFloat(i, j), 0f);
0696:                    }
0697:                }
0698:
0699:                offsets = db4.getOffsets();
0700:                for (int i = 0; i < db4.getNumBanks(); i++) {
0701:                    data = db4.getData(i);
0702:                    for (int j = 0; j < size; j++) {
0703:                        data[offsets[i] + j] = j;
0704:                    }
0705:                }
0706:                for (int i = 0; i < db4.getNumBanks(); i++) {
0707:                    for (int j = 0; j < size; j++) {
0708:                        assertEquals(j, db4.getElemFloat(i, j), 0f);
0709:                    }
0710:                }
0711:
0712:                offsets = db5.getOffsets();
0713:                for (int i = 0; i < db5.getNumBanks(); i++) {
0714:                    data = db5.getData(i);
0715:                    for (int j = 0; j < size; j++) {
0716:                        data[offsets[i] + j] = j;
0717:                    }
0718:                }
0719:                for (int i = 0; i < db5.getNumBanks(); i++) {
0720:                    for (int j = 0; j < size; j++) {
0721:                        assertEquals(j, db5.getElemFloat(i, j), 0f);
0722:                    }
0723:                }
0724:
0725:                offsets = db6.getOffsets();
0726:                for (int i = 0; i < db6.getNumBanks(); i++) {
0727:                    data = db6.getData(i);
0728:                    for (int j = 0; j < size; j++) {
0729:                        data[offsets[i] + j] = j;
0730:                    }
0731:                }
0732:                for (int i = 0; i < db6.getNumBanks(); i++) {
0733:                    for (int j = 0; j < size; j++) {
0734:                        assertEquals(j, db6.getElemFloat(i, j), 0f);
0735:                    }
0736:                }
0737:            }
0738:
0739:            public final void testGetElemFloat() {
0740:                int data[];
0741:                int offset;
0742:
0743:                data = db1.getData();
0744:                offset = db1.getOffset();
0745:                for (int i = 0; i < size; i++) {
0746:                    data[offset + i] = i;
0747:                }
0748:                for (int i = 0; i < size; i++) {
0749:                    assertEquals(i, db1.getElemFloat(i), 0f);
0750:                }
0751:
0752:                data = db2.getData();
0753:                offset = db2.getOffset();
0754:                for (int i = 0; i < size; i++) {
0755:                    data[offset + i] = i;
0756:                }
0757:                for (int i = 0; i < size; i++) {
0758:                    assertEquals(i, db2.getElemFloat(i), 0f);
0759:                }
0760:
0761:                data = db3.getData();
0762:                offset = db3.getOffset();
0763:                for (int i = 0; i < size; i++) {
0764:                    data[offset + i] = i;
0765:                }
0766:                for (int i = 0; i < size; i++) {
0767:                    assertEquals(i, db3.getElemFloat(i), 0f);
0768:                }
0769:
0770:                data = db4.getData();
0771:                offset = db4.getOffset();
0772:                for (int i = 0; i < size; i++) {
0773:                    data[offset + i] = i;
0774:                }
0775:                for (int i = 0; i < size; i++) {
0776:                    assertEquals(i, db4.getElemFloat(i), 0f);
0777:                }
0778:
0779:                data = db5.getData();
0780:                offset = db5.getOffset();
0781:                for (int i = 0; i < size; i++) {
0782:                    data[offset + i] = i;
0783:                }
0784:                for (int i = 0; i < size; i++) {
0785:                    assertEquals(i, db5.getElemFloat(i), 0f);
0786:                }
0787:
0788:                data = db6.getData();
0789:                offset = db6.getOffset();
0790:                for (int i = 0; i < size; i++) {
0791:                    data[offset + i] = i;
0792:                }
0793:                for (int i = 0; i < size; i++) {
0794:                    assertEquals(i, db6.getElemFloat(i), 0f);
0795:                }
0796:            }
0797:
0798:            public final void testSetElemDoubleBank() {
0799:                int data[];
0800:                int offsets[];
0801:
0802:                for (int i = 0; i < db1.getNumBanks(); i++) {
0803:                    for (int j = 0; j < db1.getSize(); j++) {
0804:                        db1.setElemDouble(i, j, j);
0805:                    }
0806:                }
0807:                offsets = db1.getOffsets();
0808:                for (int i = 0; i < db1.getNumBanks(); i++) {
0809:                    data = db1.getData(i);
0810:                    for (int j = 0; j < size; j++) {
0811:                        assertEquals(j, data[offsets[i] + j]);
0812:                    }
0813:                }
0814:
0815:                for (int i = 0; i < db2.getNumBanks(); i++) {
0816:                    for (int j = 0; j < db2.getSize(); j++) {
0817:                        db2.setElemDouble(i, j, j);
0818:                    }
0819:                }
0820:                offsets = db2.getOffsets();
0821:                for (int i = 0; i < db2.getNumBanks(); i++) {
0822:                    data = db2.getData(i);
0823:                    for (int j = 0; j < size; j++) {
0824:                        assertEquals(j, data[offsets[i] + j]);
0825:                    }
0826:                }
0827:
0828:                for (int i = 0; i < db3.getNumBanks(); i++) {
0829:                    for (int j = 0; j < db3.getSize(); j++) {
0830:                        db3.setElemDouble(i, j, j);
0831:                    }
0832:                }
0833:                offsets = db3.getOffsets();
0834:                for (int i = 0; i < db3.getNumBanks(); i++) {
0835:                    data = db3.getData(i);
0836:                    for (int j = 0; j < size; j++) {
0837:                        assertEquals(j, data[offsets[i] + j]);
0838:                    }
0839:                }
0840:
0841:                for (int i = 0; i < db4.getNumBanks(); i++) {
0842:                    for (int j = 0; j < db4.getSize(); j++) {
0843:                        db4.setElemDouble(i, j, j);
0844:                    }
0845:                }
0846:                offsets = db4.getOffsets();
0847:                for (int i = 0; i < db4.getNumBanks(); i++) {
0848:                    data = db4.getData(i);
0849:                    for (int j = 0; j < size; j++) {
0850:                        assertEquals(j, data[offsets[i] + j]);
0851:                    }
0852:                }
0853:
0854:                for (int i = 0; i < db5.getNumBanks(); i++) {
0855:                    for (int j = 0; j < db5.getSize(); j++) {
0856:                        db5.setElemDouble(i, j, j);
0857:                    }
0858:                }
0859:                offsets = db5.getOffsets();
0860:                for (int i = 0; i < db5.getNumBanks(); i++) {
0861:                    data = db5.getData(i);
0862:                    for (int j = 0; j < size; j++) {
0863:                        assertEquals(j, data[offsets[i] + j]);
0864:                    }
0865:                }
0866:
0867:                for (int i = 0; i < db6.getNumBanks(); i++) {
0868:                    for (int j = 0; j < db6.getSize(); j++) {
0869:                        db6.setElemDouble(i, j, j);
0870:                    }
0871:                }
0872:                offsets = db6.getOffsets();
0873:                for (int i = 0; i < db6.getNumBanks(); i++) {
0874:                    data = db6.getData(i);
0875:                    for (int j = 0; j < size; j++) {
0876:                        assertEquals(j, data[offsets[i] + j]);
0877:                    }
0878:                }
0879:
0880:            }
0881:
0882:            public final void testSetElemDouble() {
0883:                int data[];
0884:                int offset;
0885:
0886:                for (int i = 0; i < size; i++) {
0887:                    db1.setElemDouble(i, i);
0888:                }
0889:                data = db1.getData();
0890:                offset = db1.getOffset();
0891:                for (int i = 0; i < size; i++) {
0892:                    assertEquals(i, data[offset + i]);
0893:                }
0894:
0895:                for (int i = 0; i < size; i++) {
0896:                    db2.setElemDouble(i, i);
0897:                }
0898:                data = db2.getData();
0899:                offset = db2.getOffset();
0900:                for (int i = 0; i < size; i++) {
0901:                    assertEquals(i, data[offset + i]);
0902:                }
0903:
0904:                for (int i = 0; i < size; i++) {
0905:                    db3.setElemDouble(i, i);
0906:                }
0907:                data = db3.getData();
0908:                offset = db3.getOffset();
0909:                for (int i = 0; i < size; i++) {
0910:                    assertEquals(i, data[offset + i]);
0911:                }
0912:
0913:                for (int i = 0; i < size; i++) {
0914:                    db4.setElemDouble(i, i);
0915:                }
0916:                data = db4.getData();
0917:                offset = db4.getOffset();
0918:                for (int i = 0; i < size; i++) {
0919:                    assertEquals(i, data[offset + i]);
0920:                }
0921:
0922:                for (int i = 0; i < size; i++) {
0923:                    db5.setElemDouble(i, i);
0924:                }
0925:                data = db5.getData();
0926:                offset = db5.getOffset();
0927:                for (int i = 0; i < size; i++) {
0928:                    assertEquals(i, data[offset + i]);
0929:                }
0930:
0931:                for (int i = 0; i < size; i++) {
0932:                    db6.setElemDouble(i, i);
0933:                }
0934:                data = db6.getData();
0935:                offset = db6.getOffset();
0936:                for (int i = 0; i < size; i++) {
0937:                    assertEquals(i, data[offset + i]);
0938:                }
0939:            }
0940:
0941:            public final void testGetElemDoubleBank() {
0942:                int data[];
0943:                int offsets[];
0944:
0945:                offsets = db1.getOffsets();
0946:                for (int i = 0; i < db1.getNumBanks(); i++) {
0947:                    data = db1.getData(i);
0948:                    for (int j = 0; j < size; j++) {
0949:                        data[offsets[i] + j] = j;
0950:                    }
0951:                }
0952:                for (int i = 0; i < db1.getNumBanks(); i++) {
0953:                    for (int j = 0; j < size; j++) {
0954:                        assertEquals(j, db1.getElemDouble(i, j), 0);
0955:                    }
0956:                }
0957:
0958:                offsets = db2.getOffsets();
0959:                for (int i = 0; i < db2.getNumBanks(); i++) {
0960:                    data = db2.getData(i);
0961:                    for (int j = 0; j < size; j++) {
0962:                        data[offsets[i] + j] = (short) j;
0963:                    }
0964:                }
0965:                for (int i = 0; i < db2.getNumBanks(); i++) {
0966:                    for (int j = 0; j < size; j++) {
0967:                        assertEquals(j, db2.getElemDouble(i, j), 0);
0968:                    }
0969:                }
0970:
0971:                offsets = db3.getOffsets();
0972:                for (int i = 0; i < db3.getNumBanks(); i++) {
0973:                    data = db3.getData(i);
0974:                    for (int j = 0; j < size; j++) {
0975:                        data[offsets[i] + j] = (short) j;
0976:                    }
0977:                }
0978:                for (int i = 0; i < db3.getNumBanks(); i++) {
0979:                    for (int j = 0; j < size; j++) {
0980:                        assertEquals(j, db3.getElemDouble(i, j), 0);
0981:                    }
0982:                }
0983:
0984:                offsets = db4.getOffsets();
0985:                for (int i = 0; i < db4.getNumBanks(); i++) {
0986:                    data = db4.getData(i);
0987:                    for (int j = 0; j < size; j++) {
0988:                        data[offsets[i] + j] = (short) j;
0989:                    }
0990:                }
0991:                for (int i = 0; i < db4.getNumBanks(); i++) {
0992:                    for (int j = 0; j < size; j++) {
0993:                        assertEquals(j, db4.getElemDouble(i, j), 0);
0994:                    }
0995:                }
0996:
0997:                offsets = db5.getOffsets();
0998:                for (int i = 0; i < db5.getNumBanks(); i++) {
0999:                    data = db5.getData(i);
1000:                    for (int j = 0; j < size; j++) {
1001:                        data[offsets[i] + j] = (short) j;
1002:                    }
1003:                }
1004:                for (int i = 0; i < db5.getNumBanks(); i++) {
1005:                    for (int j = 0; j < size; j++) {
1006:                        assertEquals(j, db5.getElemDouble(i, j), 0);
1007:                    }
1008:                }
1009:
1010:                offsets = db6.getOffsets();
1011:                for (int i = 0; i < db6.getNumBanks(); i++) {
1012:                    data = db6.getData(i);
1013:                    for (int j = 0; j < size; j++) {
1014:                        data[offsets[i] + j] = (short) j;
1015:                    }
1016:                }
1017:                for (int i = 0; i < db6.getNumBanks(); i++) {
1018:                    for (int j = 0; j < size; j++) {
1019:                        assertEquals(j, db6.getElemDouble(i, j), 0);
1020:                    }
1021:                }
1022:            }
1023:
1024:            public final void testGetElemDouble() {
1025:                int data[];
1026:                int offset;
1027:
1028:                data = db1.getData();
1029:                offset = db1.getOffset();
1030:                for (int i = 0; i < size; i++) {
1031:                    data[offset + i] = i;
1032:                }
1033:                for (int i = 0; i < size; i++) {
1034:                    assertEquals(i, db1.getElemDouble(i), 0);
1035:                }
1036:
1037:                data = db2.getData();
1038:                offset = db2.getOffset();
1039:                for (int i = 0; i < size; i++) {
1040:                    data[offset + i] = i;
1041:                }
1042:                for (int i = 0; i < size; i++) {
1043:                    assertEquals(i, db2.getElemDouble(i), 0);
1044:                }
1045:
1046:                data = db3.getData();
1047:                offset = db3.getOffset();
1048:                for (int i = 0; i < size; i++) {
1049:                    data[offset + i] = i;
1050:                }
1051:                for (int i = 0; i < size; i++) {
1052:                    assertEquals(i, db3.getElemDouble(i), 0);
1053:                }
1054:
1055:                data = db4.getData();
1056:                offset = db4.getOffset();
1057:                for (int i = 0; i < size; i++) {
1058:                    data[offset + i] = i;
1059:                }
1060:                for (int i = 0; i < size; i++) {
1061:                    assertEquals(i, db4.getElemDouble(i), 0);
1062:                }
1063:
1064:                data = db5.getData();
1065:                offset = db5.getOffset();
1066:                for (int i = 0; i < size; i++) {
1067:                    data[offset + i] = i;
1068:                }
1069:                for (int i = 0; i < size; i++) {
1070:                    assertEquals(i, db5.getElemDouble(i), 0);
1071:                }
1072:
1073:                data = db6.getData();
1074:                offset = db6.getOffset();
1075:                for (int i = 0; i < size; i++) {
1076:                    data[offset + i] = i;
1077:                }
1078:                for (int i = 0; i < size; i++) {
1079:                    assertEquals(i, db6.getElemDouble(i), 0);
1080:                }
1081:            }
1082:
1083:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.