// Copyright (c) 2024 Jason Witty . // All rights reserved. // // Unit tests for event.rs module use bytes::Bytes; use webterm::event::{ChildDied, IO}; #[test] fn test_io_from_bytes() { let data = Bytes::from("test data"); let io = IO::from(data.clone()); assert_eq!(io.0, data); } #[test] fn test_io_from_string() { let data = String::from("test string"); let io = IO::from(data.clone()); assert_eq!(io.0, Bytes::from(data)); } #[test] fn test_io_from_str() { let data = "test str"; let io = IO::from(data); assert_eq!(io.0, Bytes::from(data)); } #[test] fn test_io_equality() { let io1 = IO::from("same data"); let io2 = IO::from("same data"); let io3 = IO::from("different data"); assert_eq!(io1, io2); assert_ne!(io1, io3); } #[test] fn test_io_clone() { let original = IO::from("original data"); let cloned = original.clone(); assert_eq!(original, cloned); assert_eq!(original.0, cloned.0); } #[test] fn test_io_empty() { let empty = IO::from(""); assert_eq!(empty.0.len(), 0); assert!(empty.0.is_empty()); } #[test] fn test_io_binary_data() { let binary_data = vec![0u8, 1, 2, 3, 255]; let bytes = Bytes::from(binary_data.clone()); let io = IO::from(bytes); assert_eq!(io.0.as_ref(), binary_data.as_slice()); } #[test] fn test_io_unicode() { let unicode = "Hello δΈ–η•Œ 🌍"; let io = IO::from(unicode); assert_eq!(io.0, Bytes::from(unicode)); } #[test] fn test_io_large_data() { let large_string = "a".repeat(10000); let io = IO::from(large_string.as_str()); assert_eq!(io.0.len(), 10000); } #[test] fn test_child_died_creation() { let event = ChildDied(); // ChildDied is a unit struct, just verify it can be created let _cloned = event.clone(); } #[test] fn test_child_died_clone() { let event1 = ChildDied(); let event2 = event1.clone(); // Both should exist without panicking // ChildDied is a zero-sized type, so dropping is a no-op let _ = event1; let _ = event2; }