| 551 | } |
| 552 | |
| 553 | func TestStringGetBit(t *testing.T) { |
| 554 | CallTest("setbit", "getbit", "5", "1") |
| 555 | tests := []struct { |
| 556 | name string |
| 557 | args []string |
| 558 | want string |
| 559 | }{ |
| 560 | { |
| 561 | name: "1", |
| 562 | args: []string{"getbit", "1", "0", "0"}, |
| 563 | want: "-ERR wrong number of arguments for 'getbit' command", |
| 564 | }, |
| 565 | { |
| 566 | name: "2", |
| 567 | args: []string{"getbit", "x"}, |
| 568 | want: ErrBitOffset.Error(), |
| 569 | }, |
| 570 | { |
| 571 | name: "3", |
| 572 | args: []string{"getbit", "1"}, |
| 573 | want: ":0", |
| 574 | }, |
| 575 | { |
| 576 | name: "5", |
| 577 | args: []string{"getbit", "5"}, |
| 578 | want: ":1", |
| 579 | }, |
| 580 | { |
| 581 | name: "6", |
| 582 | args: []string{"getbit", "10"}, |
| 583 | want: ":0", |
| 584 | }, |
| 585 | } |
| 586 | |
| 587 | for _, tt := range tests { |
| 588 | t.Run(tt.name, func(t *testing.T) { |
| 589 | out := CallTest("getbit", tt.args...) |
| 590 | assert.Contains(t, out.String(), tt.want) |
| 591 | }) |
| 592 | } |
| 593 | } |
| 594 | |
| 595 | func TestStringBitCount(t *testing.T) { |
| 596 | CallTest("setbit", "bit-count", "5", "1") |