FileDocCategorySizeDatePackage
CharSequencesTest.javaAPI DocAndroid 5.1 API1995Thu Mar 12 22:22:12 GMT 2015com.android.internal.util

CharSequencesTest

public class CharSequencesTest extends TestCase

Fields Summary
Constructors Summary
Methods Summary
public voidtestCharSequences()

        String s = "Crazy Bob";
        byte[] bytes = s.getBytes();

        String copy = toString(forAsciiBytes(bytes));
        assertTrue(s.equals(copy));

        copy = toString(forAsciiBytes(bytes, 0, s.length()));
        assertTrue(s.equals(copy));

        String crazy = toString(forAsciiBytes(bytes, 0, 5));
        assertTrue("Crazy".equals(crazy));

        String a = toString(forAsciiBytes(bytes, 0, 3).subSequence(2, 3));
        assertTrue("a".equals(a));

        String empty = toString(forAsciiBytes(bytes, 0, 3).subSequence(3, 3));
        assertTrue("".equals(empty));

        assertTrue(CharSequences.equals("bob", "bob"));
        assertFalse(CharSequences.equals("b", "bob"));
        assertFalse(CharSequences.equals("", "bob"));
    
static java.lang.StringtoString(java.lang.CharSequence charSequence)
Converts a CharSequence to a string the slow way. Useful for testing a CharSequence implementation.

        return new StringBuilder().append(charSequence).toString();