File: test_xor.py

package info (click to toggle)
python-pyutil 3.3.2-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 884 kB
  • sloc: python: 7,198; makefile: 6
file content (24 lines) | stat: -rw-r--r-- 746 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
#!/usr/bin/env python
# -*- coding: utf-8-with-signature-unix; fill-column: 77 -*-
# -*- indent-tabs-mode: nil -*-

#  This file is part of pyutil; see README.rst for licensing terms.

import unittest

from pyutil.xor import xor

# unit tests
def _help_test(xf):
    assert xf(b'\000', b'\000') == b'\000'
    assert xf(b'\001', b'\000') == b'\001'
    assert xf(b'\001', b'\001') == b'\000'
    assert xf(b'\000\001', b'\000\001') == b'\000\000'
    assert xf(b'\100\101', b'\000\101') == b'\100\000'

class Testy(unittest.TestCase):
    def test_em(self):
        for xorfunc in (xor.py_xor, xor.py_xor_simple, xor.xor,):
            if callable(xorfunc):
                # print "testing xorfunc ", xorfunc
                _help_test(xorfunc)