(t *testing.T)
| 568 | } |
| 569 | |
| 570 | func TestIncrbyfloat(t *testing.T) { |
| 571 | server.Clear() |
| 572 | c, err := proto.Dial(server.Addr()) |
| 573 | ok(t, err) |
| 574 | defer c.Close() |
| 575 | s := server.Direct() |
| 576 | |
| 577 | // Existing key |
| 578 | { |
| 579 | s.Set("foo", "12") |
| 580 | mustDo(t, c, |
| 581 | "INCRBYFLOAT", "foo", "400.12", |
| 582 | proto.String("412.12"), |
| 583 | ) |
| 584 | s.CheckGet(t, "foo", "412.12") |
| 585 | } |
| 586 | |
| 587 | // Existing key, not a number |
| 588 | { |
| 589 | s.Set("foo", "noint") |
| 590 | mustDo(t, c, |
| 591 | "INCRBYFLOAT", "foo", "400", |
| 592 | proto.Error(msgInvalidFloat), |
| 593 | ) |
| 594 | } |
| 595 | |
| 596 | // New key |
| 597 | { |
| 598 | mustDo(t, c, |
| 599 | "INCRBYFLOAT", "bar", "40.33", |
| 600 | proto.String("40.33"), |
| 601 | ) |
| 602 | s.CheckGet(t, "bar", "40.33") |
| 603 | } |
| 604 | |
| 605 | // Direct usage |
| 606 | { |
| 607 | s.Set("foo", "500.1") |
| 608 | f, err := s.Incrfloat("foo", 12) |
| 609 | ok(t, err) |
| 610 | equals(t, 512.1, f) |
| 611 | s.CheckGet(t, "foo", "512.1") |
| 612 | |
| 613 | s.HSet("wrong", "aap", "noot") |
| 614 | _, err = s.Incrfloat("wrong", 12) |
| 615 | assert(t, err != nil, "do s.Incrfloat() error") |
| 616 | } |
| 617 | |
| 618 | // Wrong type of existing key |
| 619 | { |
| 620 | s.HSet("wrong", "aap", "noot") |
| 621 | mustDo(t, c, |
| 622 | "INCRBYFLOAT", "wrong", "400", |
| 623 | proto.Error(msgWrongType), |
| 624 | ) |
| 625 | } |
| 626 | |
| 627 | // Amount not a number |
nothing calls this directly
no test coverage detected