remove additional line from write_file
parent
dc8c84a2a8
commit
1cd95091f2
|
@ -470,7 +470,7 @@ pub fn home_dir() string {
|
||||||
// write_file writes text data to a file in `path`.
|
// write_file writes text data to a file in `path`.
|
||||||
pub fn write_file(path, text string) {
|
pub fn write_file(path, text string) {
|
||||||
f := os.create(path)
|
f := os.create(path)
|
||||||
f.writeln(text)
|
f.write(text)
|
||||||
f.close()
|
f.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,3 +19,15 @@ fn test_unsetenv() {
|
||||||
assert os.getenv('foo') == ''
|
assert os.getenv('foo') == ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_write_and_read_string_to_file() {
|
||||||
|
filename := './test1.txt'
|
||||||
|
hello := 'hello world!'
|
||||||
|
os.write_file(filename, hello)
|
||||||
|
assert hello.len == os.file_size(filename)
|
||||||
|
|
||||||
|
read_hello := os.read_file(filename) or {
|
||||||
|
panic('error reading file $filename')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
assert hello == read_hello
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue