aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2024-06-23 21:54:03 -0700
committeriximeow <me@iximeow.net>2024-06-23 21:54:03 -0700
commit01fe27a77a08c932b6457f1621796a57e6b866d7 (patch)
tree65df47e121eba5bd934ae1338c6f37e01787638a /tests
parentd0b9925bc1f75949f54d5290edfda4bf9ecd7bba (diff)
fix InstructionTextSink panicking in write_char
Diffstat (limited to 'tests')
-rw-r--r--tests/display.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/display.rs b/tests/display.rs
index a6d6eb1..8826303 100644
--- a/tests/display.rs
+++ b/tests/display.rs
@@ -19,6 +19,35 @@ fn formatters_are_not_feature_gated() {
#[cfg(feature="alloc")]
#[test]
+fn instruction_text_sink_write_char_requires_ascii() {
+ use core::fmt::Write;
+
+ let mut text = String::with_capacity(512);
+ let mut sink = unsafe {
+ yaxpeax_arch::display::InstructionTextSink::new(&mut text)
+ };
+ let expected = "`1234567890-=+_)(*&^%$#@!~\\][poiuytrewq |}{POIUYTREWQ';lkjhgfdsa\":LKJHGFDSA/.,mnbvcxz?><MNBVCXZ \r\n";
+ for c in expected.as_bytes().iter() {
+ sink.write_char(*c as char).expect("write works");
+ }
+ assert_eq!(text, expected);
+}
+
+#[cfg(feature="alloc")]
+#[test]
+#[should_panic]
+fn instruction_text_sink_write_char_rejects_not_ascii() {
+ use core::fmt::Write;
+
+ let mut text = String::with_capacity(512);
+ let mut sink = unsafe {
+ yaxpeax_arch::display::InstructionTextSink::new(&mut text)
+ };
+ sink.write_char('\u{80}').expect("write works");
+}
+
+#[cfg(feature="alloc")]
+#[test]
fn display_sink_write_hex_helpers() {
use yaxpeax_arch::display::{DisplaySink};