数字输入的测试用例
处理数字输入时有哪些常见(或有价值)的测试、测试问题、弱点或误解?
这是一个社区 wiki。请添加。
例如,这里有一些示例想法:
- 我经常看到用户在数字字段中输入文本(例如,“>4”或“4 天”等)。
- 字段留空 (null)
- 非常长的数字字符串
- 多个小数和逗号(例如,“4..4”和“4,,434.4.4”)
- 边界值分析:
- 下边界
- 下限 - 1(对于小数/浮点数,使用较小的值)
- 上边界
- 上边界 + 1
- 远低于下限(例如,超出硬件边界值)
- 远高于上限
- 范围的中间
- 0
- 0.0
- 空白,无else " "
- 在有效数字
- 字符串输入 之前、之中或之后的空白其他不正确的数据类型。
- 前面或后面有文字的数字,例如“$5.00”、“4 磅”、“约 60”、“50+”
- 负数
- + 正数符号,“+4”
- 正负号同时存在,例如“+-4 " 和 "-4e+30"
- 10 的指数,大小写、正数和负数,例如“4e10”、“-5E-10”、“+6e+60”等
- 太多“e”字符,例如“4e4e4” " "4EE4"
- 不可能的大/小指数或不合适的指数
- 无法在计算机中表示的十进制值
- 例如 .3 + .6 == 1.0?此错误会影响大多数硬件,因此比较十进制值的输出应该允许一定程度的错误。
- 整数/硬件溢出。例如,对于 32 位整数,将 40 亿加到 40 亿会发生什么?
- 错误使用小数点和千位分隔符(“,”与“.”)(MikeD)
- 国际化 i18n 问题:在英语应用程序中,您写“12,345.67”,意思是“12345.67”,在德语中,您写“12345,67” – (k3b)
- 前导 0 不会使数字成为八进制(常见的 JavaScript 错误)
What are some common (or worthwhile) tests, test questions, weaknesses, or misunderstandings dealing with numeric inputs?
This is a community wiki. Please add to it.
For example, here are a couple sample ideas:
- I commonly see users enter text into number fields (e.g., ">4" or "4 days", etc).
- Fields left blank (null)
- Very long numeric strings
- Multiple decimals and commas (e.g., "4..4" and "4,,434.4.4")
- Boundary Value Analysis:
- Lower Boundary
- Lower Boundary - 1 (for decimal/float, use smaller amounts)
- Upper Boundary
- Upper Boundary + 1
- Far below the lower boundary (e.g., beyond the hardware boundary value)
- Far above the upper boundary
- middle of the range
- 0
- 0.0
- Whitespace, nothing else " "
- Whitespace before, in, or after an otherwise valid number
- String input & other incorrect data types.
- Number with text in front or back, e.g. "$5.00", "4 lbs", "about 60", "50+"
- Negative numbers
- + sign with positive numbers, "+4"
- Both plus and minus sign, e.g. "+-4" and "-4e+30"
- Exponents of 10, both uppercase and lowercase, positive and negative e.g. "4e10", "-5E-10", "+6e+60", etc
- Too many "e" characters, e.g. "4e4e4" "4EE4"
- Impossibly large/small exponents or inappropriate ones
- Decimal values that cannot be represented in a computer
- e.g. .3 + .6 == 1.0? This bug affects most hardware, so outputs that compare decimal values should allow for a degree of error.
- Integer/hardware overflow. e.g., for 32-bit integers, what happens when adding 4 billion to 4 billion?
- Wrong use of decimal sign and thousands separator ("," vs. ".") (MikeD)
- Internationalisation i18n issues: In English applications you write "12,345.67" meaning "12345.67" in German you write "12345,67" – (k3b)
- Leading 0's don't make number octal (common JavaScript bug)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论