summaryrefslogtreecommitdiffstats
path: root/src/wrapping.rs
diff options
context:
space:
mode:
authorThomas Otto <th1000s@posteo.net>2022-01-04 23:19:08 +0100
committerDan Davison <dandavison7@gmail.com>2022-01-04 19:51:23 -0500
commit48fec2e6fdede01ed32f28c9083bdc42ef300615 (patch)
treeb857723ddf43f3f622712a6ba64f7ab0904e6c3f /src/wrapping.rs
parent1d6f18a6630825cefa4c6cd714e8103dd8a95cde (diff)
Make Config cloneable for DeltaTest, store as Cow<Config> there
Only cloneable when testing, the types git2::Config and git2::Repository in GitConfig contain C pointers and can't really be cloned.
Diffstat (limited to 'src/wrapping.rs')
-rw-r--r--src/wrapping.rs56
1 files changed, 25 insertions, 31 deletions
diff --git a/src/wrapping.rs b/src/wrapping.rs
index f1078de2..37f7a6fb 100644
--- a/src/wrapping.rs
+++ b/src/wrapping.rs
@@ -988,11 +988,11 @@ index 223ca50..e69de29 100644
#[test]
fn test_alignment_2_lines_vs_3_lines() {
- let config_1 =
- || make_config_from_args(&default_wrap_cfg_plus(&["--side-by-side", "--width", "55"]));
+ let config =
+ make_config_from_args(&default_wrap_cfg_plus(&["--side-by-side", "--width", "55"]));
{
- DeltaTest::with_config(config_1())
+ DeltaTest::with_config(&config)
.with_input(&format!(
"{}-{}+{}",
HUNK_ALIGN_DIFF_HEADER, HUNK_ALIGN_DIFF_SHORT, HUNK_ALIGN_DIFF_LONG
@@ -1007,7 +1007,7 @@ index 223ca50..e69de29 100644
}
{
- DeltaTest::with_config(config_1())
+ DeltaTest::with_config(&config)
.with_input(&format!(
"{}-{}+{}",
HUNK_ALIGN_DIFF_HEADER, HUNK_ALIGN_DIFF_LONG, HUNK_ALIGN_DIFF_SHORT
@@ -1023,18 +1023,16 @@ index 223ca50..e69de29 100644
#[test]
fn test_alignment_1_line_vs_3_lines() {
- let config_2 = || {
- make_config_from_args(&default_wrap_cfg_plus(&[
- "--side-by-side",
- "--width",
- "61",
- "--line-fill-method",
- "spaces",
- ]))
- };
+ let config = make_config_from_args(&default_wrap_cfg_plus(&[
+ "--side-by-side",
+ "--width",
+ "61",
+ "--line-fill-method",
+ "spaces",
+ ]));
{
- DeltaTest::with_config(config_2())
+ DeltaTest::with_config(&config)
.with_input(&format!(
"{}-{}+{}",
HUNK_ALIGN_DIFF_HEADER, HUNK_ALIGN_DIFF_SHORT, HUNK_ALIGN_DIFF_LONG
@@ -1048,7 +1046,7 @@ index 223ca50..e69de29 100644
}
{
- DeltaTest::with_config(config_2())
+ DeltaTest::with_config(&config)
.with_input(&format!(
"{}-{}+{}",
HUNK_ALIGN_DIFF_HEADER, HUNK_ALIGN_DIFF_LONG, HUNK_ALIGN_DIFF_SHORT
@@ -1065,22 +1063,19 @@ index 223ca50..e69de29 100644
#[test]
fn test_wrap_max_lines_2() {
// TODO overriding is not possible, need to change config directly
- let config_3 = || {
- let mut config = make_config_from_args(&default_wrap_cfg_plus(&[
- // "--wrap-max-lines",
- // "2",
- "--side-by-side",
- "--width",
- "72",
- "--line-fill-method",
- "spaces",
- ]));
- config.truncation_symbol = ">".into();
- config
- };
+ let mut config = make_config_from_args(&default_wrap_cfg_plus(&[
+ // "--wrap-max-lines",
+ // "2",
+ "--side-by-side",
+ "--width",
+ "72",
+ "--line-fill-method",
+ "spaces",
+ ]));
+ config.truncation_symbol = ">".into();
{
- DeltaTest::with_config(config_3())
+ DeltaTest::with_config(&config)
.with_input(&format!(
"{}-{}+{}",
HUNK_ALIGN_DIFF_HEADER, HUNK_ALIGN_DIFF_SHORT, HUNK_ALIGN_DIFF_LONG
@@ -1094,9 +1089,8 @@ index 223ca50..e69de29 100644
}
{
- let mut config = config_3();
config.wrap_config.max_lines = 2;
- DeltaTest::with_config(config)
+ DeltaTest::with_config(&config)
.with_input(&format!(
"{}-{}+{}",
HUNK_ALIGN_DIFF_HEADER, HUNK_ALIGN_DIFF_SHORT, HUNK_ALIGN_DIFF_LONG