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/ACOSHTest.java
-rw-r--r--
2122
 1package io.protobase.f7.formulas.math;
 2
 3import io.protobase.f7.errors.NAException;
 4import io.protobase.f7.errors.NumException;
 5import io.protobase.f7.errors.ValueException;
 6import io.protobase.f7.models.Grid;
 7import io.protobase.f7.testutils.TestFormula;
 8import org.junit.Test;
 9
10import static com.google.common.truth.Truth.assertThat;
11import static org.mockito.Mockito.verify;
12import static org.mockito.Mockito.verifyNoMoreInteractions;
13import static org.mockito.Mockito.when;
14
15public class ACOSHTest extends TestFormula {
16  @Test
17  public void testApply() {
18    assertThat(ACOSH.SELF.apply(null, 10.0)).isEqualTo(2.993222846126381);
19    assertThat(ACOSH.SELF.apply(null, 128731.2)).isEqualTo(12.458628968991492);
20    assertThat(ACOSH.SELF.apply(null, 11.11)).isEqualTo(3.098961197908289);
21    assertThat(ACOSH.SELF.apply(null, 88281.0)).isEqualTo(12.081427368428402);
22  }
23
24  @Test
25  public void testApply_numException() {
26    assertThat(ACOSH.SELF.apply(null, 0.0)).isEqualTo(new NumException());
27    assertThat(ACOSH.SELF.apply(null, 0.0000000001)).isEqualTo(new NumException());
28    assertThat(ACOSH.SELF.apply(null, -10.0)).isEqualTo(new NumException());
29  }
30
31  @Test
32  public void testApply_stringConversion() {
33    assertThat(ACOSH.SELF.apply(null, "10.0")).isEqualTo(2.993222846126381);
34  }
35
36  @Test
37  public void testApply_grid() {
38    assertThat(ACOSH.SELF.apply(null,
39        Grid.builder().add(0, 0, 4.0).add(0, 1, "Don't mind me.").build()
40    )).isEqualTo(2.0634370688955608);
41  }
42
43  @Test
44  public void test_lookup() {
45    ACOSH F = new ACOSH(lookup, collateralLookup);
46    when(collateralLookup.apply(A1, M22_RANGE)).thenReturn(10.0);
47    assertThat(F.apply(A1, M22_RANGE)).isEqualTo(2.993222846126381);
48    verify(collateralLookup).apply(A1, M22_RANGE);
49    verifyNoMoreInteractions(collateralLookup);
50  }
51
52  @Test
53  public void testApply_errorsPassThrough() {
54    assertThat(ACOSH.SELF.apply(null, new ValueException())).isEqualTo(new ValueException());
55  }
56
57  @Test
58  public void testApply_argumentsMismatch() {
59    assertThat(ACOSH.SELF.apply(null, "A", "Too many")).isEqualTo(new NAException());
60  }
61}