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

Fixed also that crash.


svn path=/trunk/koffice/; revision=599898
parent be22a1e9
......@@ -191,15 +191,20 @@ namespace Kross {
struct RubyType<QByteArray>
{
inline static VALUE toVALUE(const QByteArray& ba) {
//return rb_str_new2(ba.constData());
return rb_str_new(ba.constData(), ba.size());
}
inline static QByteArray toVariant(VALUE 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);
switch( TYPE(value) ) {
case T_STRING: {
long length = LONG2NUM( RSTRING(value)->len );
char* ca = rb_str2cstr(value, &length);
return QByteArray(ca, length);
} break;
case T_NIL:
return QByteArray("");
default:
return STR2CSTR( rb_inspect(value) );
}
}
};
......
......@@ -43,11 +43,9 @@ class TestKross < Test::Unit::TestCase
assert( TestObject1.func_qulonglong_qulonglong(378972) == 378972 )
#assert( TestObject1.func_qulonglong_qulonglong(-8540276823902375665225676321823) == -8540276823902375665225676321823 )
end
def testByteArray
#TODO crashes
#assert( TestObject1.func_qbytearray_qbytearray(nil) == nil )
def testByteArray
assert( TestObject1.func_qbytearray_qbytearray(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 " )
......
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