Skip to content

Commit c070df9

Browse files
author
luozijun
committed
Add test
1 parent 1477c9a commit c070df9

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

system-configuration/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//!
1717
//! [SystemConfiguration]: https://developer.apple.com/documentation/systemconfiguration?language=objc
1818
//! [`system-configuration-sys`]: https://crates.io/crates/system-configuration-sys
19-
19+
#![feature(test)]
2020
#![deny(missing_docs)]
2121

2222
#[macro_use]

system-configuration/src/network_configuration.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,3 +414,23 @@ impl fmt::Debug for SCNetworkInterface {
414414
)
415415
}
416416
}
417+
418+
419+
#[test]
420+
fn test_network_service() {
421+
use core_foundation::base::kCFAllocatorDefault;
422+
423+
let prefs = SCPreferences::new(unsafe { kCFAllocatorDefault }, "test_session", None);
424+
let list = SCNetworkService::list(&prefs);
425+
426+
for network_service in list.iter() {
427+
let network_service_id = network_service.id();
428+
let res = SCNetworkService::from_id(&prefs, &network_service_id);
429+
430+
assert!(res.is_some());
431+
let res = res.unwrap();
432+
433+
assert_eq!(res.id(), network_service.id());
434+
assert_eq!(res.name(), network_service.name());
435+
}
436+
}

0 commit comments

Comments
 (0)