oct 0.29.2

Octonary transcodings.
Documentation
// Copyright 2024-2026 Gabriel Bjørnager Jensen.
//
// SPDX: MIT OR Apache-2.0

//! Tests for [`transmute`] and
//! [`transmute_unchecked`].
//!
//! [`transmute_unchecked`]: crate::transmute_unchecked

#![cfg(test)]

use oct::{
	FromOcts,
	Immutable,
	Init,
	transmute,
	Zeroable,
};

#[repr(C, align(4))]
#[derive(Debug, PartialEq)]
struct Foo(u8, u8, u8, u8);

unsafe impl FromOcts for Foo {}

unsafe impl Immutable for Foo {}

unsafe impl Init for Foo {}

unsafe impl Zeroable for Foo {}

#[test]
fn test_transmute() {
	assert_eq!(
		transmute::<u8, i8>(45),
		45u8.cast_signed(),
	);

	assert_eq!(
		transmute::<i32, Foo>(i32::from_be(0x7F_FF_00_7F)),
		Foo(0x7F, 0xFF, 0x00, 0x7F),
	);
}