# Path: axolotl/util/byteutil.py
# class ByteUtil:
#     @staticmethod
#     def combine(*args):
#         baos = bytearray()
#         for a in args:
#             if type(a) in (list, bytearray, str, bytes):
#                 baos.extend(a)
#             else:
#                 baos.append(a)
# 
#         return baos
# 
#     # @staticmethod
#     # def xsplit(inp, firstLength, secondLength, thirdLength = None):
#     #     parts = []
#     #     parts.append(inp[:firstLength])
#     #     parts.append(inp[len(parts[0]): secondLength + 1])
#     #     if thirdLength:
#     #         parts.append(inp[len(parts[1]): thirdLength + 1])
#     #     return parts
# 
#     @staticmethod
#     def split(inp, firstLength, secondLength, thirdLength=None):
#         parts = []
#         parts.append(inp[:firstLength])
#         parts.append(inp[firstLength:firstLength + secondLength])
#         if thirdLength is not None:
#             parts.append(inp[firstLength + secondLength: firstLength + secondLength + thirdLength])
# 
#         return parts
# 
#     @staticmethod
#     def trim(inp, length):
#         return inp[:length]
# 
#     @staticmethod
#     def intsToByteHighAndLow(highValue, lowValue):
#         highValue = ord(highValue) if type(highValue) is str else highValue
#         lowValue = ord(lowValue) if type(lowValue) is str else lowValue
#         return ((highValue << 4 | lowValue) & 0xFF) % 256
# 
#     @staticmethod
#     def highBitsToInt(value):
#         bit = ord(value) if type(value) is str else value
#         return (bit & 0xFF) >> 4
# 
#     @staticmethod
#     def lowBitsToInt(value):
#         return value & 0xF
# 
#     @staticmethod
#     def intToByteArray(_bytes, offset, value):
#         _bytes[offset + 3] = value % 256
#         _bytes[offset + 2] = (value >> 8) % 256
#         _bytes[offset + 1] = (value >> 16) % 256
#         _bytes[offset] = (value >> 24) % 256
# 
#         return 4


import unittest
from ...util.byteutil import ByteUtil
# -*- coding: utf-8 -*-


# from ...util.hexutil import HexUtil


class ByteUtilTest(unittest.TestCase):
    def test_split(self):
        # okm = HexUtil.decodeHex('02a9aa6c7dbd64f9d3aa92f92a277bf54609dadf0b00'
        #                         '828acfc61e3c724b84a7bfbe5efb603030526742e3ee'
        #                         '89c7024e884e440f1ff376bb2317b2d64deb7c8322f4'
        #                         'c5015d9d895849411ba1d793a827')

        data = [i for i in range(0, 80)]
        a_data = [i for i in range(0, 32)]
        b_data = [i for i in range(32, 64)]
        c_data = [i for i in range(64, 80)]

        a, b, c = ByteUtil.split(data, 32, 32, 16)

        self.assertEqual(a, a_data)
        self.assertEqual(b, b_data)

# Path: axolotl/util/byteutil.py
# class ByteUtil:
#     @staticmethod
#     def combine(*args):
#         baos = bytearray()
#         for a in args:
#             if type(a) in (list, bytearray, str, bytes):
#                 baos.extend(a)
#             else:
#                 baos.append(a)
# 
#         return baos
# 
#     # @staticmethod
#     # def xsplit(inp, firstLength, secondLength, thirdLength = None):
#     #     parts = []
#     #     parts.append(inp[:firstLength])
#     #     parts.append(inp[len(parts[0]): secondLength + 1])
#     #     if thirdLength:
#     #         parts.append(inp[len(parts[1]): thirdLength + 1])
#     #     return parts
# 
#     @staticmethod
#     def split(inp, firstLength, secondLength, thirdLength=None):
#         parts = []
#         parts.append(inp[:firstLength])
#         parts.append(inp[firstLength:firstLength + secondLength])
#         if thirdLength is not None:
#             parts.append(inp[firstLength + secondLength: firstLength + secondLength + thirdLength])
# 
#         return parts
# 
#     @staticmethod
#     def trim(inp, length):
#         return inp[:length]
# 
#     @staticmethod
#     def intsToByteHighAndLow(highValue, lowValue):
#         highValue = ord(highValue) if type(highValue) is str else highValue
#         lowValue = ord(lowValue) if type(lowValue) is str else lowValue
#         return ((highValue << 4 | lowValue) & 0xFF) % 256
# 
#     @staticmethod
#     def highBitsToInt(value):
#         bit = ord(value) if type(value) is str else value
#         return (bit & 0xFF) >> 4
# 
#     @staticmethod
#     def lowBitsToInt(value):
#         return value & 0xF
# 
#     @staticmethod
#     def intToByteArray(_bytes, offset, value):
#         _bytes[offset + 3] = value % 256
#         _bytes[offset + 2] = (value >> 8) % 256
#         _bytes[offset + 1] = (value >> 16) % 256
#         _bytes[offset] = (value >> 24) % 256
# 
#         return 4


# Path: axolotl/tests/util/test_byteutil.py
import unittest
from ...util.byteutil import ByteUtil

# -*- coding: utf-8 -*-


# from ...util.hexutil import HexUtil


class ByteUtilTest(unittest.TestCase):
    def test_split(self):
        # okm = HexUtil.decodeHex('02a9aa6c7dbd64f9d3aa92f92a277bf54609dadf0b00'
        #                         '828acfc61e3c724b84a7bfbe5efb603030526742e3ee'
        #                         '89c7024e884e440f1ff376bb2317b2d64deb7c8322f4'
        #                         'c5015d9d895849411ba1d793a827')

        data = [i for i in range(0, 80)]
        a_data = [i for i in range(0, 32)]
        b_data = [i for i in range(32, 64)]
        c_data = [i for i in range(64, 80)]

        a, b, c = ByteUtil.split(data, 32, 32, 16)

        self.assertEqual(a, a_data)
        self.assertEqual(b, b_data)

        self.assertEqual(c, c_data)