| 593 | } |
| 594 | |
| 595 | func TestStringBitCount(t *testing.T) { |
| 596 | CallTest("setbit", "bit-count", "5", "1") |
| 597 | CallTest("setbit", "bit-count", "9", "1") |
| 598 | tests := []struct { |
| 599 | name string |
| 600 | args []string |
| 601 | want string |
| 602 | }{ |
| 603 | { |
| 604 | name: "1", |
| 605 | args: []string{"bit-count", "1"}, |
| 606 | want: ErrSyntax.Error(), |
| 607 | }, |
| 608 | { |
| 609 | name: "2", |
| 610 | args: []string{"bit-count", "x", "1"}, |
| 611 | want: ErrInteger.Error(), |
| 612 | }, |
| 613 | { |
| 614 | name: "3", |
| 615 | args: []string{"bit-count", "1", "x"}, |
| 616 | want: ErrInteger.Error(), |
| 617 | }, |
| 618 | { |
| 619 | name: "4", |
| 620 | args: []string{"bit-count"}, |
| 621 | want: ":2", |
| 622 | }, |
| 623 | { |
| 624 | name: "5", |
| 625 | args: []string{"bit-count", "1", "1"}, |
| 626 | want: ":1", |
| 627 | }, |
| 628 | } |
| 629 | |
| 630 | for _, tt := range tests { |
| 631 | t.Run(tt.name, func(t *testing.T) { |
| 632 | out := CallTest("bitcount", tt.args...) |
| 633 | assert.Contains(t, out.String(), tt.want) |
| 634 | }) |
| 635 | } |
| 636 | } |
| 637 | |
| 638 | func TestStringBitPos(t *testing.T) { |
| 639 | CallTest("set", "bit-pos", "5") |