FileDocCategorySizeDatePackage
AddressUnitTests.javaAPI DocAndroid 1.5 API4483Wed May 06 22:42:46 BST 2009com.android.email.mail

AddressUnitTests

public class AddressUnitTests extends android.test.AndroidTestCase
This is a series of unit tests for the Address class. These tests must be locally complete - no server(s) required.

Fields Summary
Address
mAddress1
Address
mAddress2
Address
mAddress3
Constructors Summary
Methods Summary
protected voidsetUp()
Setup code. We generate a handful of Address objects

        super.setUp();

        mAddress1 = new Address("address1", "personal1");
        mAddress2 = new Address("address2", "");
        mAddress3 = new Address("address3", null);
    
public voidtestEmptyPack()
Simple quick checks of empty-input edge conditions for pack() NOTE: This is not a claim that these edge cases are "correct", only to maintain consistent behavior while I am changing some of the code in the function under test.

        String result;
        
        // null input => null string
        result = Address.pack(null);
        assertNull("packing null", result);
        
        // zero-length input => empty string
        result = Address.pack(new Address[] { });
        assertEquals("packing empty array", "", result);
    
public voidtestEmptyParse()
Simple quick checks of empty-input edge conditions for parse() NOTE: This is not a claim that these edge cases are "correct", only to maintain consistent behavior while I am changing some of the code in the function under test.

        Address[] result;
        
        // null input => empty array
        result = Address.parse(null);
        assertTrue("parsing null address", result != null && result.length == 0);
        
        // empty string input => empty array
        result = Address.parse("");
        assertTrue("parsing zero-length", result != null && result.length == 0);
    
public voidtestEmptyUnpack()
Simple quick checks of empty-input edge conditions for unpack() NOTE: This is not a claim that these edge cases are "correct", only to maintain consistent behavior while I am changing some of the code in the function under test.

        Address[] result;
        
        // null input => empty array
        result = Address.unpack(null);
        assertTrue("unpacking null address", result != null && result.length == 0);
        
        // empty string input => empty array
        result = Address.unpack("");
        assertTrue("unpacking zero-length", result != null && result.length == 0);
    
public voidtestToFriendlyArray()
Test various combinations of the toFriendly (array) method

        
        Address[] list1 = null;
        Address[] list2 = new Address[0];
        Address[] list3 = new Address[] { mAddress1 };
        Address[] list4 = new Address[] { mAddress1, mAddress2, mAddress3 };
        
        assertEquals(null, Address.toFriendly(list1));
        assertEquals(null, Address.toFriendly(list2));
        assertEquals("personal1", Address.toFriendly(list3));
        assertEquals("personal1,address2,address3", Address.toFriendly(list4));
    
public voidtestToFriendlySingle()
Test various combinations of the toFriendly (single) method

        
        assertEquals("personal1", mAddress1.toFriendly());
        assertEquals("address2", mAddress2.toFriendly());
        assertEquals("address3", mAddress3.toFriendly());