summaryrefslogtreecommitdiff
path: root/ext/-test-/string
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-02 13:44:02 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-02 13:44:02 +0000
commitd054eb96317445fb30ac6d8b67721b88927f3f17 (patch)
tree517d36bde55799d6a561a053b76464d6345f42bb /ext/-test-/string
parent866761d2e8e04e8dc39cb306d47ef6e8e0e362b7 (diff)
Add a test for r35863.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/-test-/string')
-rw-r--r--ext/-test-/string/coderange.c29
-rw-r--r--ext/-test-/string/enc_str_buf_cat.c14
2 files changed, 43 insertions, 0 deletions
diff --git a/ext/-test-/string/coderange.c b/ext/-test-/string/coderange.c
new file mode 100644
index 0000000..f6f58c4
--- /dev/null
+++ b/ext/-test-/string/coderange.c
@@ -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);
+}
diff --git a/ext/-test-/string/enc_str_buf_cat.c b/ext/-test-/string/enc_str_buf_cat.c
new file mode 100644
index 0000000..5d583c6
--- /dev/null
+++ b/ext/-test-/string/enc_str_buf_cat.c
@@ -0,0 +1,14 @@
+#include "ruby/ruby.h"
+#include "ruby/encoding.h"
+
+static VALUE
+enc_str_buf_cat(VALUE str, VALUE str2)
+{
+ return rb_enc_str_buf_cat(str, RSTRING_PTR(str2), RSTRING_LEN(str2), rb_enc_get(str2));
+}
+
+void
+Init_enc_str_buf_cat(VALUE klass)
+{
+ rb_define_method(klass, "enc_str_buf_cat", enc_str_buf_cat, 1);
+}