Files
aji/tests/conformance/source/std/fill_and_search.aji
T

29 lines
846 B
Rust

// expect: run
// result: 0
// phase: 6
// spec: docs/spec/16-standard-library.md; docs/spec/15-source-language.md §13
module test.standard
import std.bytes;
fn main() -> u8
effects []
{
var buf: [u8; 5] = zero;
std.bytes.fill(mut buf[1..4], 255);
assert(buf[0] == 0 and buf[4] == 0);
assert(buf[1] == 255 and buf[2] == 255 and buf[3] == 255);
std.bytes.fill(mut buf[2..2], 42);
assert(buf[2] == 255);
let index = std.bytes.find(ref buf, 255);
if index < buf.len { assert(buf[index] == 255); }
assert(index == 1usize);
for n in 0u16..256u16 {
let byte = n as% u8;
std.bytes.fill(mut buf, byte);
assert(std.bytes.compare(ref buf, ref buf) == 0);
assert(std.bytes.find(ref buf, byte) == 0usize);
for i in 0..buf.len { assert(buf[i] == byte); }
}
return 0;
}