mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os: add test for os.open_append (#16846)
* os: add test for os.open_append * fix unclosed file in test_eof (it made os.open_append fail only on windows, since it got the previous file content, because the file was locked, and os.rm could not delete it)
This commit is contained in:
parent
d5b9f7d026
commit
3625a74ec5
@ -405,6 +405,7 @@ fn test_eof() {
|
|||||||
assert !f.eof()
|
assert !f.eof()
|
||||||
f.read_bytes(100)
|
f.read_bytes(100)
|
||||||
assert f.eof()
|
assert f.eof()
|
||||||
|
f.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_open_file_wb_ab() {
|
fn test_open_file_wb_ab() {
|
||||||
@ -419,3 +420,21 @@ fn test_open_file_wb_ab() {
|
|||||||
afile.close()
|
afile.close()
|
||||||
assert os.read_file('text.txt')? == 'hellohello'
|
assert os.read_file('text.txt')? == 'hellohello'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_open_append() {
|
||||||
|
os.rm(tfile) or {}
|
||||||
|
mut f1 := os.open_append(tfile)!
|
||||||
|
f1.write_string('abc\n')!
|
||||||
|
f1.close()
|
||||||
|
assert os.read_lines(tfile)! == ['abc']
|
||||||
|
//
|
||||||
|
mut f2 := os.open_append(tfile)!
|
||||||
|
f2.write_string('abc\n')!
|
||||||
|
f2.close()
|
||||||
|
assert os.read_lines(tfile)! == ['abc', 'abc']
|
||||||
|
//
|
||||||
|
mut f3 := os.open_append(tfile)!
|
||||||
|
f3.write_string('def\n')!
|
||||||
|
f3.close()
|
||||||
|
assert os.read_lines(tfile)! == ['abc', 'abc', 'def']
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user