Verifies: SYS-REQ-008 [example] MCDC SYS-REQ-008: eachkey_callback_receives_found_values=F, eachkey_completes_requested_scan=F, eachkey_malformed_input_returns_error=F, missing_multipath_request_does_not_emit_callback=F, multipath_requests_are_provided=T => FALSE MCDC SYS-REQ-008: eachkey_callback_r
(t *testing.T)
| 1968 | // MCDC SYS-REQ-008: eachkey_callback_receives_found_values=F, eachkey_completes_requested_scan=T, eachkey_malformed_input_returns_error=F, missing_multipath_request_does_not_emit_callback=F, multipath_requests_are_provided=T => TRUE |
| 1969 | // MCDC SYS-REQ-008: eachkey_callback_receives_found_values=T, eachkey_completes_requested_scan=F, eachkey_malformed_input_returns_error=F, missing_multipath_request_does_not_emit_callback=F, multipath_requests_are_provided=T => TRUE |
| 1970 | func TestEachKey(t *testing.T) { |
| 1971 | paths := [][]string{ |
| 1972 | {"name"}, |
| 1973 | {"order"}, |
| 1974 | {"nested", "a"}, |
| 1975 | {"nested", "b"}, |
| 1976 | {"nested2", "a"}, |
| 1977 | {"nested", "nested3", "b"}, |
| 1978 | {"arr", "[1]", "b"}, |
| 1979 | {"arrInt", "[3]"}, |
| 1980 | {"arrInt", "[5]"}, // Should not find last key |
| 1981 | {"nested"}, |
| 1982 | {"arr", "["}, // issue#177 Invalid arguments |
| 1983 | {"a\n", "b\n"}, // issue#165 |
| 1984 | {"nested", "b"}, // Should find repeated key |
| 1985 | } |
| 1986 | |
| 1987 | keysFound := 0 |
| 1988 | |
| 1989 | EachKey(testJson, func(idx int, value []byte, vt ValueType, err error) { |
| 1990 | keysFound++ |
| 1991 | |
| 1992 | switch idx { |
| 1993 | case 0: |
| 1994 | if string(value) != "Name" { |
| 1995 | t.Error("Should find 1 key", string(value)) |
| 1996 | } |
| 1997 | case 1: |
| 1998 | if string(value) != "Order" { |
| 1999 | t.Errorf("Should find 2 key") |
| 2000 | } |
| 2001 | case 2: |
| 2002 | if string(value) != "test" { |
| 2003 | t.Errorf("Should find 3 key") |
| 2004 | } |
| 2005 | case 3: |
| 2006 | if string(value) != "2" { |
| 2007 | t.Errorf("Should find 4 key") |
| 2008 | } |
| 2009 | case 4: |
| 2010 | if string(value) != "test2" { |
| 2011 | t.Error("Should find 5 key", string(value)) |
| 2012 | } |
| 2013 | case 5: |
| 2014 | if string(value) != "4" { |
| 2015 | t.Errorf("Should find 6 key") |
| 2016 | } |
| 2017 | case 6: |
| 2018 | if string(value) != "2" { |
| 2019 | t.Errorf("Should find 7 key") |
| 2020 | } |
| 2021 | case 7: |
| 2022 | if string(value) != "4" { |
| 2023 | t.Error("Should find 8 key", string(value)) |
| 2024 | } |
| 2025 | case 8: |
| 2026 | t.Errorf("Found key #8 that should not be found") |
| 2027 | case 9: |
nothing calls this directly
no test coverage detected
searching dependent graphs…