From 246063fb7cd21a83beae5934f95b2795fb85df51 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Fri, 14 Oct 2022 10:49:28 +0200 Subject: Refactor to use default trait in tests --- tests/gfm_strikethrough.rs | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) (limited to 'tests/gfm_strikethrough.rs') diff --git a/tests/gfm_strikethrough.rs b/tests/gfm_strikethrough.rs index 980f1e9..b8e30a6 100644 --- a/tests/gfm_strikethrough.rs +++ b/tests/gfm_strikethrough.rs @@ -3,20 +3,12 @@ use markdown::{ mdast::{Delete, Node, Paragraph, Root, Text}, to_html, to_html_with_options, to_mdast, unist::Position, - Constructs, Options, ParseOptions, + Options, ParseOptions, }; use pretty_assertions::assert_eq; #[test] fn gfm_strikethrough() -> Result<(), String> { - let gfm = Options { - parse: ParseOptions { - constructs: Constructs::gfm(), - ..ParseOptions::default() - }, - ..Options::default() - }; - assert_eq!( to_html("a ~b~ c"), "

a ~b~ c

", @@ -24,49 +16,49 @@ fn gfm_strikethrough() -> Result<(), String> { ); assert_eq!( - to_html_with_options("a ~b~", &gfm)?, + to_html_with_options("a ~b~", &Options::gfm())?, "

a b

", "should support strikethrough w/ one tilde" ); assert_eq!( - to_html_with_options("a ~~b~~", &gfm)?, + to_html_with_options("a ~~b~~", &Options::gfm())?, "

a b

", "should support strikethrough w/ two tildes" ); assert_eq!( - to_html_with_options("a ~~~b~~~", &gfm)?, + to_html_with_options("a ~~~b~~~", &Options::gfm())?, "

a ~~~b~~~

", "should not support strikethrough w/ three tildes" ); assert_eq!( - to_html_with_options("a \\~~~b~~ c", &gfm)?, + to_html_with_options("a \\~~~b~~ c", &Options::gfm())?, "

a ~b c

", "should support strikethrough after an escaped tilde" ); assert_eq!( - to_html_with_options("a ~~b ~~c~~ d~~ e", &gfm)?, + to_html_with_options("a ~~b ~~c~~ d~~ e", &Options::gfm())?, "

a b c d e

", "should support nested strikethrough" ); assert_eq!( - to_html_with_options("a ~-1~ b", &gfm)?, + to_html_with_options("a ~-1~ b", &Options::gfm())?, "

a -1 b

", "should open if preceded by whitespace and followed by punctuation" ); assert_eq!( - to_html_with_options("a ~b.~ c", &gfm)?, + to_html_with_options("a ~b.~ c", &Options::gfm())?, "

a b. c

", "should close if preceded by punctuation and followed by whitespace" ); assert_eq!( - to_html_with_options("~b.~.", &gfm)?, + to_html_with_options("~b.~.", &Options::gfm())?, "

b..

", "should close if preceded and followed by punctuation" ); @@ -130,7 +122,7 @@ a ~~two b one~ c two~~ d a ~~two b two~~ c one~ d "###, - &gfm + &Options::gfm() )?, r###"

Balanced

a one b

@@ -199,7 +191,7 @@ a ~~twoLeft b ~~twoLeft c twoRight~~ d a ~~twoLeft b ~~twoLeft c ~~twoLeft d "###, - &gfm + &Options::gfm() )?, r###"

Flank

a oneRight~ b oneRight~ c oneRight~ d

@@ -316,7 +308,7 @@ t ~~**xxx**~~ zzz u ~**xxx**~ zzz "###, - &gfm + &Options::gfm() )?, r###"

Interlpay

Interleave with attention

@@ -372,11 +364,10 @@ u ~**xxx**~ zzz "a ~b~ ~~c~~ d", &Options { parse: ParseOptions { - constructs: Constructs::gfm(), gfm_strikethrough_single_tilde: false, - ..ParseOptions::default() + ..ParseOptions::gfm() }, - ..Options::default() + ..Options::gfm() } )?, "

a ~b~ c d

", @@ -388,11 +379,10 @@ u ~**xxx**~ zzz "a ~b~ ~~c~~ d", &Options { parse: ParseOptions { - constructs: Constructs::gfm(), gfm_strikethrough_single_tilde: true, - ..ParseOptions::default() + ..ParseOptions::gfm() }, - ..Options::default() + ..Options::gfm() } )?, "

a b c d

", @@ -400,7 +390,7 @@ u ~**xxx**~ zzz ); assert_eq!( - to_mdast("a ~~alpha~~ b.", &gfm.parse)?, + to_mdast("a ~~alpha~~ b.", &ParseOptions::gfm())?, Node::Root(Root { children: vec![Node::Paragraph(Paragraph { children: vec![ -- cgit