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/ASINHTest.java
-rw-r--r--
2156
 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 ASINHTest extends TestFormula {
15  @Test
16  public void testApply() {
17    assertThat(ASINH.SELF.apply(null, 10.0)).isEqualTo(2.99822295029797);
18    assertThat(ASINH.SELF.apply(null, 128731.2)).isEqualTo(12.458628969021666);
19    assertThat(ASINH.SELF.apply(null, 11.11)).isEqualTo(3.1030120634231873);
20    assertThat(ASINH.SELF.apply(null, 0.0)).isEqualTo(0.0);
21    assertThat(ASINH.SELF.apply(null, 88281.0)).isEqualTo(12.081427368492559);
22    assertThat(ASINH.SELF.apply(null, 2.0)).isEqualTo(1.4436354751788103);
23    assertThat(ASINH.SELF.apply(null, 4.0)).isEqualTo(2.0947125472611012);
24    assertThat(ASINH.SELF.apply(null, -4.0)).isEqualTo(-2.094712547261101);
25    assertThat(ASINH.SELF.apply(null, -10124.0)).isEqualTo(-9.91581129653516);
26  }
27
28  @Test
29  public void testApply_stringConversion() {
30    assertThat(ASINH.SELF.apply(null, "-10124.0")).isEqualTo(-9.91581129653516);
31  }
32
33  @Test
34  public void testApply_grid() {
35    assertThat(ASINH.SELF.apply(null,
36        Grid.builder().add(0, 0, 4.0).add(0, 1, "Don't mind me.").build()
37    )).isEqualTo(2.0947125472611012);
38  }
39
40  @Test
41  public void test_lookup() {
42    ASINH F = new ASINH(lookup, collateralLookup);
43    when(collateralLookup.apply(A1, M22_RANGE)).thenReturn(10.0);
44    assertThat(F.apply(A1, M22_RANGE)).isEqualTo(2.99822295029797);
45    verify(collateralLookup).apply(A1, M22_RANGE);
46    verifyNoMoreInteractions(collateralLookup);
47  }
48
49  @Test
50  public void testApply_errorsPassThrough() {
51    assertThat(ASINH.SELF.apply(null, new ValueException())).isEqualTo(new ValueException());
52  }
53
54  @Test
55  public void testApply_argumentsMismatch() {
56    assertThat(ASINH.SELF.apply(null, "A", "Too many")).isEqualTo(new NAException());
57  }
58}