quote/unquote functions

This commit is contained in:
Max Bradbury 2020-04-30 18:54:28 +01:00
parent e9f1a1afcf
commit 32a369118c
2 changed files with 15 additions and 2 deletions

View File

@ -62,7 +62,6 @@ some more practical uses would be things like:
* implement Result return types on ::from functions so we can handle errors * implement Result return types on ::from functions so we can handle errors
* handle old out-of-bounds editor errors (extra image pixels, exits/endings with position -1,-0 etc.) * handle old out-of-bounds editor errors (extra image pixels, exits/endings with position -1,-0 etc.)
* it's ok if the output of these does not match the input as we're fixing it * it's ok if the output of these does not match the input as we're fixing it
* "unquote" function for dialogues, game title, anything else that supports """
* add Bitsy HD and Bitsy 7.0 test data * add Bitsy HD and Bitsy 7.0 test data
* fix variables/endings becoming "DLG DLG"? * fix variables/endings becoming "DLG DLG"?
* replace Image with Vec<u8> or something. seems like a pointless abstraction * replace Image with Vec<u8> or something. seems like a pointless abstraction

View File

@ -176,7 +176,7 @@ impl Unquote for String {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use crate::{from_base36, ToBase36, optional_data_line, mock, segments_from_string}; use crate::{from_base36, ToBase36, optional_data_line, mock, segments_from_string, Quote, Unquote};
#[test] #[test]
fn test_from_base36() { fn test_from_base36() {
@ -211,4 +211,18 @@ mod test {
assert_eq!(output, expected); assert_eq!(output, expected);
} }
#[test]
fn test_quote() {
let output = "this is a string.\nIt has 2 lines".to_string().quote();
let expected = "\"\"\"\nthis is a string.\nIt has 2 lines\n\"\"\"".to_string();
assert_eq!(output, expected);
}
#[test]
fn test_unquote() {
let output = "\"\"\"\nwho the fuck is scraeming \"LOG OFF\" at my house.\nshow yourself, coward.\ni will never log off\n\"\"\"".to_string().unquote();
let expected = "who the fuck is scraeming \"LOG OFF\" at my house.\nshow yourself, coward.\ni will never log off".to_string();
assert_eq!(output, expected);
}
} }