pub fn main(world: World) -> Void raises { var reversed_buf: [6]u8 = [0_u8; 6] let reversed: Maybe> = std.str.reverse(reversed_buf, "drawer") let trimmed: Span = std.str.trimAscii(" zero text ") let left_trimmed: Span = std.str.trimStartAscii(" left") let right_trimmed: Span = std.str.trimEndAscii("right ") var small: [3]u8 = [0_u8; 3] let overflow: Maybe> = std.str.reverse(small, "drawer") var copy_buf: [4]u8 = [0_u8; 4] var concat_buf: [8]u8 = [0_u8; 8] var repeat_buf: [6]u8 = [0_u8; 6] var replace_buf: [16]u8 = [0_u8; 16] var replace_small: [4]u8 = [0_u8; 4] var lower_buf: [4]u8 = [0_u8; 4] var upper_buf: [4]u8 = [0_u8; 4] let copied: Maybe> = std.str.copy(copy_buf, "zero") let joined: Maybe> = std.str.concat(concat_buf, "zero", "lang") let repeated: Maybe> = std.str.repeat(repeat_buf, "ha", 3) let replaced: Maybe> = std.str.replace(replace_buf, "hello zero hello", "hello", "hi") let replace_overflow: Maybe> = std.str.replace(replace_small, "zero", "z", "zero") let replace_empty_old: Maybe> = std.str.replace(replace_buf, "zero", "", "x") let lowered: Maybe> = std.str.toLowerAscii(lower_buf, "ZERO") let uppered: Maybe> = std.str.toUpperAscii(upper_buf, "zero") let split0: Maybe> = std.str.split("alpha,beta,gamma", ",", 0) let split1: Maybe> = std.str.split("alpha,beta,gamma", ",", 1) let split2: Maybe> = std.str.split("alpha,beta,gamma", ",", 2) let split_missing: Maybe> = std.str.split("alpha,beta,gamma", ",", 3) let field1: Maybe> = std.str.fieldAscii(" zero\ttext\nsyntax ", 1) let field_missing: Maybe> = std.str.fieldAscii(" zero\ttext\nsyntax ", 3) let line0: Maybe> = std.str.line("one\r\ntwo\n", 0) let line1: Maybe> = std.str.line("one\r\ntwo\n", 1) let line_missing: Maybe> = std.str.line("one\r\ntwo\n", 2) var ok: Bool = true if !reversed.has { ok = false } if reversed.has { if !std.mem.eql(reversed.value, "reward") { ok = false } } if overflow.has { ok = false } if std.str.countByte("banana", 97_u8) != 3 { ok = false } if !std.str.startsWith("zero text syntax", "zero") { ok = false } if !std.str.endsWith("zero text syntax", "syntax") { ok = false } if !std.str.contains("zero text syntax", "text") { ok = false } if std.str.contains("zero text syntax", "column") { ok = false } if !std.str.contains("zero", "") { ok = false } if !std.mem.eql(trimmed, "zero text") { ok = false } if !std.mem.eql(left_trimmed, "left") || !std.mem.eql(right_trimmed, "right") { ok = false } if !copied.has || !joined.has || !repeated.has || !lowered.has || !uppered.has { ok = false } if copied.has && !std.mem.eql(copied.value, "zero") { ok = false } if joined.has && !std.mem.eql(joined.value, "zerolang") { ok = false } if repeated.has && !std.mem.eql(repeated.value, "hahaha") { ok = false } if !replaced.has || replace_overflow.has || replace_empty_old.has { ok = false } if replaced.has && !std.mem.eql(replaced.value, "hi zero hi") { ok = false } if lowered.has && !std.mem.eql(lowered.value, "zero") { ok = false } if uppered.has && !std.mem.eql(uppered.value, "ZERO") { ok = false } if std.str.count("aaaa", "aa") != 2 { ok = false } if std.str.indexOf("zero text syntax", "text") != 5 || std.str.lastIndexOf("one two one", "one") != 8 { ok = false } if !std.str.eqlIgnoreAsciiCase("Zero", "zero") { ok = false } if std.str.wordCountAscii("zero text syntax") != 3 { ok = false } if std.str.splitCount("alpha,beta,gamma", ",") != 3 || std.str.splitCount("alpha", "") != 0 { ok = false } if !split0.has || !split1.has || !split2.has || split_missing.has { ok = false } if split0.has && !std.mem.eql(split0.value, "alpha") { ok = false } if split1.has && !std.mem.eql(split1.value, "beta") { ok = false } if split2.has && !std.mem.eql(split2.value, "gamma") { ok = false } if std.str.fieldCountAscii(" zero\ttext\nsyntax ") != 3 || !field1.has || field_missing.has { ok = false } if field1.has && !std.mem.eql(field1.value, "text") { ok = false } if std.str.lineCount("one\r\ntwo\n") != 2 || !line0.has || !line1.has || line_missing.has { ok = false } if line0.has && !std.mem.eql(line0.value, "one") { ok = false } if line1.has && !std.mem.eql(line1.value, "two") { ok = false } if ok { check world.out.write("std str breadth ok\n") } }