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

Unified Diff: pkg/http/test/request_test.dart

Issue 23450003: Add encoding tests to pkg/http. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/http/test/multipart_test.dart ('k') | pkg/http/test/response_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/test/request_test.dart
diff --git a/pkg/http/test/request_test.dart b/pkg/http/test/request_test.dart
index 4761dc066b039a38f2eb395c075c6b054a5b745d..929cc636f0299d05e1720ce396447165da1951ae 100644
--- a/pkg/http/test/request_test.dart
+++ b/pkg/http/test/request_test.dart
@@ -136,8 +136,19 @@ void main() {
expect(request.body, equals("hello"));
});
- // TODO(nweiz): test that both the getter and the setter respect #encoding
- // when issue 6284 is fixed.
+ test('is encoded according to the given encoding', () {
+ var request = new http.Request('POST', dummyUrl);
+ request.encoding = LATIN1;
+ request.body = "föøbãr";
+ expect(request.bodyBytes, equals([102, 246, 248, 98, 227, 114]));
+ });
+
+ test('is decoded according to the given encoding', () {
+ var request = new http.Request('POST', dummyUrl);
+ request.encoding = LATIN1;
+ request.bodyBytes = [102, 246, 248, 98, 227, 114];
+ expect(request.body, equals("föøbãr"));
+ });
});
group('#bodyFields', () {
@@ -180,8 +191,23 @@ void main() {
equals({'key 1': 'value', 'key 2': 'other+value'}));
});
- // TODO(nweiz): test that both the getter and the setter respect #encoding
- // when issue 6284 is fixed.
+ test('is encoded according to the given encoding', () {
+ var request = new http.Request('POST', dummyUrl);
+ request.headers[HttpHeaders.CONTENT_TYPE] =
+ 'application/x-www-form-urlencoded';
+ request.encoding = LATIN1;
+ request.bodyFields = {"föø": "bãr"};
+ expect(request.body, equals('f%F6%F8=b%E3r'));
+ });
+
+ test('is decoded according to the given encoding', () {
+ var request = new http.Request('POST', dummyUrl);
+ request.headers[HttpHeaders.CONTENT_TYPE] =
+ 'application/x-www-form-urlencoded';
+ request.encoding = LATIN1;
+ request.body = 'f%F6%F8=b%E3r';
+ expect(request.bodyFields, equals({"föø": "bãr"}));
+ });
});
test('#followRedirects', () {
« no previous file with comments | « pkg/http/test/multipart_test.dart ('k') | pkg/http/test/response_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698