Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::fs;
- fn open_file(file_path: &str) -> String {
- fs::read_to_string(file_path).expect("Failed to read file")
- }
- fn main() {
- let contents = open_file("test.txt");
- println!("{}", contents);
- }
- #[cfg(test)]
- mod tests {
- use super::*;
- #[test]
- fn test_open_file() {
- let content: String = open_file("test.txt");
- assert_eq!(content, "hello world\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement