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)
| 1639 | // Verifies: SYS-REQ-029 [boundary] |
| 1640 | // MCDC SYS-REQ-029: addressed_array_is_well_formed=F, malformed_array_input_returns_error=T => TRUE |
| 1641 | func TestArrayEachWithWhiteSpace(t *testing.T) { |
| 1642 | // Issue #159 |
| 1643 | count := 0 |
| 1644 | funcError := func([]byte, ValueType, int, error) { t.Errorf("Run func not allow") } |
| 1645 | funcSuccess := func(value []byte, dataType ValueType, index int, err error) { |
| 1646 | count++ |
| 1647 | |
| 1648 | switch count { |
| 1649 | case 1: |
| 1650 | if string(value) != `AAA` { |
| 1651 | t.Errorf("Wrong first item: %s", string(value)) |
| 1652 | } |
| 1653 | case 2: |
| 1654 | if string(value) != `BBB` { |
| 1655 | t.Errorf("Wrong second item: %s", string(value)) |
| 1656 | } |
| 1657 | case 3: |
| 1658 | if string(value) != `CCC` { |
| 1659 | t.Errorf("Wrong third item: %s", string(value)) |
| 1660 | } |
| 1661 | default: |
| 1662 | t.Errorf("Should process only 3 items") |
| 1663 | } |
| 1664 | } |
| 1665 | |
| 1666 | type args struct { |
| 1667 | data []byte |
| 1668 | cb func(value []byte, dataType ValueType, offset int, err error) |
| 1669 | keys []string |
| 1670 | } |
| 1671 | tests := []struct { |
| 1672 | name string |
| 1673 | args args |
| 1674 | wantErr bool |
| 1675 | }{ |
| 1676 | {"Array with white space", args{[]byte(` ["AAA", "BBB", "CCC"]`), funcSuccess, []string{}}, false}, |
| 1677 | {"Array with only one character after white space", args{[]byte(` 1`), funcError, []string{}}, true}, |
| 1678 | {"Only white space", args{[]byte(` `), funcError, []string{}}, true}, |
| 1679 | } |
| 1680 | for _, tt := range tests { |
| 1681 | t.Run(tt.name, func(t *testing.T) { |
| 1682 | _, err := ArrayEach(tt.args.data, tt.args.cb, tt.args.keys...) |
| 1683 | if (err != nil) != tt.wantErr { |
| 1684 | t.Errorf("ArrayEach() error = %v, wantErr %v", err, tt.wantErr) |
| 1685 | return |
| 1686 | } |
| 1687 | }) |
| 1688 | } |
| 1689 | } |
| 1690 | |
| 1691 | // Verifies: SYS-REQ-028 [boundary] |
| 1692 | // 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
searching dependent graphs…