⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gsmalphabettest.java

📁 goolge phone 目前没有开放的android 平台的源码
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   GsmAlphabetTest.java

package android.telephony.gsm._tests;

import android.content.Context;
import android.telephony.gsm.*;
import android.test.Assert;
import android.test.TestCase;

public class GsmAlphabetTest
    implements TestCase
{

    public GsmAlphabetTest()
    {
    }

    public void setUp(Context context)
    {
        mContext = context;
    }

    public void tearDown()
    {
    }

    public void run()
    {
        try
        {
            Assert.assertEquals(0, GsmAlphabet.charToGsm('@'));
            Assert.assertEquals(127, GsmAlphabet.charToGsm('\340'));
            int i = 0;
            for(int s = "{|}\\[~]\f\u20AC".length(); i < s; i++)
                Assert.assertEquals(27, GsmAlphabet.charToGsm("{|}\\[~]\f\u20AC".charAt(i)));

            Assert.assertEquals(27, GsmAlphabet.charToGsm('\u20AC'));
            Assert.assertEquals(GsmAlphabet.charToGsm(' '), GsmAlphabet.charToGsm('\242'));
            Assert.assertEquals(1, GsmAlphabet.countGsmSeptets('\242'));
            i = 0;
            for(int s = "{|}\\[~]\f\u20AC".length(); i < s; i++)
                Assert.assertEquals("{|}\\[~]\f\u20AC".charAt(i), GsmAlphabet.gsmExtendedToChar(GsmAlphabet.charToGsmExtended("{|}\\[~]\f\u20AC".charAt(i))));

            Assert.assertEquals(GsmAlphabet.charToGsm(' '), GsmAlphabet.charToGsmExtended('@'));
            Assert.assertEquals('@', GsmAlphabet.gsmToChar(0));
            Assert.assertEquals('\340', GsmAlphabet.gsmToChar(127));
            Assert.assertEquals('\uFFFF', GsmAlphabet.gsmToChar(27));
            Assert.assertEquals(' ', GsmAlphabet.gsmToChar(128));
            Assert.assertEquals('{', GsmAlphabet.gsmExtendedToChar(40));
            Assert.assertEquals(' ', GsmAlphabet.gsmExtendedToChar(27));
            Assert.assertEquals(' ', GsmAlphabet.gsmExtendedToChar(0));
            StringBuilder testString = new StringBuilder(300);
            byte packed[];
            int i;
            for(i = 0; i < 9;)
            {
                packed = GsmAlphabet.stringToGsm7BitPacked(testString.toString());
                Assert.assertEquals(testString.toString(), GsmAlphabet.gsm7BitPackedToString(packed, 1, 0xff & packed[0]));
                i++;
                testString.append('@');
            }

            for(i = 0; i < 128; i++)
                if(i != 27)
                {
                    char c = GsmAlphabet.gsmToChar(i);
                    testString.append(c);
                    Assert.assertEquals(1, GsmAlphabet.countGsmSeptets(c));
                }

            packed = GsmAlphabet.stringToGsm7BitPacked(testString.toString());
            Assert.assertEquals(testString.toString(), GsmAlphabet.gsm7BitPackedToString(packed, 1, 0xff & packed[0]));
            testString.append("{|}\\[~]\f\u20AC");
            i = 0;
            for(int s = "{|}\\[~]\f\u20AC".length(); i < s; i++)
                Assert.assertEquals(2, GsmAlphabet.countGsmSeptets("{|}\\[~]\f\u20AC".charAt(i)));

            packed = GsmAlphabet.stringToGsm7BitPacked(testString.toString());
            Assert.assertEquals(testString.toString(), GsmAlphabet.gsm7BitPackedToString(packed, 1, 0xff & packed[0]));
            testString.setLength(0);
            for(i = 0; i < 255; i++)
                testString.append('@');

            packed = GsmAlphabet.stringToGsm7BitPacked(testString.toString());
            Assert.assertEquals(testString.toString(), GsmAlphabet.gsm7BitPackedToString(packed, 1, 0xff & packed[0]));
            testString.append('@');
            try
            {
                GsmAlphabet.stringToGsm7BitPacked(testString.toString());
                Assert.fail("expected exception");
            }
            catch(EncodeException ex) { }
            testString.setLength(0);
            for(ex = 0; ex < 127; ex++)
                testString.append('{');

            packed = GsmAlphabet.stringToGsm7BitPacked(testString.toString());
            Assert.assertEquals(testString.toString(), GsmAlphabet.gsm7BitPackedToString(packed, 1, 0xff & packed[0]));
            testString.append('{');
            try
            {
                GsmAlphabet.stringToGsm7BitPacked(testString.toString());
                Assert.fail("expected exception");
            }
            catch(EncodeException ex) { }
            byte unpacked[] = SimUtils.hexStringToBytes("566F696365204D61696C");
            Assert.assertEquals("Voice Mail", GsmAlphabet.gsm8BitUnpackedToString(unpacked, 0, unpacked.length));
            Assert.assertEquals(SimUtils.bytesToHexString(unpacked), SimUtils.bytesToHexString(GsmAlphabet.stringToGsm8BitPacked("Voice Mail")));
            unpacked = GsmAlphabet.stringToGsm8BitPacked("{|}\\[~]\f\u20AC");
            Assert.assertEquals(2 * "{|}\\[~]\f\u20AC".length(), unpacked.length);
            Assert.assertEquals("{|}\\[~]\f\u20AC", GsmAlphabet.gsm8BitUnpackedToString(unpacked, 0, unpacked.length));
            Assert.assertEquals(2 * "{|}\\[~]\f\u20AC".length(), unpacked.length);
            unpacked = new byte[3];
            GsmAlphabet.stringToGsm8BitUnpackedField("{|}\\[~]\f\u20AC", unpacked, 0, unpacked.length);
            Assert.assertEquals(255, 0xff & unpacked[2]);
            Assert.assertEquals("{|}\\[~]\f\u20AC".substring(0, 1), GsmAlphabet.gsm8BitUnpackedToString(unpacked, 0, unpacked.length));
            unpacked = new byte[3];
            GsmAlphabet.stringToGsm8BitUnpackedField("abcd", unpacked, 0, unpacked.length);
            Assert.assertEquals("abc", GsmAlphabet.gsm8BitUnpackedToString(unpacked, 0, unpacked.length));
            unpacked = new byte[3];
            GsmAlphabet.stringToGsm8BitUnpackedField("a{cd", unpacked, 0, unpacked.length);
            Assert.assertEquals("a{", GsmAlphabet.gsm8BitUnpackedToString(unpacked, 0, unpacked.length));
            unpacked = new byte[3];
            GsmAlphabet.stringToGsm8BitUnpackedField("a", unpacked, 0, unpacked.length);
            Assert.assertEquals("a", GsmAlphabet.gsm8BitUnpackedToString(unpacked, 0, unpacked.length));
            Assert.assertEquals(255, 0xff & unpacked[1]);
            Assert.assertEquals(255, 0xff & unpacked[2]);
            unpacked[0] = 0;
            unpacked[1] = 0;
            unpacked[2] = 27;
            Assert.assertEquals("@@", GsmAlphabet.gsm8BitUnpackedToString(unpacked, 0, unpacked.length));
            Assert.assertEquals("@", GsmAlphabet.gsm8BitUnpackedToString(unpacked, 1, unpacked.length - 1));
            unpacked[0] = 0;
            GsmAlphabet.stringToGsm8BitUnpackedField("abcd", unpacked, 1, unpacked.length - 1);
            Assert.assertTrue(0 == unpacked[0]);
            Assert.assertEquals("ab", GsmAlphabet.gsm8BitUnpackedToString(unpacked, 1, unpacked.length - 1));
            unpacked[0] = 0;
            GsmAlphabet.stringToGsm8BitUnpackedField("a{", unpacked, 1, unpacked.length - 1);
            Assert.assertTrue(0 == unpacked[0]);
            Assert.assertEquals("a", GsmAlphabet.gsm8BitUnpackedToString(unpacked, 1, unpacked.length - 1));
        }
        catch(EncodeException ex)
        {
            throw new RuntimeException("unexpected ex", ex);
        }
    }

    private Context mContext;
    static final String sGsmExtendedChars = "{|}\\[~]\f\u20AC";
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -