예제 #1
0
    def test_address2index_baddata(self):
        with self.assertRaises(UserWarning) as e:
            xl.utility_address2index(address=1)
            self.assertEqual('pylightxl - Address (1) must be a string.', e)

        with self.assertRaises(UserWarning) as e:
            xl.utility_address2index('')
            self.assertEqual(
                'pylightxl - Address ('
                ') cannot be an empty str.', e)

        with self.assertRaises(UserWarning) as e:
            xl.utility_address2index('1')
            self.assertEqual(
                'pylightxl - Incorrect address (1) entry. Address must be an alphanumeric '
                'where the starting character(s) are alpha characters a-z', e)

        with self.assertRaises(UserWarning) as e:
            xl.utility_address2index('1A')
            self.assertEqual(
                'pylightxl - Incorrect address (1A) entry. Address must be an alphanumeric '
                'where the starting character(s) are alpha characters a-z', e)

        with self.assertRaises(UserWarning) as e:
            xl.utility_address2index('AA')
            self.assertEqual(
                'pylightxl - Incorrect address (AA) entry. Address must be an alphanumeric '
                'where the trailing character(s) are numeric characters 1-9',
                e)
예제 #2
0
    def test_address2index(self):
        self.assertEqual(xl.utility_address2index('A1'), [1, 1])
        self.assertEqual(xl.utility_address2index('A1000'), [1000, 1])
        self.assertEqual(xl.utility_address2index('A1048576'), [1048576, 1])

        self.assertEqual(xl.utility_address2index('Z1'), [1, 26])
        self.assertEqual(xl.utility_address2index('AA1'), [1, 27])
        self.assertEqual(xl.utility_address2index('BA1'), [1, 53])
        self.assertEqual(xl.utility_address2index('YQ1'), [1, 667])
        self.assertEqual(xl.utility_address2index('AAA1'), [1, 703])
        self.assertEqual(xl.utility_address2index('AAZ1'), [1, 728])
        self.assertEqual(xl.utility_address2index('PZD1'), [1, 11496])
        self.assertEqual(xl.utility_address2index('QGK1'), [1, 11685])
        self.assertEqual(xl.utility_address2index('XFD1'), [1, 16384])

        self.assertEqual(xl.utility_address2index('XFD1048576'), [1048576, 16384])