Skip to content

Commit

Permalink
Add serialize str
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Sep 19, 2023
1 parent 6fc422a commit c41b63c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion crates/serde-firestore-value/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ mod tests {
}

fn serialize_str(self, v: &str) -> Result<Self::Ok, Self::Error> {
todo!()
// TODO: length check
self.output.value_type = Some(ValueType::StringValue(v.to_string()));
Ok(())
}

fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error> {
Expand Down Expand Up @@ -467,4 +469,16 @@ mod tests {
);
Ok(())
}

#[test]
fn test_str() -> anyhow::Result<()> {
// TODO: length check
assert_eq!(
to_value(&"abc")?,
Value {
value_type: Some(ValueType::StringValue("abc".to_string()))
}
);
Ok(())
}
}

0 comments on commit c41b63c

Please sign in to comment.