Fix tutorials default-first build - ref# 156
* Fix tutorials default-first build - ref# 156
Fix assertion error - loss of precision was happening because double was being divided by an integer
* Fix tutorials default-first build - ref# 156
Fixed formatting
package com.baeldung.maths;
-import static org.junit.Assert.assertTrue;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
import org.junit.jupiter.api.Test;
@@ -11,10 +12,10 @@ public class MathSinUnitTest {
double angleInDegrees = 30;
double sinForDegrees = Math.sin(Math.toRadians(angleInDegrees)); // 0.5
- double thirtyDegreesInRadians = 1/6 * Math.PI;
+ double thirtyDegreesInRadians = (double) 1 / 6 * Math.PI;
double sinForRadians = Math.sin(thirtyDegreesInRadians); // 0.5
- assertTrue(sinForDegrees == sinForRadians);
+ assertThat(sinForDegrees, is(sinForRadians));
}
}
