@@ -68,8 +68,18 @@ func TestByteArrayGetItem(t *testing.T) {
68
68
69
69
func TestByteArrayInit (t * testing.T ) {
70
70
cases := []invokeTestCase {
71
+ {args : wrapArgs (), want : newTestByteArray ("" ).ToObject ()},
71
72
{args : wrapArgs (3 ), want : newTestByteArray ("\x00 \x00 \x00 " ).ToObject ()},
72
- {args : wrapArgs (newObject (ObjectType )), wantExc : mustCreateException (TypeErrorType , `'__init__' requires a 'int' object but received a "object"` )},
73
+ {args : wrapArgs ([]int {3 , 2 , 1 }), want : newTestByteArray ("\x03 \x02 \x01 " ).ToObject ()},
74
+ {args : wrapArgs ("abc" ), want : newTestByteArray ("abc" ).ToObject ()},
75
+ {args : wrapArgs ([]string {"a" , "b" , "c" }), want : newTestByteArray ("abc" ).ToObject ()},
76
+ {args : wrapArgs (newTestXRange (3 )), want : newTestByteArray ("\x00 \x01 \x02 " ).ToObject ()},
77
+ {args : wrapArgs (newTestRange (3 )), want : newTestByteArray ("\x00 \x01 \x02 " ).ToObject ()},
78
+ {args : wrapArgs (newObject (ObjectType )), wantExc : mustCreateException (TypeErrorType , `'object' object is not iterable` )},
79
+ {args : wrapArgs ([]int {- 1 }), wantExc : mustCreateException (ValueErrorType , `byte must be in range(0, 256)` )},
80
+ {args : wrapArgs ([]int {256 }), wantExc : mustCreateException (ValueErrorType , `byte must be in range(0, 256)` )},
81
+ {args : wrapArgs ([]string {"ab" }), wantExc : mustCreateException (ValueErrorType , `string must be of size 1` )},
82
+ {args : wrapArgs ([]interface {}{5 , []interface {}{}}), wantExc : mustCreateException (TypeErrorType , `an integer or string of size 1 is required` )},
73
83
}
74
84
for _ , cas := range cases {
75
85
if err := runInvokeTestCase (ByteArrayType .ToObject (), & cas ); err != "" {
0 commit comments