1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

strings: run v fmt (#7438)

This commit is contained in:
zakuro
2020-12-22 05:00:32 +09:00
committed by GitHub
parent fade162471
commit 6c341a77f5
8 changed files with 55 additions and 49 deletions

View File

@ -23,14 +23,13 @@ fn test_sb() {
y := MyInt(20)
sb.writeln('x = $x y = $y')
res := sb.str()
assert res[res.len-1] == `\n`
assert res[res.len - 1] == `\n`
println('"$res"')
assert res.trim_space() == 'x = 10 y = 20'
//
sb = strings.new_builder(10)
sb.write('x = $x y = $y')
assert sb.str() == 'x = 10 y = 20'
$if !windows {
// TODO msvc bug
sb = strings.new_builder(10)
@ -49,7 +48,7 @@ const (
fn test_big_sb() {
mut sb := strings.new_builder(100)
mut sb2 := strings.new_builder(10000)
for i in 0..maxn {
for i in 0 .. maxn {
sb.writeln(i.str())
sb2.write('+')
}
@ -62,12 +61,11 @@ fn test_big_sb() {
assert lines[98765] == '98765'
println(sb2.len)
assert sb2.len == maxn
}
fn test_byte_write() {
mut sb := strings.new_builder(100)
temp_str := "byte testing"
temp_str := 'byte testing'
mut count := 0
for word in temp_str {
sb.write_b(word)