gpt4 book ai didi

unit-testing - 单元测试 - 如何将带逗号的字符串传递到 DUnitX 中的测试用例

转载 作者:行者123 更新时间:2023-12-03 15:28:17 25 4
gpt4 key购买 nike

如果我有一个带有 string 参数的单元测试,并且我想检查输入字符串是否在某处有 逗号 (,) ,我应该创建一个其中包含逗号的输入字符串。

但是如何将其传递给测试用例呢?

[Test]    
[TestCase('TestA', '12,34')] //AValue1 gets only '12' instead of '12,34'
[TestCase('TestB', '12,,34')] //AValue1 gets only '12' instead of '12,34'
[TestCase('TestC', '12/,34')] //AValue1 gets only '12/' instead of '12,34'
[TestCase('TestD', '12\,34')] //AValue1 gets only '12\' instead of '12,34'
procedure ValueShouldHaveComma(const AValue1: string);

最佳答案

我找到了:

    [Test]
[TestCase('TestA', '12,34', ';')] //AValue1 gets '12,34'
procedure ValueShouldHaveComma(const AValue1: string);

测试用例的最后一个可选参数是分隔符。

关于unit-testing - 单元测试 - 如何将带逗号的字符串传递到 DUnitX 中的测试用例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44538544/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com