(t *testing.T)
| 76 | } |
| 77 | |
| 78 | func TestFromChan(t *testing.T) { |
| 79 | t.Run("nil", func(t *testing.T) { |
| 80 | res := FromChan[int](nil, nil) |
| 81 | th.ExpectValue(t, res, nil) |
| 82 | }) |
| 83 | |
| 84 | t.Run("no error", func(t *testing.T) { |
| 85 | var inSlice []int |
| 86 | var expectedOutSlice []Try[int] |
| 87 | |
| 88 | for i := 0; i < 20000; i++ { |
| 89 | inSlice = append(inSlice, i) |
| 90 | expectedOutSlice = append(expectedOutSlice, Try[int]{Value: i}) |
| 91 | } |
| 92 | |
| 93 | wrapped := FromChan(th.FromSlice(inSlice), nil) |
| 94 | outSlice := th.ToSlice(wrapped) |
| 95 | |
| 96 | th.ExpectSlice(t, outSlice, expectedOutSlice) |
| 97 | }) |
| 98 | |
| 99 | t.Run("with error", func(t *testing.T) { |
| 100 | var inSlice []int |
| 101 | var expectedOutSlice []Try[int] |
| 102 | |
| 103 | err := fmt.Errorf("err") |
| 104 | expectedOutSlice = append(expectedOutSlice, Try[int]{Error: err}) |
| 105 | |
| 106 | for i := 0; i < 20000; i++ { |
| 107 | inSlice = append(inSlice, i) |
| 108 | expectedOutSlice = append(expectedOutSlice, Try[int]{Value: i}) |
| 109 | } |
| 110 | |
| 111 | wrapped := FromChan(th.FromSlice(inSlice), err) |
| 112 | outSlice := th.ToSlice(wrapped) |
| 113 | |
| 114 | th.ExpectSlice(t, outSlice, expectedOutSlice) |
| 115 | }) |
| 116 | } |
| 117 | |
| 118 | func TestFromChans(t *testing.T) { |
| 119 | // slices -> FromSlice -> FromChans -> ToChans -> ToSlice -> compare |
nothing calls this directly
no test coverage detected