/
BernoullisProgressViewTest.kt
47 lines (40 loc) · 1.83 KB
/
BernoullisProgressViewTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.vlad1m1r.lemniscate
import com.google.common.truth.Truth.assertThat
import org.mockito.kotlin.mock
import com.vlad1m1r.lemniscate.testutils.TestConstants
import com.vlad1m1r.lemniscate.testutils.isPeriodic
import com.vlad1m1r.lemniscate.testutils.setupDefaultMock
import org.junit.Before
import org.junit.Test
import kotlin.math.PI
class BernoullisProgressViewTest {
private val view = mock<BernoullisProgressView>()
@Before
fun setUp() {
view.setupDefaultMock()
}
@Test
fun getGraphX() {
assertThat(view.getGraphX(0.0f)).isWithin(TestConstants.DELTA).of(50.0f)
assertThat(view.getGraphX(0.1f)).isWithin(TestConstants.DELTA).of(49.259254f)
assertThat(view.getGraphX(0.5f)).isWithin(TestConstants.DELTA).of(35.67847f)
assertThat(view.getGraphX(1.0f)).isWithin(TestConstants.DELTA).of(15.816132f)
assertThat(view.getGraphX(PI.toFloat())).isWithin(TestConstants.DELTA).of(-50.0f)
assertThat(view.getGraphX(2.0f)).isWithin(TestConstants.DELTA).of(-11.389914f)
assertThat(view.getGraphX(2 * PI.toFloat())).isWithin(TestConstants.DELTA).of(50.0f)
}
@Test
fun getGraphY() {
assertThat(view.getGraphY(0.0f)).isWithin(TestConstants.DELTA).of(0.0f)
assertThat(view.getGraphY(0.1f)).isWithin(TestConstants.DELTA).of(4.91772f)
assertThat(view.getGraphY(0.5f)).isWithin(TestConstants.DELTA).of(17.10517f)
assertThat(view.getGraphY(1.0f)).isWithin(TestConstants.DELTA).of(13.308815f)
assertThat(view.getGraphY(PI.toFloat())).isWithin(TestConstants.DELTA).of(0.0f)
assertThat(view.getGraphY(2.0f)).isWithin(TestConstants.DELTA).of(-10.356819f)
assertThat(view.getGraphY(2 * PI.toFloat())).isWithin(TestConstants.DELTA).of(0.0f)
}
@Test
fun isPeriodic() {
view.isPeriodic(2 * PI.toFloat())
}
}