[librsvg: 8/10] Added extra test cases.
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 8/10] Added extra test cases.
- Date: Thu, 14 Dec 2017 03:26:43 +0000 (UTC)
commit 6fc8583a4f96e6242daedb78650c7f13a760e885
Author: Jordan Petridis <jordanpetridis protonmail com>
Date: Sat Dec 9 10:46:51 2017 +0200
Added extra test cases.
rust/src/space.rs | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
---
diff --git a/rust/src/space.rs b/rust/src/space.rs
index ee4ae76..42b2f1f 100644
--- a/rust/src/space.rs
+++ b/rust/src/space.rs
@@ -35,18 +35,13 @@ fn normalize_default<'a, S: Into<Cow<'a, str>>>(s: S) -> String {
s.trim()
.chars()
.filter(|ch| *ch != '\n')
- .map(|ch| {
- match ch {
- '\t' => ' ',
- c => c
- }
+ .map(|ch| match ch {
+ '\t' => ' ',
+ c => c,
})
- .coalesce(|current, next| {
- if current == ' ' && next == ' ' {
- Ok(' ')
- } else {
- Err((current, next))
- }
+ .coalesce(|current, next| match (current, next) {
+ (' ', ' ') | (' ', '\t') => Ok(' '),
+ (_, _) => Err((current, next)),
})
.collect::<String>()
}
@@ -88,11 +83,14 @@ mod tests {
fn xml_space_default() {
assert_eq!(xml_space_normalize(XmlSpace::Default, "\n WS example\n indented lines\n "),
"WS example indented lines");
- assert_eq!(xml_space_normalize(XmlSpace::Default, "\n \t \tWS \t\t\texample\n \t indented
liines\t\t \n "),
- "WS example indented liines");
-
+ assert_eq!(xml_space_normalize(XmlSpace::Default, "\n \t \tWS \t\t\texample\n \t indented
lines\t\t \n "),
+ "WS example indented lines");
+ assert_eq!(xml_space_normalize(XmlSpace::Default, "\n \t \tWS \t\t\texample\n \t duplicate
letters\t\t \n "),
+ "WS example duplicate letters");
assert_eq!(xml_space_normalize(XmlSpace::Default, "\nWS example\nnon-indented lines\n "),
"WS examplenon-indented lines");
+ assert_eq!(xml_space_normalize(XmlSpace::Default, "\nWS example\tnon-indented lines\n "),
+ "WS example non-indented lines");
}
#[test]
@@ -101,6 +99,7 @@ mod tests {
" WS example indented lines ");
assert_eq!(xml_space_normalize(XmlSpace::Preserve, "\n \t \tWS \t\t\texample\n \t indented
lines\t\t \n "),
" WS example indented lines ");
-
+ assert_eq!(xml_space_normalize(XmlSpace::Preserve, "\n \t \tWS \t\t\texample\n \t duplicate
letters\t\t \n "),
+ " WS example duplicate letters ");
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]