Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
yggverse committed Dec 7, 2024
1 parent 8c5e806 commit 9f7b85b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ match Link::from(
match link.timestamp {
Some(timestamp) => {
assert_eq!(timestamp.year(), 1965);
assert_eq!(timestamp.month(), 01);
assert_eq!(timestamp.month(), 1);
assert_eq!(timestamp.day_of_month(), 19);
}
None => assert!(false),
Expand Down
38 changes: 21 additions & 17 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,31 @@ fn gemtext() {

// Validate inline code
assert_eq!(code_inline.len(), 1);
assert_eq!(code_inline.get(0).unwrap().value, "inline code");
assert_eq!(code_inline.first().unwrap().value, "inline code");

// Validate multiline code
assert_eq!(code_multiline.len(), 2);

{
let item = code_multiline.get(0).unwrap();
let item = code_multiline.first().unwrap();
assert_eq!(item.alt.clone().unwrap(), "alt text");

assert_eq!(item.value.lines().count(), 2);
assert_eq!(item.value.lines().nth(0).unwrap(), "multi");
assert_eq!(item.value.lines().nth(1).unwrap(), " preformatted line");

let mut lines = item.value.lines();
assert_eq!(lines.next().unwrap(), "multi");
assert_eq!(lines.next().unwrap(), " preformatted line");
} // #1

{
let item = code_multiline.get(1).unwrap();
assert_eq!(item.alt.clone(), None);

assert_eq!(item.value.lines().count(), 2);
assert_eq!(item.value.lines().nth(0).unwrap(), "alt-less");
assert_eq!(item.value.lines().nth(1).unwrap(), " preformatted line");

let mut lines = item.value.lines();
assert_eq!(lines.next().unwrap(), "alt-less");
assert_eq!(lines.next().unwrap(), " preformatted line");
} // #2

// Validate headers
Expand All @@ -119,7 +125,7 @@ fn gemtext() {
} // comparison helper

{
let item = header.get(0).unwrap();
let item = header.first().unwrap();

assert_eq!(to_i8(&item.level), to_i8(&Level::H1));
assert_eq!(item.value, "H1");
Expand All @@ -143,7 +149,7 @@ fn gemtext() {
assert_eq!(link.len(), 6);

{
let item = link.get(0).unwrap();
let item = link.first().unwrap();

assert_eq!(item.alt, None);
assert_eq!(item.timestamp, None);
Expand All @@ -157,7 +163,7 @@ fn gemtext() {

let timestamp = item.timestamp.clone().unwrap();
assert_eq!(timestamp.year(), 1965);
assert_eq!(timestamp.month(), 01);
assert_eq!(timestamp.month(), 1);
assert_eq!(timestamp.day_of_month(), 19);

assert_eq!(item.uri.to_str(), "gemini://geminiprotocol.net");
Expand All @@ -178,7 +184,7 @@ fn gemtext() {

let timestamp = item.timestamp.clone().unwrap();
assert_eq!(timestamp.year(), 1965);
assert_eq!(timestamp.month(), 01);
assert_eq!(timestamp.month(), 1);
assert_eq!(timestamp.day_of_month(), 19);

assert_eq!(item.uri.to_str(), "gemini://geminiprotocol.net");
Expand All @@ -191,7 +197,7 @@ fn gemtext() {

let timestamp = item.timestamp.clone().unwrap();
assert_eq!(timestamp.year(), 1965);
assert_eq!(timestamp.month(), 01);
assert_eq!(timestamp.month(), 1);
assert_eq!(timestamp.day_of_month(), 19);

assert_eq!(
Expand All @@ -210,16 +216,14 @@ fn gemtext() {

// Validate lists
assert_eq!(list.len(), 2);
assert_eq!(list.get(0).unwrap().value, "Listing item 1");
assert_eq!(list.get(1).unwrap().value, "Listing item 2");
assert_eq!(list.first().unwrap().value, "Listing item 1");
assert_eq!(list.last().unwrap().value, "Listing item 2");

// Validate quotes
assert_eq!(quote.len(), 1);
assert_eq!(quote.get(0).unwrap().value, "quoted string");
assert_eq!(quote.first().unwrap().value, "quoted string");
}
// Could not load gemtext file
Err(_) => {
assert!(false);
}
Err(_) => panic!(),
}
}

0 comments on commit 9f7b85b

Please sign in to comment.