From 595e75f1e0bbeab397992b53de6f920b6af2ba01 Mon Sep 17 00:00:00 2001 From: Aaron Weiss Date: Fri, 5 Jun 2015 22:25:49 -0400 Subject: [PATCH] Added unit tests for new username/hostname parsing. --- src/client/data/user.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/client/data/user.rs b/src/client/data/user.rs index 2b24e2e..b12c684 100644 --- a/src/client/data/user.rs +++ b/src/client/data/user.rs @@ -272,6 +272,22 @@ mod test { assert_eq!(user.get_nickname(), "owner"); } + #[test] + fn get_username() { + let user = User::new("user!username@hostname"); + assert_eq!(user.get_username(), Some("username")); + let user = User::new("user"); + assert_eq!(user.get_username(), None); + } + + #[test] + fn get_hostname() { + let user = User::new("user!username@hostname"); + assert_eq!(user.get_hostname(), Some("hostname")); + let user = User::new("user"); + assert_eq!(user.get_hostname(), None); + } + #[test] fn access_level() { let user = User::new("~owner");