Make tests OS independent

This commit is contained in:
altugbakan 2023-03-13 20:08:37 +03:00
parent 66f479e8bc
commit 6e52f55264
3 changed files with 3 additions and 17 deletions

View file

@ -108,20 +108,6 @@ mod tests {
assert_eq!(config.directory, PathBuf::from_str("/").unwrap()); assert_eq!(config.directory, PathBuf::from_str("/").unwrap());
} }
#[test]
fn parses_windows_config() {
let config = Config::new(
vec!["/", "-i", "127.0.0.1", "-d", r"C:\Users\", "-p", "1567"]
.iter()
.map(|s| s.to_string()),
)
.unwrap();
assert_eq!(config.ip_address, Ipv4Addr::new(127, 0, 0, 1));
assert_eq!(config.port, 1567);
assert_eq!(config.directory, PathBuf::from_str(r"C:\Users\").unwrap());
}
#[test] #[test]
fn parses_some_config() { fn parses_some_config() {
let config = Config::new( let config = Config::new(

View file

@ -16,7 +16,7 @@ use crate::{ErrorCode, Packet, TransferOption};
/// ///
/// // Send a FileNotFound error. /// // Send a FileNotFound error.
/// Message::send_error_to( /// Message::send_error_to(
/// &UdpSocket::bind(SocketAddr::from_str("127.0.0.1:69").unwrap()).unwrap(), /// &UdpSocket::bind(SocketAddr::from_str("127.0.0.1:6969").unwrap()).unwrap(),
/// &SocketAddr::from_str("127.0.0.1:1234").unwrap(), /// &SocketAddr::from_str("127.0.0.1:1234").unwrap(),
/// ErrorCode::FileNotFound, /// ErrorCode::FileNotFound,
/// "file does not exist".to_string(), /// "file does not exist".to_string(),

View file

@ -13,10 +13,10 @@ use std::path::PathBuf;
/// ///
/// ```rust /// ```rust
/// // Create the TFTP server. /// // Create the TFTP server.
/// use std::env;
/// use tftpd::{Config, Server}; /// use tftpd::{Config, Server};
/// ///
/// let config = Config::new(env::args()).unwrap(); /// let args = ["/", "-p", "1234"].iter().map(|s| s.to_string());
/// let config = Config::new(args).unwrap();
/// let server = Server::new(&config).unwrap(); /// let server = Server::new(&config).unwrap();
/// ``` /// ```
pub struct Server { pub struct Server {