Почему действительно Утверждает. AreEqual (1.0, дважды. NaN, 1.0) передача?

Можно попробовать что-то как:

InputStream stream = this.getClass().getClassLoader().getResourceAsStream("/images/image.jpg");

В Вашем файле JAR, у Вас могла бы быть структура каталогов:

MyJAR.jar
- com (файлы класса в здесь)
- изображения
----image.jpg

13
задан Colonel Panic 20 January 2015 в 14:23
поделиться

1 ответ

Be careful. NaN is weird, somewhat like null in many DBMSs, and you shouldn't be comparing values to it (either directly, or with Assert.AreEqual). From the docs for Double.NaN:

Use IsNaN to determine whether a value is not a number. It is not possible to determine whether a value is not a number by comparing it to another value equal to NaN.

double zero = 0;
Console.WriteLine((0 / zero) == Double.NaN);  // prints false
Console.WriteLine(Double.IsNaN(0 / zero));  // prints true

You'd have to peer at the internals of Assert(double, double, double) to see what's going on, but in general, you're depending on undefined behavior relative to NaN.

9
ответ дан 1 December 2019 в 22:57
поделиться
Другие вопросы по тегам:

Похожие вопросы: