Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: test/media_type_test.dart

Issue 1419493002: Make MediaType case-insensitive, following the spec. (Closed) Base URL: git@github.com:dart-lang/http_parser@master
Patch Set: Add tests Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library http_parser.media_type_test; 5 library http_parser.media_type_test;
6 6
7 import 'package:http_parser/http_parser.dart'; 7 import 'package:http_parser/http_parser.dart';
8 import 'package:test/test.dart'; 8 import 'package:test/test.dart';
9 9
10 void main() { 10 void main() {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 throwsFormatException); 63 throwsFormatException);
64 }); 64 });
65 65
66 test("parses quoted parameters", () { 66 test("parses quoted parameters", () {
67 var type = new MediaType.parse( 67 var type = new MediaType.parse(
68 'text/plain; foo="bar space"; baz="bang\\\\escape"'); 68 'text/plain; foo="bar space"; baz="bang\\\\escape"');
69 expect(type.mimeType, equals("text/plain")); 69 expect(type.mimeType, equals("text/plain"));
70 expect( 70 expect(
71 type.parameters, equals({"foo": "bar space", "baz": "bang\\escape"})); 71 type.parameters, equals({"foo": "bar space", "baz": "bang\\escape"}));
72 }); 72 });
73
74 test("lower-cases type and subtype", () {
75 var type = new MediaType.parse('TeXt/pLaIn');
76 expect(type.type, equals("text"));
77 expect(type.subtype, equals("plain"));
78 expect(type.mimeType, equals("text/plain"));
79 });
80
81 test("records parameters as case-insensitive", () {
82 var type = new MediaType.parse('test/plain;FoO=bar;bAz=bang');
83 expect(type.parameters, equals({
84 "FoO": "bar",
85 "bAz": "bang"
86 }));
87 expect(type.parameters, containsPair("foo", "bar"));
88 expect(type.parameters, containsPair("baz", "bang"));
89 });
73 }); 90 });
74 91
75 group("change", () { 92 group("change", () {
76 var type; 93 var type;
77 setUp(() { 94 setUp(() {
78 type = new MediaType.parse("text/plain; foo=bar; baz=bang"); 95 type = new MediaType.parse("text/plain; foo=bar; baz=bang");
79 }); 96 });
80 97
81 test("uses the existing fields by default", () { 98 test("uses the existing fields by default", () {
82 var newType = type.change(); 99 var newType = type.change();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 expect(new MediaType("text", "plain", {"foo": 'bar"\x7Fbaz'}).toString(), 162 expect(new MediaType("text", "plain", {"foo": 'bar"\x7Fbaz'}).toString(),
146 equals('text/plain; foo="bar\\"\\\x7Fbaz"')); 163 equals('text/plain; foo="bar\\"\\\x7Fbaz"'));
147 }); 164 });
148 165
149 test("serializes multiple parameters", () { 166 test("serializes multiple parameters", () {
150 expect(new MediaType("text", "plain", {"foo": "bar", "baz": "bang"}) 167 expect(new MediaType("text", "plain", {"foo": "bar", "baz": "bang"})
151 .toString(), equals("text/plain; foo=bar; baz=bang")); 168 .toString(), equals("text/plain; foo=bar; baz=bang"));
152 }); 169 });
153 }); 170 });
154 } 171 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698