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/info/ISBLANKTest.java
-rw-r--r--
2162
 1package io.protobase.f7.formulas.info;
 2
 3import io.protobase.f7.errors.NAException;
 4import io.protobase.f7.models.Grid;
 5import io.protobase.f7.testutils.TestFormula;
 6import org.junit.Test;
 7
 8import static com.google.common.truth.Truth.assertThat;
 9import static org.mockito.Mockito.verify;
10import static org.mockito.Mockito.when;
11
12public class ISBLANKTest extends TestFormula {
13  @Test
14  public void test_number() {
15    assertThat(ISBLANK.SELF.apply(null, 10.0)).isEqualTo(false);
16  }
17
18  @Test
19  public void test_string() {
20    assertThat(ISBLANK.SELF.apply(null, "String")).isEqualTo(false);
21  }
22
23  @Test
24  public void test_boolean() {
25    assertThat(ISBLANK.SELF.apply(null, true)).isEqualTo(false);
26    assertThat(ISBLANK.SELF.apply(null, false)).isEqualTo(false);
27  }
28
29  @Test
30  public void test_error() {
31    assertThat(ISBLANK.SELF.apply(null, new NAException())).isEqualTo(false);
32  }
33
34  @Test
35  public void test_blankAKANull() {
36    String NULL = null;
37    assertThat(ISBLANK.SELF.apply(null, NULL)).isEqualTo(true);
38  }
39
40  @Test
41  public void test_lookup() {
42    ISBLANK F = new ISBLANK(lookup, collateralLookup);
43    when(collateralLookup.apply(A1, M22_RANGE)).thenReturn(Grid.builder().build());
44    assertThat(F.apply(A1, M22_RANGE)).isEqualTo(true);
45    verify(collateralLookup).apply(A1, M22_RANGE);
46  }
47
48  @Test
49  public void test_grid() {
50    assertThat(ISBLANK.SELF.apply(null, Grid.builder().add(0, 0, "Yes").build())).isEqualTo(false);
51    assertThat(ISBLANK.SELF.apply(null, Grid.builder().add(0, 0, 22000.000).build())).isEqualTo(false);
52    assertThat(ISBLANK.SELF.apply(null, Grid.builder().add(0, 0, true).build())).isEqualTo(false);
53    assertThat(ISBLANK.SELF.apply(null,
54        Grid.builder()
55            .add(0, 0, "Nope")
56            .add(0, 1, false)
57            .build()))
58        .isEqualTo(false);
59    assertThat(ISBLANK.SELF.apply(null, Grid.builder().add(0, 0, new NAException()).build())).isEqualTo(false);
60  }
61
62  @Test
63  public void test_errorFromArgumentsMismatch() {
64    assertThat(ISBLANK.SELF.apply(null)).isEqualTo(new NAException());
65    assertThat(ISBLANK.SELF.apply(null, "A", "B")).isEqualTo(new NAException());
66  }
67}