Chromium Code Reviews| Index: tests/standalone/io/http_headers_test.dart |
| diff --git a/tests/standalone/io/http_headers_test.dart b/tests/standalone/io/http_headers_test.dart |
| index 6b4c1f15b61cbbb328c31b95be71df595c1c0d13..d54b767bc33ca60a3e4cb35d8b2c6276774b654c 100644 |
| --- a/tests/standalone/io/http_headers_test.dart |
| +++ b/tests/standalone/io/http_headers_test.dart |
| @@ -462,6 +462,43 @@ void testHeaderLists() { |
| HttpHeaders.REQUEST_HEADERS.forEach((x) => null); |
| } |
| +void testInvalidField() { |
|
Søren Gjesse
2014/07/04 09:24:54
testInvalidField -> testInvalidFieldName
Anders Johnsen
2014/07/04 11:03:50
Done.
|
| + void test(String field) { |
| + _HttpHeaders headers = new _HttpHeaders("1.1"); |
| + Expect.throws(() => headers.add(field, "value"), |
| + (e) => e is FormatException); |
| + Expect.throws(() => headers.set(field, "value"), |
| + (e) => e is FormatException); |
| + Expect.throws(() => headers.remove(field, "value"), |
| + (e) => e is FormatException); |
| + Expect.throws(() => headers.removeAll(field), |
| + (e) => e is FormatException); |
| + } |
| + test('\r'); |
| + test('\n'); |
| + test(','); |
| + test('test\x00'); |
| +} |
| + |
| +void testInvalidValue() { |
|
Søren Gjesse
2014/07/04 09:24:54
testInvalidValue -> testInvalidFieldValue
Anders Johnsen
2014/07/04 11:03:50
Done.
|
| + void test(value, {bool remove: true}) { |
| + _HttpHeaders headers = new _HttpHeaders("1.1"); |
| + Expect.throws(() => headers.add("field", value), |
| + (e) => e is FormatException); |
| + Expect.throws(() => headers.set("field", value), |
| + (e) => e is FormatException); |
| + if (remove) { |
| + Expect.throws(() => headers.remove("field", value), |
| + (e) => e is FormatException); |
| + } |
| + } |
| + test('\r'); |
| + test('\n'); |
| + test('test\x00'); |
| + // Test we handle other types correctly. |
| + test(new StringBuffer('\x00'), remove: false); |
| +} |
| + |
| main() { |
| testMultiValue(); |
| testDate(); |
| @@ -475,4 +512,6 @@ main() { |
| testCookie(); |
| testInvalidCookie(); |
| testHeaderLists(); |
| + testInvalidField(); |
| + testInvalidValue(); |
| } |