Skip to content

Commit e0873f8

Browse files
committed
tests: fix holes found by cargo-mutants
1 parent 07fe610 commit e0873f8

File tree

6 files changed

+26
-20
lines changed

6 files changed

+26
-20
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66

77
# Code coverage things
88
*.profraw
9+
mutants.out
10+
mutants.out*

src/builders/image.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl ImageBuilder {
5151

5252
impl Image {
5353
pub fn builder() -> ImageBuilder {
54-
ImageBuilder::new()
54+
Default::default()
5555
}
5656
}
5757

src/builders/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl LinkBuilder {
6363

6464
impl Link {
6565
pub fn builder() -> LinkBuilder {
66-
LinkBuilder::new()
66+
Default::default()
6767
}
6868
}
6969

src/builders/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl ListBuilder {
4949

5050
impl List {
5151
pub fn builder() -> ListBuilder {
52-
ListBuilder::new()
52+
Default::default()
5353
}
5454
}
5555

src/transforms.rs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ where
7777
}
7878

7979
fn to_code_block_with_language<S: AsRef<str>>(&self, language: S) -> String {
80-
format!("```{}\n{}\n```", language.as_ref(), self.as_ref())
80+
format!(
81+
"```{}\n{}\n```",
82+
language.as_ref().to_lowercase(),
83+
self.as_ref()
84+
)
8185
}
8286
}
8387

@@ -129,7 +133,7 @@ where
129133
#[cfg(test)]
130134
mod tests {
131135
use super::{BlockQuote, Bold, Inline, Italic};
132-
use crate::transforms::Strikethrough;
136+
use crate::{transforms::Strikethrough, CodeBlock};
133137

134138
#[test]
135139
fn test_block_quote_single_line() {
@@ -151,35 +155,38 @@ mod tests {
151155
fn test_bold() {
152156
let text = "text";
153157
assert_eq!("**text**", text.to_bold());
154-
155-
let text = String::from("text");
156-
assert_eq!(String::from("**text**"), text.to_bold());
157158
}
158159

159160
#[test]
160161
fn test_inline() {
161162
let text = "text";
162163
assert_eq!("`text`", text.to_inline());
163-
164-
let text = String::from("text");
165-
assert_eq!(String::from("`text`"), text.to_inline());
166164
}
167165

168166
#[test]
169167
fn test_italic() {
170168
let text = "text";
171169
assert_eq!("*text*", text.to_italic());
172-
173-
let text = String::from("text");
174-
assert_eq!(String::from("*text*"), text.to_italic());
175170
}
176171

177172
#[test]
178173
fn test_strikethrough() {
179174
let text = "text";
180175
assert_eq!("~~text~~", text.to_strikethrough());
176+
}
181177

182-
let text = String::from("text");
183-
assert_eq!(String::from("~~text~~"), text.to_strikethrough())
178+
#[test]
179+
fn test_code_block() {
180+
let text = "println!(\"Hello world\")";
181+
assert_eq!("```\nprintln!(\"Hello world\")\n```", text.to_code_block());
182+
}
183+
184+
#[test]
185+
fn test_code_block_with_language() {
186+
let text = "println!(\"Hello world\")";
187+
assert_eq!(
188+
"```rust\nprintln!(\"Hello world\")\n```",
189+
text.to_code_block_with_language("Rust")
190+
);
184191
}
185192
}

src/types/list.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ impl List {
4747

4848
/// Creates a new empty unordered `List`.
4949
pub fn unordered() -> Self {
50-
Self {
51-
variant: ListVariant::Unordered,
52-
..Default::default()
53-
}
50+
Default::default()
5451
}
5552

5653
/// Creates a new ordered `List` with the given items.

0 commit comments

Comments
 (0)