0
|
1 |
#
|
|
2 |
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
#
|
|
16 |
|
|
17 |
import unittest
|
|
18 |
from testautomation import utils
|
|
19 |
|
|
20 |
class TestHexToBinData(unittest.TestCase):
|
|
21 |
def test_hex_to_bindata(self):
|
|
22 |
try: utils.hex_to_bindata('102')
|
|
23 |
except ValueError: pass
|
|
24 |
|
|
25 |
try: utils.hex_to_bindata('asdfgh')
|
|
26 |
except ValueError: pass
|
|
27 |
|
|
28 |
self.assertEquals(utils.hex_to_bindata(' 00 11 22 33 44 55 66 77 88 99 aA bB cC dD eE fF '),
|
|
29 |
'\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff')
|
|
30 |
|
|
31 |
DATA = """
|
|
32 |
00 11 22 33 44 55
|
|
33 |
66 77 88 99
|
|
34 |
aA bB cC dD eE fF
|
|
35 |
"""
|
|
36 |
self.assertEquals(utils.hex_to_bindata(DATA),
|
|
37 |
'\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff')
|