Class: CaseHouse
Overview
通用测试点库[email protected]
Constant Summary collapse
- @@instance =
nil
Class Method Summary collapse
Instance Method Summary collapse
-
#get_all_number ⇒ Object
功能: 产生8,16,32,64位数字的所有边界值.
-
#rand_string(size, mask) ⇒ Object
功能 生成随机字符串.
Methods inherited from DataHouse
Constructor Details
This class inherits a constructor from DataHouse
Class Method Details
.get_instance ⇒ Object
123 124 125 126 |
# File 'lib/common/data_house.rb', line 123 def self.get_instance @@instance = new("case") unless @@instance @@instance end |
Instance Method Details
#get_all_number ⇒ Object
功能: 产生8,16,32,64位数字的所有边界值
参数: 无
返回: ret数字的数组
Example: CaseHouse.get_instance.get_all_number
181 182 183 |
# File 'lib/common/data_house.rb', line 181 def get_all_number return [-18446744073709551616, -18446744073709551615, -9223372036854775808, -9223372036854775807, -4294967296, -4294967295, -2147483648, -2147483647, -65536,-65535, -32768, -32767, -256, -255, -1, 0, 1, 255, 256, 32767, 32768, 65535, 65536, 2147483647, 2147483648, 4294967295, 4294967296, 9223372036854775807, 9223372036854775808, 18446744073709551615, 18446744073709551616] end |
#rand_string(size, mask) ⇒ Object
功能生成随机字符串
参数size: 串的长度mask: 串的内容,mask是个字符串类型。其中包含一些用于表示字符串类型的字符。 a: 小写字符串A: 大写字符串 0: 数字串 $: 特殊字符串 B: 空白字符mask中字符顺序无关
返回ret字符串
Example CaseHouse.get_instance.rand_string(10,“aAB0$”)
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/common/data_house.rb', line 146 def rand_string(size, mask) charpool=[] if mask.scan("a").size > 0 charpool = charpool+("a".."z").to_a end if mask.scan("A").size > 0 charpool = charpool+("A".."Z").to_a end if mask.scan("0").size > 0 charpool = charpool+("0".."9").to_a end if mask.scan("$").size > 0 charpool = charpool+"~!@#\$%^&*()_+=-{}|\\][:\"';<>?/.,".split(//) end if mask.scan("B").size > 0 charpool = charpool+[" "," "," "] end ret="" 1.upto(size){|i| ret << charpool[rand(charpool.size-1)] } return ret end |