Fix tests.
This commit is contained in:
parent
c905e705ff
commit
189dfb1755
@ -920,7 +920,7 @@ mod tests {
|
||||
},
|
||||
KVPair {
|
||||
key: "animal",
|
||||
value: RValue::RVString("cat".to_owned())
|
||||
value: RValue::RVLiteral(OwnedLiteral::LString("cat".to_owned()))
|
||||
}
|
||||
]
|
||||
})
|
||||
@ -943,7 +943,7 @@ mod tests {
|
||||
},
|
||||
KVPair {
|
||||
key: "animal",
|
||||
value: RValue::RVString("cat".to_owned())
|
||||
value: RValue::RVLiteral(OwnedLiteral::LString("cat".to_owned()))
|
||||
}
|
||||
]
|
||||
})
|
||||
@ -962,11 +962,11 @@ mod tests {
|
||||
params: vec![
|
||||
KVPair {
|
||||
key: "a",
|
||||
value: RValue::RVString("foo".to_owned())
|
||||
value: RValue::RVLiteral(OwnedLiteral::LString("foo".to_owned()))
|
||||
},
|
||||
KVPair {
|
||||
key: "b",
|
||||
value: RValue::RVPositiveInteger(179)
|
||||
value: RValue::RVLiteral(OwnedLiteral::LPositiveInteger(179))
|
||||
}
|
||||
]
|
||||
})
|
||||
@ -989,7 +989,7 @@ mod tests {
|
||||
},
|
||||
KVPair {
|
||||
key: "value",
|
||||
value: RValue::RVString("cat".to_owned())
|
||||
value: RValue::RVLiteral(OwnedLiteral::LString("cat".to_owned()))
|
||||
}
|
||||
],
|
||||
contents: Some(Body {
|
||||
@ -1025,7 +1025,7 @@ mod tests {
|
||||
},
|
||||
KVPair {
|
||||
key: "value",
|
||||
value: RValue::RVString("cat".to_owned())
|
||||
value: RValue::RVLiteral(OwnedLiteral::LString("cat".to_owned()))
|
||||
}
|
||||
],
|
||||
contents: None,
|
||||
@ -1131,23 +1131,33 @@ mod tests {
|
||||
params: vec![
|
||||
KVPair {
|
||||
key: "v1",
|
||||
value: RValue::RVString("b".to_owned())
|
||||
value: RValue::RVLiteral(OwnedLiteral::LString(
|
||||
"b".to_owned()
|
||||
))
|
||||
},
|
||||
KVPair {
|
||||
key: "v2",
|
||||
value: RValue::RVString("b".to_owned())
|
||||
value: RValue::RVLiteral(OwnedLiteral::LString(
|
||||
"b".to_owned()
|
||||
))
|
||||
},
|
||||
KVPair {
|
||||
key: "v3",
|
||||
value: RValue::RVString("b".to_owned())
|
||||
value: RValue::RVLiteral(OwnedLiteral::LString(
|
||||
"b".to_owned()
|
||||
))
|
||||
},
|
||||
KVPair {
|
||||
key: "v4",
|
||||
value: RValue::RVString("b".to_owned())
|
||||
value: RValue::RVLiteral(OwnedLiteral::LString(
|
||||
"b".to_owned()
|
||||
))
|
||||
},
|
||||
KVPair {
|
||||
key: "v5",
|
||||
value: RValue::RVString("b".to_owned())
|
||||
value: RValue::RVLiteral(OwnedLiteral::LString(
|
||||
"b".to_owned()
|
||||
))
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -493,6 +493,81 @@ mod tests {
|
||||
use crate::renderer::context_element::Walkable;
|
||||
use crate::renderer::CompareContextElement;
|
||||
|
||||
impl ContextElement for String {}
|
||||
|
||||
impl Renderable for String {
|
||||
fn render(&self, _filters: &Vec<Filter>) -> Result<String, RenderError> {
|
||||
Ok(self.clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl Loopable for String {
|
||||
fn get_loop_elements(&self) -> Vec<&dyn ContextElement> {
|
||||
if self.is_empty() {
|
||||
Vec::new()
|
||||
} else {
|
||||
vec![self]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Walkable for String {
|
||||
fn walk(&self, segment: &str) -> Result<&dyn ContextElement, WalkError> {
|
||||
Err(WalkError::CantWalk)
|
||||
}
|
||||
}
|
||||
|
||||
impl CompareContextElement for String {
|
||||
fn equals(&self, other: &dyn ContextElement) -> bool {
|
||||
match other.to_any().downcast_ref::<Self>() {
|
||||
None => false,
|
||||
Some(other_string) => self == other_string,
|
||||
}
|
||||
}
|
||||
|
||||
fn partial_compare(&self, other: &dyn ContextElement) -> Option<Ordering> {
|
||||
match other.to_any().downcast_ref::<Self>() {
|
||||
None => None,
|
||||
Some(other_string) => self.partial_cmp(other_string),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl ContextElement for u64 {}
|
||||
|
||||
impl Renderable for u64 {
|
||||
fn render(&self, _filters: &Vec<Filter>) -> Result<String, RenderError> {
|
||||
Ok(self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl Loopable for u64 {
|
||||
fn get_loop_elements(&self) -> Vec<&dyn ContextElement> {
|
||||
vec![self]
|
||||
}
|
||||
}
|
||||
|
||||
impl Walkable for u64 {
|
||||
fn walk(&self, segment: &str) -> Result<&dyn ContextElement, WalkError> {
|
||||
Err(WalkError::CantWalk)
|
||||
}
|
||||
}
|
||||
|
||||
impl CompareContextElement for u64 {
|
||||
fn equals(&self, other: &dyn ContextElement) -> bool {
|
||||
match other.to_any().downcast_ref::<Self>() {
|
||||
None => false,
|
||||
Some(other_num) => self == other_num,
|
||||
}
|
||||
}
|
||||
|
||||
fn partial_compare(&self, other: &dyn ContextElement) -> Option<Ordering> {
|
||||
match other.to_any().downcast_ref::<Self>() {
|
||||
None => None,
|
||||
Some(other_num) => self.partial_cmp(other_num),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<I: 'static + ContextElement + Clone> ContextElement for HashMap<String, I> {}
|
||||
|
||||
impl<I: ContextElement> Renderable for HashMap<String, I> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user