From 0588de82e088f320471f10e0b7af8c3d2e33b1d4 Mon Sep 17 00:00:00 2001 From: Aaron Weiss Date: Mon, 1 Dec 2014 18:20:29 -0500 Subject: [PATCH] Fixed encode tests. --- src/conn.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/conn.rs b/src/conn.rs index afcab60..04f5ecb 100644 --- a/src/conn.rs +++ b/src/conn.rs @@ -225,7 +225,7 @@ mod test { use std::io::util::{NullReader, NullWriter}; use data::message::Message; #[cfg(feature = "encode")] use encoding::{DecoderTrap, Encoding}; - #[cfg(feature = "encode")] use encoding::all::ISO_8859_15; + #[cfg(feature = "encode")] use encoding::all::{ISO_8859_15, UTF_8}; #[test] #[cfg(not(feature = "encode"))] @@ -243,16 +243,21 @@ mod test { fn send_utf8() { let conn = Connection::new(NullReader, MemWriter::new()); assert!(conn.send( - Message::new(None, "PRIVMSG", Some(vec!["test"]), Some("€ŠšŽžŒœŸ")), "l9" + Message::new(None, "PRIVMSG", Some(vec!["test"]), Some("€ŠšŽžŒœŸ")), "UTF-8" ).is_ok()); - let data = ISO_8859_15.decode(conn.stream().value()[], DecoderTrap::Strict).unwrap(); - assert_eq!(data[], "PRIVMSG test :€ŠšŽžŒœŸ\r\n"); + let data = UTF_8.decode(conn.writer().get_ref(), DecoderTrap::Strict).unwrap(); + assert_eq!(data[], "PRIVMSG test :€ŠšŽžŒœŸ\r\n"); } #[test] #[cfg(feature = "encode")] fn send_iso885915() { - + let conn = Connection::new(NullReader, MemWriter::new()); + assert!(conn.send( + Message::new(None, "PRIVMSG", Some(vec!["test"]), Some("€ŠšŽžŒœŸ")), "l9" + ).is_ok()); + let data = ISO_8859_15.decode(conn.writer().get_ref(), DecoderTrap::Strict).unwrap(); + assert_eq!(data[], "PRIVMSG test :€ŠšŽžŒœŸ\r\n"); } #[test]