#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Tests for the base16 decoder object."""

import unittest

from dfvfs.encoding import base16_decoder
from dfvfs.encoding import test_lib
from dfvfs.lib import errors


class Base16DecoderTestCase(test_lib.DecoderTestCase):
  """Tests for the base16 decoder object."""

  def testDecode(self):
    """Tests the Decode method."""
    decoder = base16_decoder.Base16Decoder()

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

    decoder = base16_decoder.Base16Decoder()

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


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