home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 June / PCWorld_2005-06_cd.bin / software / vyzkuste / firewally / firewally.exe / framework-2.3.exe / test_base64.py < prev    next >
Text File  |  2003-12-30  |  2KB  |  38 lines

  1. import unittest
  2. from test import test_support
  3. import base64
  4.  
  5. class Base64TestCase(unittest.TestCase):
  6.  
  7.     def test_encodestring(self):
  8.         self.assertEqual(base64.encodestring("www.python.org"), "d3d3LnB5dGhvbi5vcmc=\n")
  9.         self.assertEqual(base64.encodestring("a"), "YQ==\n")
  10.         self.assertEqual(base64.encodestring("ab"), "YWI=\n")
  11.         self.assertEqual(base64.encodestring("abc"), "YWJj\n")
  12.         self.assertEqual(base64.encodestring(""), "")
  13.         self.assertEqual(base64.encodestring("abcdefghijklmnopqrstuvwxyz"
  14.                            "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  15.                            "0123456789!@#0^&*();:<>,. []{}"),
  16.               "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
  17.               "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT"
  18.               "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==\n")
  19.  
  20.     def test_decodestring(self):
  21.         self.assertEqual(base64.decodestring("d3d3LnB5dGhvbi5vcmc=\n"), "www.python.org")
  22.         self.assertEqual(base64.decodestring("YQ==\n"), "a")
  23.         self.assertEqual(base64.decodestring("YWI=\n"), "ab")
  24.         self.assertEqual(base64.decodestring("YWJj\n"), "abc")
  25.         self.assertEqual(base64.decodestring("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
  26.                            "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT"
  27.                            "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==\n"),
  28.               "abcdefghijklmnopqrstuvwxyz"
  29.               "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  30.               "0123456789!@#0^&*();:<>,. []{}")
  31.         self.assertEqual(base64.decodestring(''), '')
  32.  
  33. def test_main():
  34.     test_support.run_unittest(Base64TestCase)
  35.  
  36. if __name__ == "__main__":
  37.     test_main()
  38.