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