Skip to content

Commit

Permalink
Fixed issues#769 : add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangHanDong committed Dec 29, 2023
1 parent 986364e commit 7fb4391
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/system/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,42 @@ mod test {

use super::*;

#[test]
fn test_user_id() {
let uid = UserId(1000);
assert_eq!(uid.id(), 1000);
let parsed_uid: UserId = "1000".parse().unwrap();
assert_eq!(parsed_uid, uid);
assert_eq!(format!("{}", uid), "1000");
}

#[test]
fn test_group_id() {
let gid = GroupId(1000);
assert_eq!(gid.id(), 1000);
let parsed_gid: GroupId = "1000".parse().unwrap();
assert_eq!(parsed_gid, gid);
assert_eq!(format!("{}", gid), "1000");
}

#[test]
fn test_process_id() {
let pid = ProcessId(1000);
assert_eq!(pid.id(), 1000);
let parsed_pid: ProcessId = "1000".parse().unwrap();
assert_eq!(parsed_pid, pid);
assert_eq!(format!("{}", pid), "1000");
}

#[test]
fn test_device_id() {
let did = DeviceId(1000);
assert_eq!(did.id(), 1000);
let parsed_did: DeviceId = "1000".parse().unwrap();
assert_eq!(parsed_did, did);
assert_eq!(format!("{}", did), "1000");
}

fn test_user(user: impl UnixUser, name_c: &CStr, uid: UserId) {
let name = name_c.to_str().unwrap();
assert!(user.has_name(name));
Expand Down

0 comments on commit 7fb4391

Please sign in to comment.