File: base64_decoder.py

package info (click to toggle)
dfvfs 20160918-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 96,408 kB
  • ctags: 2,759
  • sloc: python: 22,682; makefile: 57; vhdl: 25; sh: 16
file content (31 lines) | stat: -rw-r--r-- 804 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Tests for the base64 decoder object."""

import unittest

from dfvfs.encoding import base64_decoder
from dfvfs.lib import errors

from tests.encoding import test_lib


class Base64DecoderTestCase(test_lib.DecoderTestCase):
  """Tests for the base64 decoder object."""

  def testDecode(self):
    """Tests the Decode method."""
    decoder = base64_decoder.Base64Decoder()

    decoded_data, _ = decoder.Decode(b'AQIDBAUGBwg=')
    expected_decoded_data = b'\x01\x02\x03\x04\x05\x06\x07\x08'
    self.assertEqual(decoded_data, expected_decoded_data)

    decoder = base64_decoder.Base64Decoder()

    with self.assertRaises(errors.BackEndError):
      _, _ = decoder.Decode(b'\x01\x02\x03\x04\x05\x06\x07\x08A')


if __name__ == '__main__':
  unittest.main()