mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: replace []byte with []u8
This commit is contained in:
@ -10,7 +10,7 @@ fn imin(a int, b int) int {
|
||||
return if a < b { a } else { b }
|
||||
}
|
||||
|
||||
fn (mut s StringReader) read(mut buf []byte) ?int {
|
||||
fn (mut s StringReader) read(mut buf []u8) ?int {
|
||||
$if debug {
|
||||
eprintln('>>>> StringReader.read output buf.len: $buf.len')
|
||||
}
|
||||
@ -24,14 +24,14 @@ fn (mut s StringReader) read(mut buf []byte) ?int {
|
||||
return read
|
||||
}
|
||||
|
||||
fn read_from_string(text string, capacity int) []byte {
|
||||
fn read_from_string(text string, capacity int) []u8 {
|
||||
mut str := StringReader{
|
||||
text: text
|
||||
}
|
||||
mut stream := io.new_buffered_reader(reader: str, cap: capacity)
|
||||
//
|
||||
mut buf := []byte{len: 1}
|
||||
mut res := []byte{}
|
||||
mut buf := []u8{len: 1}
|
||||
mut res := []u8{}
|
||||
mut i := 0
|
||||
for {
|
||||
z := stream.read(mut buf) or { break }
|
||||
@ -50,7 +50,7 @@ pub fn test_reading_from_a_string() {
|
||||
assert read_from_string('ab', capacity) == [u8(`a`), `b`]
|
||||
assert read_from_string('abc', capacity) == [u8(`a`), `b`, `c`]
|
||||
assert read_from_string('abcde', capacity) == [u8(`a`), `b`, `c`, `d`, `e`]
|
||||
large_string_bytes := []byte{len: 1000, init: `x`}
|
||||
large_string_bytes := []u8{len: 1000, init: `x`}
|
||||
large_string := large_string_bytes.bytestr()
|
||||
assert read_from_string(large_string, capacity) == large_string_bytes
|
||||
}
|
||||
|
Reference in New Issue
Block a user