MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / memcmp_detects_difference

Function memcmp_detects_difference

tests/integration/platform_stdlib.rs:356–385  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

354 src[0] = 72
355 src[1] = 105
356 src[2] = 33
357 dst: u8[3] = []
358 src_ptr: u8* = &src[0]
359 dst_ptr: u8* = &dst[0]
360 mem.copy(dst_ptr, src_ptr, 3)
361 console.putchar(dst_ptr[0] as i32)
362 console.putchar(dst_ptr[1] as i32)
363 console.putchar(dst_ptr[2] as i32)
364 return 0
365}
366"#,
367 );
368 assert_eq!(uart, "Hi!");
369 assert_eq!(exit, Some(0));
370}
371
372#[test]
373fn mem_move_dst_greater_than_src() {
374 // High-to-low copying keeps an overlapping destination above the source safe.
375 let (uart, exit) = run_hll(
376 r#"
377console := import("console")
378mem := import("mem")
379alloc := import("alloc")
380vec := import("vec")
381owned := import("owned_string")
382arena := import("arena")
383pool := import("pool")
384
385main: () -> i32 {
386 buf: u8* = alloc.malloc(5)
387 buf[0] = 65
388 buf[1] = 66

Callers

nothing calls this directly

Calls 1

run_hllFunction · 0.70

Tested by

no test coverage detected