Verifies: SYS-REQ-029 [boundary] MCDC SYS-REQ-029: addressed_array_is_well_formed=F, malformed_array_input_returns_error=T => TRUE
(t *testing.T)
| 1664 | // Verifies: SYS-REQ-029 [boundary] |
| 1665 | // MCDC SYS-REQ-029: addressed_array_is_well_formed=F, malformed_array_input_returns_error=T => TRUE |
| 1666 | func TestArrayEachWithWhiteSpace(t *testing.T) { |
| 1667 | // Issue #159 |
| 1668 | count := 0 |
| 1669 | funcError := func([]byte, ValueType, int, error) { t.Errorf("Run func not allow") } |
| 1670 | funcSuccess := func(value []byte, dataType ValueType, index int, err error) { |
| 1671 | count++ |
| 1672 | |
| 1673 | switch count { |
| 1674 | case 1: |
| 1675 | if string(value) != `AAA` { |
| 1676 | t.Errorf("Wrong first item: %s", string(value)) |
| 1677 | } |
| 1678 | case 2: |
| 1679 | if string(value) != `BBB` { |
| 1680 | t.Errorf("Wrong second item: %s", string(value)) |
| 1681 | } |
| 1682 | case 3: |
| 1683 | if string(value) != `CCC` { |
| 1684 | t.Errorf("Wrong third item: %s", string(value)) |
| 1685 | } |
| 1686 | default: |
| 1687 | t.Errorf("Should process only 3 items") |
| 1688 | } |
| 1689 | } |
| 1690 | |
| 1691 | type args struct { |
| 1692 | data []byte |
| 1693 | cb func(value []byte, dataType ValueType, offset int, err error) |
| 1694 | keys []string |
| 1695 | } |
| 1696 | tests := []struct { |
| 1697 | name string |
| 1698 | args args |
| 1699 | wantErr bool |
| 1700 | }{ |
| 1701 | {"Array with white space", args{[]byte(` ["AAA", "BBB", "CCC"]`), funcSuccess, []string{}}, false}, |
| 1702 | {"Array with only one character after white space", args{[]byte(` 1`), funcError, []string{}}, true}, |
| 1703 | {"Only white space", args{[]byte(` `), funcError, []string{}}, true}, |
| 1704 | } |
| 1705 | for _, tt := range tests { |
| 1706 | t.Run(tt.name, func(t *testing.T) { |
| 1707 | _, err := ArrayEach(tt.args.data, tt.args.cb, tt.args.keys...) |
| 1708 | if (err != nil) != tt.wantErr { |
| 1709 | t.Errorf("ArrayEach() error = %v, wantErr %v", err, tt.wantErr) |
| 1710 | return |
| 1711 | } |
| 1712 | }) |
| 1713 | } |
| 1714 | } |
| 1715 | |
| 1716 | // Verifies: SYS-REQ-028 [boundary] |
| 1717 | // MCDC SYS-REQ-028: addressed_array_is_empty=T, addressed_array_is_well_formed=T, empty_array_produces_no_callbacks=T => TRUE |
nothing calls this directly
no test coverage detected