From f7bd7b5eafac9f016a470cc77c780922f83e690b Mon Sep 17 00:00:00 2001 From: William Etheredge Date: Fri, 3 Feb 2023 08:24:46 -0600 Subject: Add :character-info command (#4000) --- helix-term/tests/test/commands.rs | 58 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'helix-term/tests') diff --git a/helix-term/tests/test/commands.rs b/helix-term/tests/test/commands.rs index 6e7275f5..da2e020e 100644 --- a/helix-term/tests/test/commands.rs +++ b/helix-term/tests/test/commands.rs @@ -354,3 +354,61 @@ async fn test_extend_line() -> anyhow::Result<()> { Ok(()) } + +#[tokio::test(flavor = "multi_thread")] +async fn test_character_info() -> anyhow::Result<()> { + // UTF-8, single byte + test_key_sequence( + &mut helpers::AppBuilder::new().build()?, + Some("ihh:char"), + Some(&|app| { + assert_eq!( + r#""h" (U+0068) Dec 104 Hex 68"#, + app.editor.get_status().unwrap().0 + ); + }), + false, + ) + .await?; + + // UTF-8, multi-byte + test_key_sequence( + &mut helpers::AppBuilder::new().build()?, + Some("iëh:char"), + Some(&|app| { + assert_eq!( + r#""ë" (U+0065 U+0308) Hex 65 + cc 88"#, + app.editor.get_status().unwrap().0 + ); + }), + false, + ) + .await?; + + // Multiple characters displayed as one, escaped characters + test_key_sequence( + &mut helpers::AppBuilder::new().build()?, + Some(":lineending crlf:char"), + Some(&|app| { + assert_eq!( + r#""\r\n" (U+000d U+000a) Hex 0d + 0a"#, + app.editor.get_status().unwrap().0 + ); + }), + false, + ) + .await?; + + // Non-UTF-8 + test_key_sequence( + &mut helpers::AppBuilder::new().build()?, + Some(":encoding asciiihh:char"), + Some(&|app| { + assert_eq!(r#""h" Dec 104 Hex 68"#, app.editor.get_status().unwrap().0); + }), + false, + ) + .await?; + + Ok(()) +} -- cgit v1.2.3-70-g09d2