mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add a test for r35863.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
866761d2e8
commit
d054eb9631
3 changed files with 58 additions and 0 deletions
29
ext/-test-/string/coderange.c
Normal file
29
ext/-test-/string/coderange.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include "ruby/ruby.h"
|
||||
#include "ruby/encoding.h"
|
||||
|
||||
static VALUE sym_7bit, sym_valid, sym_unknown, sym_broken;
|
||||
static VALUE
|
||||
str_coderange(VALUE str)
|
||||
{
|
||||
switch (ENC_CODERANGE(str)) {
|
||||
case ENC_CODERANGE_7BIT:
|
||||
return sym_7bit;
|
||||
case ENC_CODERANGE_VALID:
|
||||
return sym_valid;
|
||||
case ENC_CODERANGE_UNKNOWN:
|
||||
return sym_unknown;
|
||||
case ENC_CODERANGE_BROKEN:
|
||||
return sym_broken;
|
||||
}
|
||||
UNREACHABLE;
|
||||
}
|
||||
|
||||
void
|
||||
Init_coderange(VALUE klass)
|
||||
{
|
||||
sym_7bit = ID2SYM(rb_intern("7bit"));
|
||||
sym_valid = ID2SYM(rb_intern("valid"));
|
||||
sym_unknown = ID2SYM(rb_intern("unknown"));
|
||||
sym_broken = ID2SYM(rb_intern("broken"));
|
||||
rb_define_method(klass, "coderange", str_coderange, 0);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue