class TestStringList_StartWithList(unittest.TestCase):
    """
    Test basic functionality of a StringList when the initial value is a series
    of strings.
    """

    def setUp(self):
        from stringlist import StringList
        self.sl = StringList('hello', 'world')
        
    def test_getitem_slice(self):
        """
        Does index and slice access work?
        """
        self.assertEquals(self.sl[0], 'hello')
        self.assertEquals(self.sl[:-1], ['hello'])
        
    def test_pop(self):
        """
        Does a common function proxy properly?
        """
        self.sl.pop()
        
        self.assertEquals(self.sl, ['hello'])
        
    def test_addition_string(self):
        """
        Does StringList + a string work?
        """
        new_sl = self.sl + 'foo'
        
        self.assertEquals(new_sl, ['hello', 'world', 'foo'])
        
        # make sure the original property isn't altered.
        self.assertEquals(self.sl, ['hello', 'world'])
        
    def test_addition_list(self):
        """
        Does StringList += a list work?
        """
        new_sl = self.sl + ['foo', 'bar']
        
        self.assertEquals(new_sl, ['hello', 'world', 'foo', 'bar'])
        
        # make sure the original property isn't altered.
        self.assertEquals(self.sl, ['hello', 'world'])
        
    def test_inline_addition_string(self):
        """
        Does StringList += a string work?
        """
        self.sl += 'foo'
        
        self.assertEquals(self.sl, ['hello', 'world', 'foo'])
        
    def test_inline_addition_list(self):
        """
        Does StringList += a list work?
        """
        self.sl += ['foo', 'bar']
        
        self.assertEquals(self.sl, ['hello', 'world', 'foo', 'bar'])
        
    def test_iteration(self):
        """
        Can you loop over a StringList?
        """
        output = []
        
        for x in self.sl:
            output.append(x)
            
        self.assertEquals(output, ['hello', 'world'])
            
        self.assertEquals([x for x in self.sl], ['hello', 'world'])
        
    def test_contains(self):
        """
        Does x in StringList work?
        """
        self.assertTrue('hello' in self.sl)
        self.assertFalse('foo' in self.sl)
        
    def test_delete(self):
        """
        Test del StringList[x]
        """
        del self.sl[0]
        
        self.assertEquals(self.sl, ['world'])
        
    def test_index_assignment(self):
        """
        Test StringList[x] = 'string'
        """
        self.sl[1] = 'foo'
        
        self.assertEquals(self.sl, ['hello', 'foo'])
        
    def test_length(self):
        """
        len(StringList)
        """
        self.assertEquals(len(self.sl), 2)
        
        
    def test_inline_addition_integer(self):
        """
        StringList += 100
        """
        self.sl += 100
            
        self.assertEquals(self.sl, ['hello', 'world', 100])
        
    def test_addition_object(self):
        """
        StringList + 100
        """
        new_sl = self.sl + 100
        
        self.assertEquals(new_sl, ['hello', 'world', 100])
        
        self.assertEquals(self.sl, ['hello', 'world'])
            
    def test_cast_to_string(self):
        """
        str(StringList)
        """
        self.assertEquals(str(self.sl), "['hello', 'world']")