From b352e435974fff45ef39cfa2fec5cf1d56fa842c Mon Sep 17 00:00:00 2001 From: krrrr38 Date: Wed, 23 Sep 2026 06:17:22 +0900 Subject: [PATCH] =?UTF-8?q?Go=20=E3=81=AE=E3=82=B7=E3=83=8A=E3=83=AA?= =?UTF-8?q?=E3=82=AA=E3=83=86=E3=82=B9=E3=83=88=E3=81=AE=E3=82=A2=E3=82=B5?= =?UTF-8?q?=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92=20t.Fatalf=20?= =?UTF-8?q?=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit t.Errorf は失敗を記録しても実行を継続するため、リバランスの配分が まるごとずれている場合に不一致が 3 件まとめて報告され、どこで最初に 壊れたのかが読み取りづらかった。assertDecimalEqual と order_scenario_test.go の合計額チェックを t.Fatalf にして、最初の不一致で止まるようにする。 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01SppdKxgYtCGigXC8dZyxob Signed-off-by: krrrr38 --- golang/test/optimal_portfolio_scenario_test.go | 2 +- patches/golang.patch | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/golang/test/optimal_portfolio_scenario_test.go b/golang/test/optimal_portfolio_scenario_test.go index 72da38a..cb4bf6f 100644 --- a/golang/test/optimal_portfolio_scenario_test.go +++ b/golang/test/optimal_portfolio_scenario_test.go @@ -73,6 +73,6 @@ func assertDecimalEqual(t *testing.T, label, got, want string) { t.Fatalf("%s: invalid want value %q: %v", label, want, err) } if !g.Equal(w) { - t.Errorf("%s: got %s, want %s", label, got, want) + t.Fatalf("%s: got %s, want %s", label, got, want) } } diff --git a/patches/golang.patch b/patches/golang.patch index 844a4a4..5f6d9ae 100644 --- a/patches/golang.patch +++ b/patches/golang.patch @@ -219,7 +219,7 @@ index 583d888..9d332e9 100644 +} diff --git a/test/order_scenario_test.go b/test/order_scenario_test.go new file mode 100644 -index 0000000..de74563 +index 0000000..2d461b0 --- /dev/null +++ b/test/order_scenario_test.go @@ -0,0 +1,168 @@ @@ -300,7 +300,7 @@ index 0000000..de74563 + } + diff1 := total1.Sub(decimal.NewFromInt(100000)).Abs() + if diff1.GreaterThan(decimal.NewFromInt(2)) { -+ t.Errorf("asset1 total should be ~100000, got %s", total1.String()) ++ t.Fatalf("asset1 total should be ~100000, got %s", total1.String()) + } + + asset1Toyopa := findStock(asset1.Stocks, "Toyopa") @@ -326,7 +326,7 @@ index 0000000..de74563 + } + diff2 := total2.Sub(decimal.NewFromInt(200000)).Abs() + if diff2.GreaterThan(decimal.NewFromInt(4)) { -+ t.Errorf("asset2 total should be ~200000, got %s", total2.String()) ++ t.Fatalf("asset2 total should be ~200000, got %s", total2.String()) + } + + t.Log("現金比率5%に対して現金が 10,000円、最適ポートフォリオに基づき Toyopa の保有額が 76,000 円(40%)、Somy の保有額が 114,000 円(60%) となる") @@ -363,7 +363,7 @@ index 0000000..de74563 + } + diff3 := total3.Sub(total2).Abs() + if diff3.GreaterThan(decimal.NewFromInt(4)) { -+ t.Errorf("asset3 total should be ~%s (total2), got %s", total2.String(), total3.String()) ++ t.Fatalf("asset3 total should be ~%s (total2), got %s", total2.String(), total3.String()) + } + + t.Log("現金比率5%に対して現金が 10,000円、最適ポートフォリオに基づき Toyopa の保有額が 19,000 円(10%)、Somy の保有額が 171,000 円(90%) となる")