@@ -55,26 +55,49 @@ def test_word_list_to_long(self):
55
55
# if len of list is odd ignore last value
56
56
self .assertEqual (word_list_to_long ([0x1 , 0x2 , 0x3 ]), [0x10002 ])
57
57
# test convert with big and little endian
58
- dead_l = [0xdead , 0xbeef ]
58
+ l1 = [0xdead , 0xbeef ]
59
+ l2 = [0xfeed , 0xface , 0xcafe , 0xbeef ]
59
60
big = dict (big_endian = True )
60
61
nobig = dict (big_endian = False )
61
- self .assertEqual (words2longs (dead_l , ** big ), [0xdeadbeef ])
62
- self .assertEqual (words2longs (dead_l * 2 , ** big ), [0xdeadbeef ]* 2 )
63
- self .assertEqual (words2longs (dead_l , ** nobig ), [0xbeefdead ])
64
- self .assertEqual (words2longs (dead_l * 2 , ** nobig ), [0xbeefdead ]* 2 )
62
+ big64 = dict (big_endian = True , long_long = True )
63
+ nobig64 = dict (big_endian = False , long_long = True )
64
+ self .assertEqual (words2longs (l1 , ** big ), [0xdeadbeef ])
65
+ self .assertEqual (words2longs (l2 , ** big ), [0xfeedface , 0xcafebeef ])
66
+ self .assertEqual (words2longs (l1 , ** nobig ), [0xbeefdead ])
67
+ self .assertEqual (words2longs (l2 , ** nobig ), [0xfacefeed , 0xbeefcafe ])
68
+ self .assertEqual (words2longs (l1 * 2 , ** big64 ), [0xdeadbeefdeadbeef ])
69
+ self .assertEqual (words2longs (l2 * 2 , ** big64 ), [0xfeedfacecafebeef ]* 2 )
70
+ self .assertEqual (words2longs (l1 * 2 , ** nobig64 ), [0xbeefdeadbeefdead ])
71
+ self .assertEqual (words2longs (l2 * 2 , ** nobig64 ), [0xbeefcafefacefeed ]* 2 )
65
72
66
73
def test_long_list_to_word (self ):
67
74
# test long_list_to_word() and short alias longs2words()
68
75
# empty list, return empty list
69
76
self .assertEqual (long_list_to_word ([]), [])
70
77
# test convert with big and little endian
71
- dead_l = [0xdeadbeef ]
78
+ l1 = [0xdeadbeef ]
79
+ l1_big = [0xdead , 0xbeef ]
80
+ l1_nobig = [0xbeef , 0xdead ]
81
+ l1_big64 = [0x0000 , 0x0000 , 0xdead , 0xbeef ]
82
+ l1_nobig64 = [0xbeef , 0xdead , 0x0000 , 0x0000 ]
83
+ l2 = [0xfeedface , 0xcafebeef ]
84
+ l2_big = [0xfeed , 0xface , 0xcafe , 0xbeef ]
85
+ l2_nobig = [0xface , 0xfeed , 0xbeef , 0xcafe ]
86
+ l3 = [0xfeedfacecafebeef ]
87
+ l3_big64 = [0xfeed , 0xface , 0xcafe , 0xbeef ]
88
+ l3_nobig64 = [0xbeef , 0xcafe , 0xface , 0xfeed ]
72
89
big = dict (big_endian = True )
73
90
nobig = dict (big_endian = False )
74
- self .assertEqual (longs2words (dead_l , ** big ), [0xdead , 0xbeef ])
75
- self .assertEqual (longs2words (dead_l * 2 , ** big ), [0xdead , 0xbeef ]* 2 )
76
- self .assertEqual (longs2words (dead_l , ** nobig ), [0xbeef , 0xdead ])
77
- self .assertEqual (longs2words (dead_l * 2 , ** nobig ), [0xbeef , 0xdead ]* 2 )
91
+ big64 = dict (big_endian = True , long_long = True )
92
+ nobig64 = dict (big_endian = False , long_long = True )
93
+ self .assertEqual (longs2words (l1 , ** big ), l1_big )
94
+ self .assertEqual (longs2words (l2 , ** big ), l2_big )
95
+ self .assertEqual (longs2words (l1 , ** nobig ), l1_nobig )
96
+ self .assertEqual (longs2words (l2 , ** nobig ), l2_nobig )
97
+ self .assertEqual (longs2words (l1 * 2 , ** big64 ), l1_big64 * 2 )
98
+ self .assertEqual (longs2words (l3 * 2 , ** big64 ), l3_big64 * 2 )
99
+ self .assertEqual (longs2words (l1 * 4 , ** nobig64 ), l1_nobig64 * 4 )
100
+ self .assertEqual (longs2words (l3 * 4 , ** nobig64 ), l3_nobig64 * 4 )
78
101
79
102
def test_get_2comp (self ):
80
103
# test get_2comp() and short alias twos_c()
0 commit comments