| 13 | } |
| 14 | |
| 15 | func (s *OptionsTestSuite) TestGet() { |
| 16 | o := options.New() |
| 17 | o.Set("string_key", "string_value") |
| 18 | o.Set("bool_key", true) |
| 19 | |
| 20 | // Existing keys |
| 21 | s.Require().Equal("string_value", options.Get(o, "string_key", "default_value")) |
| 22 | s.Require().True(options.Get(o, "bool_key", false)) |
| 23 | |
| 24 | // Non-existing keys |
| 25 | s.Require().Equal("default_value", options.Get(o, "non_existing_key", "default_value")) |
| 26 | s.Require().False(options.Get(o, "another_non_existing_key", false)) |
| 27 | |
| 28 | // Type mismatch |
| 29 | s.Require().Panics(func() { |
| 30 | _ = options.Get(o, "string_key", 42) |
| 31 | }) |
| 32 | s.Require().Panics(func() { |
| 33 | _ = options.Get(o, "bool_key", "not_a_bool") |
| 34 | }) |
| 35 | } |
| 36 | |
| 37 | func (s *OptionsTestSuite) TestAppendToSlice() { |
| 38 | o := options.New() |