UNPKG

structured-field-values

Version:

Implementation of Structured Field Values from IETF httpbis RFC8941

164 lines (163 loc) 4.72 kB
[ { "name": "basic dictionary", "raw": ["en=\"Applepie\", da=:w4ZibGV0w6ZydGUK:"], "header_type": "dictionary", "expected": [["en", ["Applepie", []]], ["da", [ {"__type": "binary", "value": "YODGE3DFOTB2M4TUMUFA===="}, []] ]] }, { "name": "empty dictionary", "raw": [""], "header_type": "dictionary", "expected": [], "canonical": [] }, { "name": "single item dictionary", "raw": ["a=1"], "header_type": "dictionary", "expected": [["a", [1, []]]] }, { "name": "list item dictionary", "raw": ["a=(1 2)"], "header_type": "dictionary", "expected": [["a", [[[1, []], [2, []]], []]]] }, { "name": "single list item dictionary", "raw": ["a=(1)"], "header_type": "dictionary", "expected": [["a", [[[1, []]], []]]] }, { "name": "empty list item dictionary", "raw": ["a=()"], "header_type": "dictionary", "expected": [["a", [[], []]]] }, { "name": "no whitespace dictionary", "raw": ["a=1,b=2"], "header_type": "dictionary", "expected": [["a", [1, []]], ["b", [2, []]]], "canonical": ["a=1, b=2"] }, { "name": "extra whitespace dictionary", "raw": ["a=1 , b=2"], "header_type": "dictionary", "expected": [["a", [1, []]], ["b", [2, []]]], "canonical": ["a=1, b=2"] }, { "name": "tab separated dictionary", "raw": ["a=1\t,\tb=2"], "header_type": "dictionary", "expected": [["a", [1, []]], ["b", [2, []]]], "canonical": ["a=1, b=2"] }, { "name": "leading whitespace dictionary", "raw": [" a=1 , b=2"], "header_type": "dictionary", "expected": [["a", [1, []]], ["b", [2, []]]], "canonical": ["a=1, b=2"] }, { "name": "whitespace before = dictionary", "raw": ["a =1, b=2"], "header_type": "dictionary", "must_fail": true }, { "name": "whitespace after = dictionary", "raw": ["a=1, b= 2"], "header_type": "dictionary", "must_fail": true }, { "name": "two lines dictionary", "raw": ["a=1", "b=2"], "header_type": "dictionary", "expected": [["a", [1, []]], ["b", [2, []]]], "canonical": ["a=1, b=2"] }, { "name": "missing value dictionary", "raw": ["a=1, b, c=3"], "header_type": "dictionary", "expected": [["a", [1, []]], ["b", [true, []]], ["c", [3, []]]] }, { "name": "all missing value dictionary", "raw": ["a, b, c"], "header_type": "dictionary", "expected": [["a", [true, []]], ["b", [true, []]], ["c", [true, []]]] }, { "name": "start missing value dictionary", "raw": ["a, b=2"], "header_type": "dictionary", "expected": [["a", [true, []]], ["b", [2, []]]] }, { "name": "end missing value dictionary", "raw": ["a=1, b"], "header_type": "dictionary", "expected": [["a", [1, []]], ["b", [true, []]]] }, { "name": "missing value with params dictionary", "raw": ["a=1, b;foo=9, c=3"], "header_type": "dictionary", "expected": [["a", [1, []]], ["b", [true, [["foo", 9]]]], ["c", [3, []]]] }, { "name": "explicit true value with params dictionary", "raw": ["a=1, b=?1;foo=9, c=3"], "header_type": "dictionary", "expected": [["a", [1, []]], ["b", [true, [["foo", 9]]]], ["c", [3, []]]], "canonical": ["a=1, b;foo=9, c=3"] }, { "name": "trailing comma dictionary", "raw": ["a=1, b=2,"], "header_type": "dictionary", "must_fail": true }, { "name": "empty item dictionary", "raw": ["a=1,,b=2,"], "header_type": "dictionary", "must_fail": true }, { "name": "duplicate key dictionary", "raw": ["a=1,b=2,a=3"], "header_type": "dictionary", "expected": [["a", [3, []]], ["b", [2, []]]], "canonical": ["a=3, b=2"] }, { "name": "numeric key dictionary", "raw": ["a=1,1b=2,a=1"], "header_type": "dictionary", "must_fail": true }, { "name": "uppercase key dictionary", "raw": ["a=1,B=2,a=1"], "header_type": "dictionary", "must_fail": true }, { "name": "bad key dictionary", "raw": ["a=1,b!=2,a=1"], "header_type": "dictionary", "must_fail": true } ]