From e932c81378fa5dc28a2f01dca991c165758ad619 Mon Sep 17 00:00:00 2001 From: Hongbo Zhang Date: Thu, 17 Oct 2024 16:01:47 +0800 Subject: [PATCH] more tests for @bytes.of --- bytes/bytes_test.mbt | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/bytes/bytes_test.mbt b/bytes/bytes_test.mbt index 38b05bca9..abdd9726f 100644 --- a/bytes/bytes_test.mbt +++ b/bytes/bytes_test.mbt @@ -37,6 +37,29 @@ test "from_array" { ) } +test "from_array literal" { + let b = @bytes.of([65, 0, 66, 0, 67, 0]) + inspect!( + b, + content= + #|b"\x41\x00\x42\x00\x43\x00" + , + ) +} + +test "from array literal" { + let b1 = @bytes.of( + [ + b'\x41', b'\x00', b'\x42', b'\x00', b'\x43', b'\x00', b'\x44', b'\x00', b'\x45', + b'\x00', b'\x46', b'\x00', b'\x47', b'\x00', b'\x48', b'\x00', b'\x49', b'\x00', + ], + ) + let b2 = @bytes.of( + [65, 0, 66, 0, 67, 0, 68, 0, 69, 0, 70, 0, 71, 0, 72, 0, 73, 0], + ) + assert_eq!(b1, b2) +} + test "hash" { let b1 = @bytes.of( [