summaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2020-08-28 20:05:59 +0000
committerOri Bernstein <ori@eigenstate.org>2020-08-28 20:05:59 +0000
commitf5a7e459867d990f4d9aa2d99706bd58676e5eca (patch)
treede022d0f05468f476550d67317fdcce06081be67 /lib/std
parent91e0b9594c2852d446d238a1678231be4d1c13b5 (diff)
downloadmc-f5a7e459867d990f4d9aa2d99706bd58676e5eca.tar.gz
copy bytes to a dest buffer.
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/test/ipparse.myr18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/std/test/ipparse.myr b/lib/std/test/ipparse.myr
index dfed4d6..acd8eca 100644
--- a/lib/std/test/ipparse.myr
+++ b/lib/std/test/ipparse.myr
@@ -60,12 +60,13 @@ const main = {
}
const eq = {ip, expected
+ var dst : byte[16]
var parsed
var p, e
parsed = std.ipparse(ip)
- p = ipbytes(parsed)
- e = ipbytes(expected)
+ p = ipbytes(dst[:], parsed)
+ e = ipbytes(dst[:], expected)
if !std.eq(p, e)
std.fput(1, "misparsed ip {}\n", ip)
std.put("parsed: ")
@@ -81,14 +82,19 @@ const eq = {ip, expected
;;
}
-const ipbytes = {ipopt
+const ipbytes = {dst, ipopt
match ipopt
+ | `std.None:
+ -> [][:]
| `std.Some ip:
match ip
- | `std.Ipv4 b: -> b[:]
- | `std.Ipv6 b: -> b[:]
+ | `std.Ipv4 b:
+ std.slcp(dst[:4], b[:])
+ -> dst[:4]
+ | `std.Ipv6 b:
+ std.slcp(dst[:16], b[:])
+ -> dst[:4]
;;
- | `std.None: -> [][:]
;;
-> [][:]
}