提交 565e60f1 编写于 作者: 陈琦

close task#36554 解决-n指定数量等于{n}定义的数量时的错误

上级 ae430cb4
......@@ -13,9 +13,9 @@ fields:
use: medium # 使用该文件中定义的medium分组。
postfix: "\t"
- field: field_use_instance # 引用其他的定义文件,该文件定义了多个实例。
from: ip.v1.yaml # yaml/ip/v1.yaml
use: privateB{5} # 使用该文件中定义的privateC和privateB两个实例。
- field: field_use_instance # 引用其他的定义文件,该文件定义了多个实例。
from: ip.v1.yaml # yaml/ip/v1.yaml
use: privateB{5} # 使用该文件中定义的privateC和privateB两个实例。
postfix: "\t"
......@@ -128,7 +128,6 @@ func GenerateForField(field *model.DefField, withFix bool) (values []string) {
values = loopFieldValues(field, unionValues, count, true)
} else if field.From != "" { // refer to res
if field.Use != "" { // refer to instance
groupValues := vari.Res[field.From]
groups := strings.Split(field.Use, ",")
......@@ -163,7 +162,11 @@ func GenerateForField(field *model.DefField, withFix bool) (values []string) {
if num == 0 {
valuesFromGroup = groupValues[group]
} else {
valuesFromGroup = groupValues[group][:num%len(groupValues[group])]
mode := num % len(groupValues[group])
if mode == 0 {
mode = len(groupValues[group])
}
valuesFromGroup = groupValues[group][:mode]
}
values = append(values, valuesFromGroup...)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册