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/spreadsheet/GeneralAdditionTest.java
-rw-r--r--
3539
 1package io.protobase.f7.spreadsheet;
 2
 3import io.protobase.f7.errors.DivException;
 4import io.protobase.f7.errors.NAException;
 5import io.protobase.f7.errors.NameException;
 6import io.protobase.f7.errors.NullException;
 7import io.protobase.f7.errors.NumException;
 8import io.protobase.f7.errors.ParseException;
 9import io.protobase.f7.errors.RefException;
10import io.protobase.f7.errors.ValueException;
11import io.protobase.f7.testutils.TestExecution;
12import org.junit.Test;
13
14public class GeneralAdditionTest extends TestExecution {
15  @Test
16  public void test_Numbers() {
17    runner().addCell("Alpha", "A1", "= 10 + 10").addExpectedValue("Alpha", "A1", 20.0).run();
18    runner().addCell("Alpha", "A1", "= 0 + 0").addExpectedValue("Alpha", "A1", 0.0).run();
19    runner().addCell("Alpha", "A1", "= 10 + -10").addExpectedValue("Alpha", "A1", 0.0).run();
20    runner().addCell("Alpha", "A1", "= -10 + -10").addExpectedValue("Alpha", "A1", -20.0).run();
21    runner().addCell("Alpha", "A1", "= 1e10 + 1.1").addExpectedValue("Alpha", "A1", 1.00000000011E10).run();
22  }
23
24  @Test
25  public void test_Boolean() {
26    runner().addCell("Alpha", "A1", "= 9 + TRUE").addExpectedValue("Alpha", "A1", 10.0).run();
27    runner().addCell("Alpha", "A1", "= 9 + FALSE").addExpectedValue("Alpha", "A1", 9.0).run();
28    runner().addCell("Alpha", "A1", "= 9 + -TRUE").addExpectedValue("Alpha", "A1", 8.0).run();
29    runner().addCell("Alpha", "A1", "= 9 + -FALSE").addExpectedValue("Alpha", "A1", 9.0).run();
30  }
31
32  @Test
33  public void test_String() {
34    runner().addCell("Alpha", "A1", "= 9 + \"10\"").addExpectedValue("Alpha", "A1", 19.0).run();
35    runner().addCell("Alpha", "A1", "= 9 + \"1e10\"").addExpectedValue("Alpha", "A1", 1.0000000009E10).run();
36    runner().addCell("Alpha", "A1", "= 9 + \"0\"").addExpectedValue("Alpha", "A1", 9.0).run();
37  }
38
39  @Test
40  public void test_StringNotNumber() {
41    runner().addCell("Alpha", "A1", "= 9 + \"No good.\"").addExpectedValue("Alpha", "A1", new ValueException()).run();
42    runner().addCell("Alpha", "A1", "= 9 + \"10    10\"").addExpectedValue("Alpha", "A1", new ValueException()).run();
43  }
44
45  @Test
46  public void test_Array() {
47    runner().addCell("Alpha", "A1", "= 2 + {1}").addExpectedValue("Alpha", "A1", 3.0).run();
48    runner().addCell("Alpha", "A1", "= 2 + {1, 44}").addExpectedValue("Alpha", "A1", 3.0).run();
49    runner().addCell("Alpha", "A1", "= 2 + -{1, \"Ignore me.\"}").addExpectedValue("Alpha", "A1", 1.0).run();
50  }
51
52  @Test
53  public void test_Blank() {
54    runner().addCell("Alpha", "A1", "= 2 + M44").addExpectedValue("Alpha", "A1", 2.0).run();
55  }
56
57  @Test
58  public void test_Errors() {
59    runner()
60        .addCell("Alpha", "A1", "= 3 + #NULL!")
61        .addCell("Alpha", "A2", "= 3 + #DIV/0!")
62        .addCell("Alpha", "A3", "= 3 + #VALUE!")
63        .addCell("Alpha", "A4", "= 3 + #REF!")
64        .addCell("Alpha", "A5", "= 3 + #NAME?")
65        .addCell("Alpha", "A6", "= 3 + #NUM!")
66        .addCell("Alpha", "A7", "= 3 + #N/A")
67        .addCell("Alpha", "A8", "= 3 + #ERROR!")
68        .addExpectedValue("Alpha", "A1", new NullException())
69        .addExpectedValue("Alpha", "A2", new DivException())
70        .addExpectedValue("Alpha", "A3", new ValueException())
71        .addExpectedValue("Alpha", "A4", new RefException())
72        .addExpectedValue("Alpha", "A5", new NameException())
73        .addExpectedValue("Alpha", "A6", new NumException())
74        .addExpectedValue("Alpha", "A7", new NAException())
75        .addExpectedValue("Alpha", "A8", new ParseException())
76        .run();
77  }
78}