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