aboutsummaryrefslogtreecommitdiff
path: root/helix-term/tests
diff options
context:
space:
mode:
authorWilliam Etheredge2023-02-03 14:24:46 +0000
committerGitHub2023-02-03 14:24:46 +0000
commitf7bd7b5eafac9f016a470cc77c780922f83e690b (patch)
tree84e5cd9d28377c14b208bab68cc5487b1289d506 /helix-term/tests
parentd8f482e11e2dec544ede636464cf6a87e32bd1f7 (diff)
Add :character-info command (#4000)
Diffstat (limited to 'helix-term/tests')
-rw-r--r--helix-term/tests/test/commands.rs58
1 files changed, 58 insertions, 0 deletions
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("ih<esc>h:char<ret>"),
+ 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ë<esc>h:char<ret>"),
+ 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(":line<minus>ending crlf<ret>:char<ret>"),
+ 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 ascii<ret>ih<esc>h:char<ret>"),
+ Some(&|app| {
+ assert_eq!(r#""h" Dec 104 Hex 68"#, app.editor.get_status().unwrap().0);
+ }),
+ false,
+ )
+ .await?;
+
+ Ok(())
+}