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