f7
f7 is a spreadsheet formula execution library
git clone https://git.vogt.world/f7.git
Log | Files | README.md | LICENSE.md
← All files
name: src/test/java/io/protobase/f7/formulas/math/ASINTest.java
-rw-r--r--
2137
 1package io.protobase.f7.formulas.math;
 2
 3import io.protobase.f7.errors.NAException;
 4import io.protobase.f7.errors.ValueException;
 5import io.protobase.f7.models.Grid;
 6import io.protobase.f7.testutils.TestFormula;
 7import org.junit.Test;
 8
 9import static com.google.common.truth.Truth.assertThat;
10import static org.mockito.Mockito.verify;
11import static org.mockito.Mockito.verifyNoMoreInteractions;
12import static org.mockito.Mockito.when;
13
14public class ASINTest extends TestFormula {
15  @Test
16  public void testApply() {
17    assertThat(ASIN.SELF.apply(null, 10.0)).isEqualTo(Math.asin(10.0));
18    assertThat(ASIN.SELF.apply(null, 128731.2)).isEqualTo(Math.asin(128731.2));
19    assertThat(ASIN.SELF.apply(null, 11.11)).isEqualTo(Math.asin(11.11));
20    assertThat(ASIN.SELF.apply(null, 0.0)).isEqualTo(Math.asin(0.0));
21    assertThat(ASIN.SELF.apply(null, 88281.0)).isEqualTo(Math.asin(88281));
22    assertThat(ASIN.SELF.apply(null, 2.0)).isEqualTo(Math.asin(2.0));
23    assertThat(ASIN.SELF.apply(null, 4.0)).isEqualTo(Math.asin(4.0));
24    assertThat(ASIN.SELF.apply(null, -4.0)).isEqualTo(Math.asin(-4.0));
25    assertThat(ASIN.SELF.apply(null, -10124.0)).isEqualTo(Math.asin(-10124.0));
26  }
27
28  @Test
29  public void testApply_stringConversion() {
30    assertThat(ASIN.SELF.apply(null, "10.0")).isEqualTo(Math.asin(10.0));
31  }
32
33  @Test
34  public void testApply_grid() {
35    assertThat(ASIN.SELF.apply(null,
36        Grid.builder().add(0, 0, -4.0).add(0, 1, "Don't mind me.").build()
37    )).isEqualTo(Math.asin(-4.0));
38  }
39
40  @Test
41  public void test_lookup() {
42    ASIN F = new ASIN(lookup, collateralLookup);
43    when(collateralLookup.apply(A1, M22_RANGE)).thenReturn(128731.2);
44    assertThat(F.apply(A1, M22_RANGE)).isEqualTo(Math.asin(128731.2));
45    verify(collateralLookup).apply(A1, M22_RANGE);
46    verifyNoMoreInteractions(collateralLookup);
47  }
48
49  @Test
50  public void testApply_errorsPassThrough() {
51    assertThat(ASIN.SELF.apply(null, new ValueException())).isEqualTo(new ValueException());
52  }
53
54  @Test
55  public void testApply_argumentsMismatch() {
56    assertThat(ASIN.SELF.apply(null, "A", "Too many")).isEqualTo(new NAException());
57  }
58}