From c6ad1b581c2e691ce7e73ac6afeaaa3840c0aba8 Mon Sep 17 00:00:00 2001 From: Onur Cinar Date: Sat, 20 Jul 2024 12:47:22 -0700 Subject: [PATCH] Combining multiple append into a single call. --- strategy/and_strategy_test.go | 6 ++---- strategy/majority_strategy_test.go | 6 ++---- strategy/or_strategy_test.go | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/strategy/and_strategy_test.go b/strategy/and_strategy_test.go index 2022bb8..a18a46e 100644 --- a/strategy/and_strategy_test.go +++ b/strategy/and_strategy_test.go @@ -27,8 +27,7 @@ func TestAndStrategy(t *testing.T) { expected := helper.Map(results, func(r *strategy.Result) strategy.Action { return r.Action }) and := strategy.NewAndStrategy("And Strategy") - and.Strategies = append(and.Strategies, strategy.NewBuyAndHoldStrategy()) - and.Strategies = append(and.Strategies, strategy.NewBuyAndHoldStrategy()) + and.Strategies = append(and.Strategies, strategy.NewBuyAndHoldStrategy(), strategy.NewBuyAndHoldStrategy()) actual := and.Compute(snapshots) @@ -45,8 +44,7 @@ func TestAndStrategyReport(t *testing.T) { } and := strategy.NewAndStrategy("And Strategy") - and.Strategies = append(and.Strategies, strategy.NewBuyAndHoldStrategy()) - and.Strategies = append(and.Strategies, strategy.NewBuyAndHoldStrategy()) + and.Strategies = append(and.Strategies, strategy.NewBuyAndHoldStrategy(), strategy.NewBuyAndHoldStrategy()) report := and.Report(snapshots) diff --git a/strategy/majority_strategy_test.go b/strategy/majority_strategy_test.go index 3c65924..acf7488 100644 --- a/strategy/majority_strategy_test.go +++ b/strategy/majority_strategy_test.go @@ -28,8 +28,7 @@ func TestMajorityStrategy(t *testing.T) { expected := helper.Map(results, func(r *strategy.Result) strategy.Action { return r.Action }) majority := strategy.NewMajorityStrategy("Majority Strategy") - majority.Strategies = append(majority.Strategies, strategy.NewBuyAndHoldStrategy()) - majority.Strategies = append(majority.Strategies, trend.NewMacdStrategy()) + majority.Strategies = append(majority.Strategies, strategy.NewBuyAndHoldStrategy(), trend.NewMacdStrategy()) actual := majority.Compute(snapshots) @@ -46,8 +45,7 @@ func TestMajorityStrategyReport(t *testing.T) { } majority := strategy.NewMajorityStrategy("Majority Strategy") - majority.Strategies = append(majority.Strategies, strategy.NewBuyAndHoldStrategy()) - majority.Strategies = append(majority.Strategies, trend.NewMacdStrategy()) + majority.Strategies = append(majority.Strategies, strategy.NewBuyAndHoldStrategy(), trend.NewMacdStrategy()) report := majority.Report(snapshots) diff --git a/strategy/or_strategy_test.go b/strategy/or_strategy_test.go index d091f1f..aba8b6f 100644 --- a/strategy/or_strategy_test.go +++ b/strategy/or_strategy_test.go @@ -28,8 +28,7 @@ func TestOrStrategy(t *testing.T) { expected := helper.Map(results, func(r *strategy.Result) strategy.Action { return r.Action }) or := strategy.NewOrStrategy("Or Strategy") - or.Strategies = append(or.Strategies, strategy.NewBuyAndHoldStrategy()) - or.Strategies = append(or.Strategies, trend.NewMacdStrategy()) + or.Strategies = append(or.Strategies, strategy.NewBuyAndHoldStrategy(), trend.NewMacdStrategy()) actual := or.Compute(snapshots) @@ -46,8 +45,7 @@ func TestOrStrategyReport(t *testing.T) { } or := strategy.NewOrStrategy("Or Strategy") - or.Strategies = append(or.Strategies, strategy.NewBuyAndHoldStrategy()) - or.Strategies = append(or.Strategies, trend.NewMacdStrategy()) + or.Strategies = append(or.Strategies, strategy.NewBuyAndHoldStrategy(), trend.NewMacdStrategy()) report := or.Report(snapshots)