`xor`,`required` 和 `and` 不能一起使用
如果在一面旗帜上贴上 " 需要 " 的标签,即使旗帜没有被通过,也不会出错。
测试大小写 : 开始 func TestXorAnd required(t *t testing.T) { (简体中文). (原始内容存档于2018-06-21). var cli struct { 你好 弦 'xor:"你好" 需要:""""" 一弦'xor:"你好"和"二" 二弦"和:"二" {\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}你觉得呢?
p: = must New(t, & cli) (中文(简体) ). , 错误 := p.Parse ([] string * *) 主张。 等错( t, 错误, “ 挂下旗帜 : -- hello = 硬化或 -- 1 = 硬化, -- 1 = 硬化和 -- 2 = 硬化) {\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}你觉得呢?
错误 :
控制台
$去测试./.
-- -- FAIL: 测试要求(0.
kong test.go: 1195: 预期出错
错误
GitHub.com/电磁/公制0.597
错误< 详细 }} 概述> 完全测试外壳 </摘要 >
开始 func TestXorAnd required(t *t testing.T) { (简体中文). (原始内容存档于2018-06-21). var cli struct { 你好 弦 'xor:"你好" 需要:""""" 一弦'xor:"你好"和"二" 二弦"和:"二" {\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}你觉得呢?
p: = must New(t, & cli) (中文(简体) ). , 错误 := p.Parse ([] string * *) 主张。 等错( t, 错误, “ 挂下旗帜 : -- hello = 硬化或 -- 1 = 硬化, -- 1 = 硬化和 -- 2 = 硬化)
p = mustNew(t, & cli) (中文(简体) ). , 错误 = p.Parse ([] string{"- 1=valOne]) 主张。 等效错误( t, 错误, “ - 1 and - 2 必须一起使用 ”)
p = mustNew(t, & cli) (中文(简体) ). , 错误 = p.Parse ([] string{"- 2=val2")] 主张。 等效错误( t, 错误, “ - 1 and - 2 必须一起使用 ”)
p = mustNew(t, & cli) (中文(简体) ). ,错误=p.Parse ([]string{"-hello=valHello","- 1=val One") (中文(简体) ). 主张。 等效 Error( t, wrong, "-hello and -- 1不能一起使用, -- 1和 -- 2必须一起使用")
p = mustNew(t, & cli) (中文(简体) ). ,错误=p.Parse ([]string{"-hello=valhello","-2=val2"}) 主张。 等效错误( t, 错误, “ - 1 and - 2 必须一起使用 ”)
p = mustNew(t, & cli) (中文(简体) ). ,错误=p.Parse ([]string{"-hello=valHello"),"- 1=val One","-2=val Two"}). 主张。 等效 Error( t, 错误, "- heello and -- 1 无法一起使用) Name
p = mustNew(t, & cli) (中文(简体) ). , 错误=p.Parse ([] string{"-hello=valhello") (中文(简体) ). 。没有错误( t, 错误)
p = mustNew(t, & cli) (中文(简体) ). , 错误 = p.Parse ([] string{"- 1=val One", "- 2=val Two" ) 。没有错误( t, 错误) {\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}你觉得呢?
func TestXorAnd Required Many(t * testing.T) { 请检查url=值 (帮助). (原始内容存档于2018-06-21). var cli struct { 你好 弦 '需要:' '' xor: 'hello' ' 一弦"需要:"("") xor:"你好"和"二". 两弦"需要"和"需要" {\fn黑体\fs22\bord1\shad0\3aHBE\4aH00\fscx67\fscy66\2cHFFFFFF\3cH808080}你觉得呢?
p: = must New(t, & cli) (中文(简体) ). , 错误 := p.Parse ([] string * *) 主张。 等错( t, 错误, “ 挂下旗帜 : -- hello = 硬化或 -- 1 = 硬化, -- 1 = 硬化和 -- 2 = 硬化)
p = mustNew(t, & cli) (中文(简体) ). , 错误 = p.Parse ([] string{"- 1=valOne]) 主张。 等效错误( t, 错误, “ - 1 and - 2 必须一起使用 ”)
p = mustNew(t, & cli) (中文(简体) ). , 错误 = p.Parse ([] string{"- 2=val2")] 主张。 等错( t, 错误, " - 1 and - 2 must) . . . . . . .
内容来源: alecthomas/kong