| // Copyright 2026 The Fuchsia Authors. All rights reserved. | |
| // Use of this source code is governed by a BSD-style license that can be | |
| // found in the LICENSE file. | |
| use vx_runtime::{HandleInfo, HandleType, InvalidHandleType}; | |
| #[test] | |
| fn handle_type_and_handle_info_roundtrips() { | |
| assert!( | |
| HandleType::from_u8(HandleType::DirectoryRequest.as_u8()) | |
| == Some(HandleType::DirectoryRequest) | |
| ); | |
| assert!( | |
| HandleType::from_u8(HandleType::ComponentConfigVmo.as_u8()) | |
| == Some(HandleType::ComponentConfigVmo) | |
| ); | |
| assert!(HandleType::try_from(0xFFu8) == Err(InvalidHandleType)); | |
| let info = HandleInfo::ns_dir(3); | |
| assert!(info.handle_type() == Some(HandleType::NamespaceDirectory)); | |
| assert_eq!(info.arg(), 3); | |
| assert!(HandleInfo::from_raw(info.as_raw()) == info); | |
| assert!(HandleInfo::DIRECTORY_REQUEST.handle_type() == Some(HandleType::DirectoryRequest)); | |
| assert_eq!(HandleInfo::DIRECTORY_REQUEST.arg(), 0); | |
| assert!(HandleInfo::COMPONENT_CONFIG.handle_type() == Some(HandleType::ComponentConfigVmo)); | |
| } |