fix method name, add missed test condition

This commit is contained in:
yggverse 2025-03-16 13:47:00 +02:00
parent 9696efa02d
commit 1b43f6aeaf

View file

@ -19,7 +19,7 @@ impl List {
// Converters // Converters
/// Convert `Self` to [Gemtext](https://geminiprotocol.net/docs/gemtext-specification.gmi) line /// Convert `Self` to [Gemtext](https://geminiprotocol.net/docs/gemtext-specification.gmi) line
pub fn as_source(&self) -> String { pub fn to_source(&self) -> String {
self.value.to_source() self.value.to_source()
} }
} }
@ -45,10 +45,12 @@ fn test() {
const SOURCE: &str = "* Item"; const SOURCE: &str = "* Item";
const VALUE: &str = "Item"; const VALUE: &str = "Item";
// test struct // test `List`
assert_eq!(List::parse(SOURCE).unwrap().value, VALUE); let list = List::parse(SOURCE).unwrap();
assert_eq!(list.value, VALUE);
assert_eq!(list.to_source(), SOURCE);
// test trait // test `Gemtext`
assert_eq!(SOURCE.as_value(), Some(VALUE)); assert_eq!(SOURCE.as_value(), Some(VALUE));
assert_eq!(VALUE.to_source(), SOURCE) assert_eq!(VALUE.to_source(), SOURCE)
} }