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

Unified Diff: third_party/protobuf/js/binary/decoder_test.js

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years 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 | « third_party/protobuf/js/binary/decoder.js ('k') | third_party/protobuf/js/binary/encoder.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/protobuf/js/binary/decoder_test.js
diff --git a/third_party/protobuf/js/binary/decoder_test.js b/third_party/protobuf/js/binary/decoder_test.js
index d045e912cf044985c51e3db4339a34ec34d07483..9f947b99defd6ac6874dd5464f21a76a361bdf5a 100644
--- a/third_party/protobuf/js/binary/decoder_test.js
+++ b/third_party/protobuf/js/binary/decoder_test.js
@@ -147,9 +147,8 @@ function doTestSignedValue(readValue,
describe('binaryDecoderTest', function() {
/**
* Tests the decoder instance cache.
- * @suppress {visibility}
*/
- it('testInstanceCache', function() {
+ it('testInstanceCache', /** @suppress {visibility} */ function() {
// Empty the instance caches.
jspb.BinaryDecoder.instanceCache_ = [];
@@ -210,7 +209,30 @@ describe('binaryDecoderTest', function() {
assertEquals(hashC, decoder.readFixedHash64());
assertEquals(hashD, decoder.readFixedHash64());
});
+
+ /**
+ * Test encoding and decoding utf-8.
+ */
+ it('testUtf8', function() {
+ var encoder = new jspb.BinaryEncoder();
+ var ascii = "ASCII should work in 3, 2, 1..."
+ var utf8_two_bytes = "©";
+ var utf8_three_bytes = "❄";
+ var utf8_four_bytes = "😁";
+
+ encoder.writeString(ascii);
+ encoder.writeString(utf8_two_bytes);
+ encoder.writeString(utf8_three_bytes);
+ encoder.writeString(utf8_four_bytes);
+
+ var decoder = jspb.BinaryDecoder.alloc(encoder.end());
+
+ assertEquals(ascii, decoder.readString(ascii.length));
+ assertEquals(utf8_two_bytes, decoder.readString(utf8_two_bytes.length));
+ assertEquals(utf8_three_bytes, decoder.readString(utf8_three_bytes.length));
+ assertEquals(utf8_four_bytes, decoder.readString(utf8_four_bytes.length));
+ });
/**
* Verifies that misuse of the decoder class triggers assertions.
« no previous file with comments | « third_party/protobuf/js/binary/decoder.js ('k') | third_party/protobuf/js/binary/encoder.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698