Skip to content

Commit b6acad7

Browse files
committed
Update
1 parent 2ed3658 commit b6acad7

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# これは何?
2+
3+
```main()```自体をテストしたい場合に、標準出力を差し替えてテスト結果を確認するためのTipsです。

examples/singleapp/main_stdout_ospipe/main_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ func TestMainOutput(t *testing.T) {
3434
wg.Wait()
3535

3636
// 出力内容を確認
37+
// 出力量が分かっている場合は以下でも良いが
38+
// 不明な場合は [io.Reader.Read()] をちゃんとループ処理して
39+
// 読み込む処理にする必要がある。
3740
want := []byte("hello,world,へろー,ワールド\n")
3841
got, _ := io.ReadAll(r)
3942
if !bytes.Equal(want, got) {

0 commit comments

Comments
 (0)