(t *testing.T)
| 100 | } |
| 101 | |
| 102 | func TestIfNotNilOrElse(t *testing.T) { |
| 103 | assert := internal.NewAssert(t, "TestIfNotNilOrElse") |
| 104 | |
| 105 | // Test when value is present |
| 106 | calledWithValue := false |
| 107 | valueAction := func(value int) { calledWithValue = true } |
| 108 | fallbackAction := func() { t.Errorf("Empty action should not be called when value is present") } |
| 109 | |
| 110 | optWithValue := Of(42) |
| 111 | optWithValue.IfNotNilOrElse(valueAction, fallbackAction) |
| 112 | |
| 113 | assert.ShouldBeTrue(calledWithValue) |
| 114 | |
| 115 | // Test when value is not present |
| 116 | calledWithEmpty := false |
| 117 | valueAction = func(value int) { t.Errorf("Value action should not be called when value is not present") } |
| 118 | fallbackAction = func() { calledWithEmpty = true } |
| 119 | |
| 120 | optDefault := Default[int]() |
| 121 | optDefault.IfNotNilOrElse(valueAction, fallbackAction) |
| 122 | |
| 123 | assert.ShouldBeTrue(calledWithEmpty) |
| 124 | } |
| 125 | |
| 126 | func TestGetWithPanicStandard(t *testing.T) { |
| 127 | assert := internal.NewAssert(t, "TestGetWithPanicStandard") |
nothing calls this directly
no test coverage detected
searching dependent graphs…