Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
fe1d0a1f
Commit
fe1d0a1f
authored
Oct 02, 2016
by
Wojciech Mandrysz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JS: Added string encoding/decoding tests for UTF-8
parent
23f108d4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
decoder_test.js
js/binary/decoder_test.js
+23
-0
No files found.
js/binary/decoder_test.js
View file @
fe1d0a1f
...
...
@@ -209,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_tree_bytes
=
"❄"
;
var
utf8_four_bytes
=
"😁"
;
encoder
.
writeString
(
ascii
);
encoder
.
writeString
(
utf8_two_bytes
);
encoder
.
writeString
(
utf8_tree_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_tree_bytes
,
decoder
.
readString
(
utf8_tree_bytes
.
length
));
assertEquals
(
utf8_four_bytes
,
decoder
.
readString
(
utf8_four_bytes
.
length
));
});
/**
* Verifies that misuse of the decoder class triggers assertions.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment