小编Lor*_*ill的帖子

assertj 中的 usingComparatorForType 似乎不适用于作为对象属性的对象的属性

我想测试两个对象的相等性,但对double它们的某些嵌套属性上存在的值的精度有一定的判断力。usingComparatorForTypeFoo似乎是一个合适的解决方案,但如果我的对象具有类型属性,Bar其中Bar.bazdouble我希望应用此精度判断的属性,则它似乎不起作用。该示例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)

java assertj

5
推荐指数
1
解决办法
3493
查看次数

语法的语言与语音识别器的语言不匹配

美好的一天!它是关于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)

c# speech-recognition microsoft-speech-platform

3
推荐指数
2
解决办法
6125
查看次数