LoginSignup
1

More than 5 years have passed since last update.

Rantly(property based testing tool)でテストデータ生成 - sized

Posted at

Rantly#sized で任意のサイズのデータを作ります

関連記事

tbpgr の rantly 関連記事

サンプル

# --文字列のサイズ指定--
Rantly{sized(3){string}}
# => "Z%v"
Rantly{sized(3){string}}
# => "CM$"
Rantly{sized(5){string}}
# => ")j(XX"
Rantly{sized(5){string}}
# => "xBKz["
Rantly{sized(5){string(:lower)}}
# => "jhbqm"
Rantly{sized(5){string(:upper)}}
# => "NRMYH"

# --配列のサイズ指定--
Rantly{sized(5){array{integer}}}
# => [-607208170168480669, 1513740129111666149, 777624871410992252, -827454461475545697, -1224300361333572634]
Rantly{sized(5){array{integer}}}
# => [356982138096701511, 2053870948491535825, 2270526892161025899, -493553456250269850, 1297713486671714040]

# --ディクショナリのサイズ指定--
Rantly{sized(5){dict{[string, integer]}}}
# => {"wg&Fq"=>1597295876761123245, "noifc"=>-1756614871689738693, "HCluf"=>-2130175418351173249, ".yw-!"=>-1790551654779019569, "^=(C|"=>89346602558527588}
Rantly{sized(5){dict{[string, integer]}}}
# => {"qms.{"=>1612436610708564014, "hP?ln"=>2009765839527579985, "USMaQ"=>-998249809492853341, "5['zx"=>291326024621946150, "}uUUr"=>1613729193229470410}

外部資料

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1