| 505 | } |
| 506 | |
| 507 | func TestStringSetBit(t *testing.T) { |
| 508 | tests := []struct { |
| 509 | name string |
| 510 | args []string |
| 511 | want string |
| 512 | }{ |
| 513 | { |
| 514 | name: "1", |
| 515 | args: []string{"setbit", "1", "0", "0"}, |
| 516 | want: "-ERR wrong number of arguments for 'setbit' command", |
| 517 | }, |
| 518 | { |
| 519 | name: "2", |
| 520 | args: []string{"setbit", "x", "0"}, |
| 521 | want: ErrBitOffset.Error(), |
| 522 | }, |
| 523 | { |
| 524 | name: "3", |
| 525 | args: []string{"setbit", "1", "x"}, |
| 526 | want: ErrBitInteger.Error(), |
| 527 | }, |
| 528 | { |
| 529 | name: "4", |
| 530 | args: []string{"setbit", "1", "2"}, |
| 531 | want: ErrBitInteger.Error(), |
| 532 | }, |
| 533 | { |
| 534 | name: "5", |
| 535 | args: []string{"setbit", "1", "1"}, |
| 536 | want: ":0", |
| 537 | }, |
| 538 | { |
| 539 | name: "6", |
| 540 | args: []string{"setbit", "1", "0"}, |
| 541 | want: ":1", |
| 542 | }, |
| 543 | } |
| 544 | |
| 545 | for _, tt := range tests { |
| 546 | t.Run(tt.name, func(t *testing.T) { |
| 547 | out := CallTest("setbit", tt.args...) |
| 548 | assert.Contains(t, out.String(), tt.want) |
| 549 | }) |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | func TestStringGetBit(t *testing.T) { |
| 554 | CallTest("setbit", "getbit", "5", "1") |