我想测试两个对象的相等性,但对double
它们的某些嵌套属性上存在的值的精度有一定的判断力。usingComparatorForTypeFoo
似乎是一个合适的解决方案,但如果我的对象具有类型属性,Bar
其中Bar.baz
是double
我希望应用此精度判断的属性,则它似乎不起作用。该示例isEqualToComparingFieldByFieldRecursively
并不能完全解决我正在尝试测试的情况。
一些示例代码
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Comparator;
import java.util.Objects;
import org.junit.Test;
public class ComparatorForTypeTest {
private static final Comparator<Double> DOUBLE_COMPARATOR = new Comparator<Double>() {
@Override
public int compare(Double d1, Double d2) {
return Math.abs(d1 - d2) <= 0.1 ? 0 : 1;
}
};
class Foo {
private int id;
private double baz;
private Bar bar;
public Foo(int id, double baz, Bar bar) {
this.id = …
Run Code Online (Sandbox Code Playgroud) 美好的一天!它是关于Microsoft Server Speech SDK v11.0(服务器版本).
我在MSDN示例中运行了测试示例.所以英语短语-red,blue--很好.但我也想识别俄语 - 安装微软语音识别语言-TELE(ru-RU)并运行我的app /
码:
static void DoWork()
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("ru-RU");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("ru-RU");
// Create a new SpeechRecognitionEngine instance.
SpeechRecognitionEngine sre = new SpeechRecognitionEngine();
// Configure the input to the recognizer.
sre.SetInputToWaveFile(@"c:\Test\???????.wav");
// Create a simple grammar that recognizes "red", "green", or "blue".
Choices colors = new Choices();
// colors.Add(new string[] { "red", "green", "blue","???????" });
colors.Add(new string[] { "???????" }); //russian word- "red"
// Create a …
Run Code Online (Sandbox Code Playgroud)