我目前有一个模拟,它具有针对特定输入集的特定行为。每个其他输入都应该返回一个特定的响应。
例如:
Mockito.when(classInstance.myFunc(Mockito.eq("Option1"))).thenReturn(answer1);
Mockito.when(classInstance.myFunc(Mockito.eq("Option2"))).thenReturn(answer2);
Mockito.when(classInstance.myFunc(Mockito.eq("Option3"))).thenReturn(answer3);
Mockito.when(classInstance.myFunc(Mockito.eq("Option4"))).thenReturn(answer4);
// Return defaultAnswer if and(and(not("Option1"), not("Option2")), and(not("Option3"), not("Option4")))
Mockito.when(classInstance.myFunc(AdditionalMatchers.and(AdditionalMatchers.and(AdditionalMatchers.not(Mockito.eq("Option1")), AdditionalMatchers.not(Mockito.eq("Option2")), AdditionalMatchers.and(AdditionalMatchers.not(Mockito.eq("Option3")), AdditionalMatchers.not(Mockito.eq("Option4")))).thenReturn(defaultAnswer);
Run Code Online (Sandbox Code Playgroud)
我最大的麻烦是and(and(not("Option1"), not("Option2")), and(not("Option3"), not("Option4")))线路的复杂性。
我真的希望有一种更简单的方法来指定“其他所有内容”或“不在列表中:[“option1”,...]”的条件
是否有“组内”或类似内容的匹配器?
我有一个文件,其中每一行都是重复的(不幸的是)。
My Name Is John
My Name Is John
I'm 30 years old
I'm 30 years old
New York is my home town
New York is my home town
Run Code Online (Sandbox Code Playgroud)
我想“恢复”重复,换句话说,选择每隔一行并删除它。有没有办法在 VS Code 中使用正则表达式替换?
(在 mac 上工作,所以像这里这样的 Notepad++ 解决方案无关紧要。我知道可以使用 bash,但我想尝试在 VS Code 中做到这一点)