Commit be22a1e9 authored by Sebastian Sauer's avatar Sebastian Sauer
Browse files

Fixed ruby QByteArray handling.

svn path=/trunk/koffice/; revision=599895
parent bc0a9c2e
......@@ -191,10 +191,15 @@ namespace Kross {
struct RubyType<QByteArray>
{
inline static VALUE toVALUE(const QByteArray& ba) {
return rb_str_new2(ba.constData());
//return rb_str_new2(ba.constData());
return rb_str_new(ba.constData(), ba.size());
}
inline static QByteArray toVariant(VALUE value) {
return STR2CSTR(value);
//QByteArray ba = STR2CSTR( rb_inspect(value) );
//bool isstring = ( TYPE(value) == T_STRING );
long length = LONG2NUM( RSTRING(value)->len );
char* ca = rb_str2cstr(value, &length);
return QByteArray(ca, length);
}
};
......
......@@ -45,8 +45,12 @@ class TestKross < Test::Unit::TestCase
end
def testByteArray
#TODO crashes
#assert( TestObject1.func_qbytearray_qbytearray(nil) == nil )
assert( TestObject1.func_qbytearray_qbytearray("") == "" )
assert( TestObject1.func_qbytearray_qbytearray(" Some String as ByteArray ") == " Some String as ByteArray " )
#assert( TestObject1.func_qbytearray_qbytearray(" \0\n\r\t\s\0 test ") == " \0\n\r\t\s\0 test " )
assert( TestObject1.func_qbytearray_qbytearray(" \0\n\r\t\s\0 test ") == " \0\n\r\t\s\0 test " )
end
def testString
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment