Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hammer
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vyrus
hammer
Commits
8c653b51
Commit
8c653b51
authored
11 years ago
by
Jakob Rath
Committed by
Dan Hirsch
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add tests about token encoding (failing for now).
parent
b16eab8f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/bindings/ruby/lib/hammer/internal.rb
+5
-2
5 additions, 2 deletions
src/bindings/ruby/lib/hammer/internal.rb
src/bindings/ruby/test/parser_test.rb
+10
-0
10 additions, 0 deletions
src/bindings/ruby/test/parser_test.rb
with
15 additions
and
2 deletions
src/bindings/ruby/lib/hammer/internal.rb
+
5
−
2
View file @
8c653b51
...
...
@@ -39,8 +39,11 @@ module Hammer
:len
,
:size_t
def
token
# TODO: Encoding? Should probably be the same encoding as the string the token was created with.
return
self
[
:token
].
read_string
(
self
[
:len
])
#.force_encoding('UTF-8')
# TODO: Encoding?
# Should be the same encoding as the string the token was created with.
# But how do we get to this knowledge at this point?
# Cheap solution: Just ask the user (additional parameter with default value of UTF-8).
return
self
[
:token
].
read_string
(
self
[
:len
]).
force_encoding
(
'UTF-8'
)
end
end
...
...
This diff is collapsed.
Click to expand it.
src/bindings/ruby/test/parser_test.rb
+
10
−
0
View file @
8c653b51
...
...
@@ -80,4 +80,14 @@ class ParserTest < Minitest::Test
refute_nil
parser
.
parse
(
'今日a'
)
end
def
test_token_encoding
(
encoding
=
'UTF-8'
)
string
=
'今日'
.
encode
(
encoding
)
parser
=
Hammer
::
Parser
.
token
(
string
)
assert_equal
string
,
parser
.
parse
(
string
)[
:ast
][
:data
][
:bytes
].
token
end
def
test_token_encoding_2
test_token_encoding
(
'EUC-JP'
)
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment