from chrysacase import ChrysalideTestCase
from pychrysalide.plugins import encodings

import base64


class TestEncodingsModule(ChrysalideTestCase):
    """TestCase for encodings plugin."""

    def testBase64Encoding(self):
        """Validate the base64 implementation."""

        text = '0123456789abcdef'

        for i in range(len(text) + 1):

            src = text[:i].encode('ascii')

            encoded = encodings.base64_encode(src)
            ref = base64.b64encode(src)

            self.assertEqual(encoded, ref)