Test ReadTimeout option initialization, including special values -1 and 0. And also test behaviour of WriteTimeout option, when it is not explicitly set and use ReadTimeout value.
(t *testing.T)
| 229 | // And also test behaviour of WriteTimeout option, when it is not explicitly set and use |
| 230 | // ReadTimeout value. |
| 231 | func TestReadTimeoutOptions(t *testing.T) { |
| 232 | testDataInputOutputMap := map[time.Duration]time.Duration{ |
| 233 | -1: 0 * time.Second, |
| 234 | 0: 3 * time.Second, |
| 235 | 1: 1 * time.Nanosecond, |
| 236 | 3: 3 * time.Nanosecond, |
| 237 | } |
| 238 | |
| 239 | for in, out := range testDataInputOutputMap { |
| 240 | o := &Options{ReadTimeout: in} |
| 241 | o.init() |
| 242 | if o.ReadTimeout != out { |
| 243 | t.Errorf("got %d instead of %d as ReadTimeout option", o.ReadTimeout, out) |
| 244 | } |
| 245 | |
| 246 | if o.WriteTimeout != o.ReadTimeout { |
| 247 | t.Errorf("got %d instead of %d as WriteTimeout option", o.WriteTimeout, o.ReadTimeout) |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | func TestProtocolOptions(t *testing.T) { |
| 253 | testCasesMap := map[int]int{ |