diff options
author | Fedor Yudanov <fedwiz@academ.org> | 2013-04-09 20:10:33 +0700 |
---|---|---|
committer | Fedor Yudanov <fedwiz@academ.org> | 2013-04-09 20:10:33 +0700 |
commit | 1b31483f9be4025e8f5d92e93f9b9969e6b7371d (patch) | |
tree | 24eb40ba01905460bb24ec3538eb70a262e8d010 /rbejdb | |
parent | 53c77cf4606a68d5602aea3d90de42930a1859c4 (diff) | |
download | ejdb-1b31483f9be4025e8f5d92e93f9b9969e6b7371d.tar.gz ejdb-1b31483f9be4025e8f5d92e93f9b9969e6b7371d.tar.bz2 ejdb-1b31483f9be4025e8f5d92e93f9b9969e6b7371d.zip |
#50 - advanced ruby types test
Diffstat (limited to 'rbejdb')
-rw-r--r-- | rbejdb/src/rbbson.c | 2 | ||||
-rw-r--r-- | rbejdb/src/rbejdb.c | 2 | ||||
-rw-r--r-- | rbejdb/test/t2.rb | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/rbejdb/src/rbbson.c b/rbejdb/src/rbbson.c index 22be25b..3fbcfd1 100644 --- a/rbejdb/src/rbbson.c +++ b/rbejdb/src/rbbson.c @@ -310,7 +310,7 @@ VALUE bson_iterator_to_ruby(bson_iterator* it, bson_type t) { VALUE bdata = rb_ary_new(); int i; for (i = 0; i < length; i++) { - rb_ary_push(bdata, INT2NUM(buf[i])); + rb_ary_push(bdata, INT2NUM((unsigned char) buf[i])); } val = rb_funcall(rb_path2class("EJDBBinary"), rb_intern("new"), 1, bdata); diff --git a/rbejdb/src/rbejdb.c b/rbejdb/src/rbejdb.c index d2ae8f9..921eebd 100644 --- a/rbejdb/src/rbejdb.c +++ b/rbejdb/src/rbejdb.c @@ -697,7 +697,7 @@ VALUE EJDB_binary_init(VALUE self, VALUE bdata) { for (i = 0; i < length; i++) { VALUE byte = rb_ary_entry(bdata, i); if (NUM2INT(byte) > 255 || NUM2INT(byte) < 0) { - rb_raise(rb_eRuntimeError, "Invalid value in binary array for EJDBBinary"); + rb_raise(rb_eRuntimeError, "Invalid value in binary array for EJDBBinary: %d", NUM2INT(byte)); } } diff --git a/rbejdb/test/t2.rb b/rbejdb/test/t2.rb index 39a5841..2717665 100644 --- a/rbejdb/test/t2.rb +++ b/rbejdb/test/t2.rb @@ -523,7 +523,7 @@ class EJDBTestUnit < Test::Unit::TestCase :true => true, :false => false, :symbol => :symbol, - :binary => EJDBBinary.new([1, 1, 1]), + :binary => EJDBBinary.new([1, 0, 255]), :time => Time.now }) @@ -544,7 +544,7 @@ class EJDBTestUnit < Test::Unit::TestCase assert !obj["false"] assert obj["symbol"].is_a? Symbol assert_equal(:symbol, obj["symbol"]) - assert_equal([1, 1, 1], obj["binary"].to_a) + assert_equal([1, 0, 255], obj["binary"].to_a) assert obj["time"].is_a? Time #puts $jb.find("monsters").to_a.to_s |