#0309 · 方法
找不变量写性质测试
不要只写几个例子。先找出 [函数] 无论输入什么都必须成立的性质,比如「编码后再解码等于原值」「排序后长度不变且有序」「结果不会小于零」。列出至少三条,再用随机生成的输入为每条写一个测试。
Don't stop at a few examples. First find properties of [function] that must hold for any input, e.g. "decode(encode(x)) == x", "sorting keeps the length and yields order", "the result is never negative". List at least three, then write a randomized-input test for each.
小杜
已贴 1,040 张上墙共收到 0 个章