(t *testing.T)
| 1520 | } |
| 1521 | |
| 1522 | func TestSetbit(t *testing.T) { |
| 1523 | server.Clear() |
| 1524 | c, err := proto.Dial(server.Addr()) |
| 1525 | ok(t, err) |
| 1526 | defer c.Close() |
| 1527 | s := server.Direct() |
| 1528 | |
| 1529 | { |
| 1530 | s.Set("findme", "\x08") |
| 1531 | must1(t, c, |
| 1532 | "SETBIT", "findme", "4", "0", |
| 1533 | ) |
| 1534 | s.CheckGet(t, "findme", "\x00") |
| 1535 | |
| 1536 | must0(t, c, |
| 1537 | "SETBIT", "findme", "4", "1", |
| 1538 | ) |
| 1539 | s.CheckGet(t, "findme", "\x08") |
| 1540 | } |
| 1541 | |
| 1542 | // Non-existing |
| 1543 | { |
| 1544 | must0(t, c, |
| 1545 | "SETBIT", "nosuch", "0", "1", |
| 1546 | ) |
| 1547 | s.CheckGet(t, "nosuch", "\x80") |
| 1548 | } |
| 1549 | |
| 1550 | // Too short |
| 1551 | { |
| 1552 | s.Set("short", "\x00\x00") |
| 1553 | must0(t, c, |
| 1554 | "SETBIT", "short", "24", "0", |
| 1555 | ) |
| 1556 | s.CheckGet(t, "short", "\x00\x00\x00\x00") |
| 1557 | must0(t, c, |
| 1558 | "SETBIT", "short", "32", "1", |
| 1559 | ) |
| 1560 | s.CheckGet(t, "short", "\x00\x00\x00\x00\x80") |
| 1561 | } |
| 1562 | |
| 1563 | // Wrong type of existing key |
| 1564 | { |
| 1565 | s.HSet("wrong", "aap", "noot") |
| 1566 | mustDo(t, c, |
| 1567 | "SETBIT", "wrong", "0", "1", |
| 1568 | proto.Error(msgWrongType), |
| 1569 | ) |
| 1570 | } |
| 1571 | |
| 1572 | // Wrong usage |
| 1573 | { |
| 1574 | mustDo(t, c, |
| 1575 | "SETBIT", "foo", |
| 1576 | proto.Error(errWrongNumber("setbit")), |
| 1577 | ) |
| 1578 | mustDo(t, c, |
| 1579 | "SETBIT", "spurious", "arguments", "!", |
nothing calls this directly
no test coverage detected