Search in sources :

Example 1 with BitwiseOutputStream

use of com.android.internal.util.BitwiseOutputStream in project android_frameworks_base by ParanoidAndroid.

the class BitwiseStreamsTest method testThree.

@SmallTest
public void testThree() throws Exception {
    int offset = 4;
    byte[] inBuf = HexDump.hexStringToByteArray("00031040900112488ea794e0");
    BitwiseOutputStream outStream = new BitwiseOutputStream(30);
    outStream.skip(offset);
    for (int i = 0; i < inBuf.length; i++) outStream.write(8, inBuf[i]);
    BitwiseInputStream inStream = new BitwiseInputStream(outStream.toByteArray());
    inStream.skip(offset);
    byte[] inBufDup = new byte[inBuf.length];
    for (int i = 0; i < inBufDup.length; i++) inBufDup[i] = (byte) inStream.read(8);
    assertEquals(HexDump.toHexString(inBuf), HexDump.toHexString(inBufDup));
}
Also used : BitwiseOutputStream(com.android.internal.util.BitwiseOutputStream) BitwiseInputStream(com.android.internal.util.BitwiseInputStream) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 2 with BitwiseOutputStream

use of com.android.internal.util.BitwiseOutputStream in project android_frameworks_base by ParanoidAndroid.

the class BitwiseStreamsTest method testExpandArray.

@SmallTest
public void testExpandArray() throws Exception {
    Random random = new Random();
    int iterations = 10000;
    int[] sizeArr = new int[iterations];
    int[] valueArr = new int[iterations];
    BitwiseOutputStream outStream = new BitwiseOutputStream(8);
    for (int i = 0; i < iterations; i++) {
        int x = random.nextInt();
        int size = (x & 0x07) + 1;
        int value = x & (-1 >>> (32 - size));
        sizeArr[i] = size;
        valueArr[i] = value;
        outStream.write(size, value);
    }
    BitwiseInputStream inStream = new BitwiseInputStream(outStream.toByteArray());
    for (int i = 0; i < iterations; i++) {
        assertEquals(valueArr[i], inStream.read(sizeArr[i]));
    }
}
Also used : BitwiseOutputStream(com.android.internal.util.BitwiseOutputStream) Random(java.util.Random) BitwiseInputStream(com.android.internal.util.BitwiseInputStream) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 3 with BitwiseOutputStream

use of com.android.internal.util.BitwiseOutputStream in project android_frameworks_base by ParanoidAndroid.

the class BitwiseStreamsTest method testFive.

@SmallTest
public void testFive() throws Exception {
    Random random = new Random();
    int iterations = 10000;
    int[] sizeArr = new int[iterations];
    int[] valueArr = new int[iterations];
    BitwiseOutputStream outStream = new BitwiseOutputStream(iterations * 4);
    for (int i = 0; i < iterations; i++) {
        int x = random.nextInt();
        int size = (x & 0x07) + 1;
        int value = x & (-1 >>> (32 - size));
        sizeArr[i] = size;
        valueArr[i] = value;
        outStream.write(size, value);
    }
    BitwiseInputStream inStream = new BitwiseInputStream(outStream.toByteArray());
    for (int i = 0; i < iterations; i++) {
        assertEquals(valueArr[i], inStream.read(sizeArr[i]));
    }
}
Also used : BitwiseOutputStream(com.android.internal.util.BitwiseOutputStream) Random(java.util.Random) BitwiseInputStream(com.android.internal.util.BitwiseInputStream) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 4 with BitwiseOutputStream

use of com.android.internal.util.BitwiseOutputStream in project android_frameworks_base by ResurrectionRemix.

the class BitwiseStreamsTest method testFive.

@SmallTest
public void testFive() throws Exception {
    Random random = new Random();
    int iterations = 10000;
    int[] sizeArr = new int[iterations];
    int[] valueArr = new int[iterations];
    BitwiseOutputStream outStream = new BitwiseOutputStream(iterations * 4);
    for (int i = 0; i < iterations; i++) {
        int x = random.nextInt();
        int size = (x & 0x07) + 1;
        int value = x & (-1 >>> (32 - size));
        sizeArr[i] = size;
        valueArr[i] = value;
        outStream.write(size, value);
    }
    BitwiseInputStream inStream = new BitwiseInputStream(outStream.toByteArray());
    for (int i = 0; i < iterations; i++) {
        assertEquals(valueArr[i], inStream.read(sizeArr[i]));
    }
}
Also used : BitwiseOutputStream(com.android.internal.util.BitwiseOutputStream) Random(java.util.Random) BitwiseInputStream(com.android.internal.util.BitwiseInputStream) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 5 with BitwiseOutputStream

use of com.android.internal.util.BitwiseOutputStream in project android_frameworks_base by ResurrectionRemix.

the class BitwiseStreamsTest method testThree.

@SmallTest
public void testThree() throws Exception {
    int offset = 4;
    byte[] inBuf = HexDump.hexStringToByteArray("00031040900112488ea794e0");
    BitwiseOutputStream outStream = new BitwiseOutputStream(30);
    outStream.skip(offset);
    for (int i = 0; i < inBuf.length; i++) outStream.write(8, inBuf[i]);
    BitwiseInputStream inStream = new BitwiseInputStream(outStream.toByteArray());
    inStream.skip(offset);
    byte[] inBufDup = new byte[inBuf.length];
    for (int i = 0; i < inBufDup.length; i++) inBufDup[i] = (byte) inStream.read(8);
    assertEquals(HexDump.toHexString(inBuf), HexDump.toHexString(inBufDup));
}
Also used : BitwiseOutputStream(com.android.internal.util.BitwiseOutputStream) BitwiseInputStream(com.android.internal.util.BitwiseInputStream) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

BitwiseOutputStream (com.android.internal.util.BitwiseOutputStream)50 SmallTest (android.test.suitebuilder.annotation.SmallTest)45 BitwiseInputStream (com.android.internal.util.BitwiseInputStream)42 Random (java.util.Random)13 CdmaSmsMessage (android.hardware.radio.V1_0.CdmaSmsMessage)5 FlakyTest (android.support.test.filters.FlakyTest)3 Test (org.junit.Test)3 CdmaSmsCbProgramData (android.telephony.cdma.CdmaSmsCbProgramData)2 SmsCbMessage (android.telephony.SmsCbMessage)1