Method: Collapstring.fuzz

Defined in:
ext/collapstring/collapstring.c

.fuzz(length) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
# File 'ext/collapstring/collapstring.c', line 127

static VALUE collapstring_fuzz(VALUE self, VALUE length)
{
        static char *chars = "\'\"\\ ";
        Check_Type(length, T_FIXNUM);
        int i, l = NUM2INT(length);
        VALUE res = rb_str_new(NULL, 0);
        assert(res);
        for (i = 0; i < l; i++) {
                res = rb_str_cat(res, chars + rand() % 4, 1);
        }
        return res;
}