You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

29 lines
515 B

use panic::*;
use std::fs::{self, File};
fn main() {
let filename = "created.txt";
File::create(filename).unwrap();
let a = open_file(filename);
println!("{:?}", a);
fs::remove_file(filename).unwrap();
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
#[should_panic]
fn test_opening() {
open_file("file.txt");
}
#[test]
fn test_opening_existing() {
let filename = "created.txt";
File::create(filename).unwrap();
open_file(filename);
fs::remove_file(filename).unwrap();
}
}