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/GeneralInequalityComparisonTest.java
-rw-r--r--
5900
  1package io.protobase.f7.spreadsheet;
  2
  3import io.protobase.f7.errors.RefException;
  4import io.protobase.f7.testutils.TestExecution;
  5import org.junit.Test;
  6
  7public class GeneralInequalityComparisonTest extends TestExecution {
  8  @Test
  9  public void test_Number() {
 10    runner().addCell("Alpha", "A1", "= 1 <> 1").addExpectedValue("Alpha", "A1", false).run();
 11    runner().addCell("Alpha", "A1", "= 1 <> 2").addExpectedValue("Alpha", "A1", true).run();
 12    runner().addCell("Alpha", "A1", "= 1.1928731 <> 1.1928731").addExpectedValue("Alpha", "A1", false).run();
 13  }
 14
 15  @Test
 16  public void test_String() {
 17    runner().addCell("Alpha", "A1", "= \"Yes\" <> \"Yes\"").addExpectedValue("Alpha", "A1", false).run();
 18    runner().addCell("Alpha", "A1", "= \"Yes\" <> \"No\"").addExpectedValue("Alpha", "A1", true).run();
 19    runner().addCell("Alpha", "A1", "= \"\" <> \"\"").addExpectedValue("Alpha", "A1", false).run();
 20  }
 21
 22  @Test
 23  public void test_Boolean() {
 24    runner().addCell("Alpha", "A1", "= TRUE <> TRUE").addExpectedValue("Alpha", "A1", false).run();
 25    runner().addCell("Alpha", "A1", "= FALSE <> FALSE").addExpectedValue("Alpha", "A1", false).run();
 26    runner().addCell("Alpha", "A1", "= TRUE <> FALSE").addExpectedValue("Alpha", "A1", true).run();
 27  }
 28
 29  @Test
 30  public void test_ArrayLiteral() {
 31    runner().addCell("Alpha", "A1", "= {1, 2, 3} <> {1, 2, 3}").addExpectedValue("Alpha", "A1", false).run();
 32    runner().addCell("Alpha", "A1", "= {1, 2, 3} <> {44}").addExpectedValue("Alpha", "A1", true).run();
 33    runner().addCell("Alpha", "A1", "= {44, #REF!} <> {44, #REF!}").addExpectedValue("Alpha", "A1", false).run();
 34  }
 35
 36  @Test
 37  public void test_NumberToBoolean() {
 38    runner().addCell("Alpha", "A1", "= 0 <> TRUE").addExpectedValue("Alpha", "A1", true).run();
 39    runner().addCell("Alpha", "A1", "= 1 <> TRUE").addExpectedValue("Alpha", "A1", true).run();
 40    runner().addCell("Alpha", "A1", "= 1 <> FALSE").addExpectedValue("Alpha", "A1", true).run();
 41    runner().addCell("Alpha", "A1", "= 0 <> FALSE").addExpectedValue("Alpha", "A1", true).run();
 42  }
 43
 44  @Test
 45  public void test_NumberToString() {
 46    runner().addCell("Alpha", "A1", "= 0 <> \"\"").addExpectedValue("Alpha", "A1", true).run();
 47    runner().addCell("Alpha", "A1", "= 0 <> \"0\"").addExpectedValue("Alpha", "A1", true).run();
 48    runner().addCell("Alpha", "A1", "= 1 <> \"0\"").addExpectedValue("Alpha", "A1", true).run();
 49    runner().addCell("Alpha", "A1", "= 1 <> \"1\"").addExpectedValue("Alpha", "A1", true).run();
 50  }
 51
 52  @Test
 53  public void test_NumberToArrayLiteral() {
 54    runner().addCell("Alpha", "A1", "= 0 <> {0, 1, 2}").addExpectedValue("Alpha", "A1", false).run();
 55    runner().addCell("Alpha", "A1", "= 1 <> {0, 1, 2}").addExpectedValue("Alpha", "A1", true).run();
 56  }
 57
 58  @Test
 59  public void test_NumberToBlank() {
 60    runner().addCell("Alpha", "A1", "= 0 <> M9").addExpectedValue("Alpha", "A1", false).run();
 61    runner().addCell("Alpha", "A1", "= 1 <> M9").addExpectedValue("Alpha", "A1", true).run();
 62    runner().addCell("Alpha", "A1", "= M9 <> 0").addExpectedValue("Alpha", "A1", false).run();
 63    runner().addCell("Alpha", "A1", "= M9 <> 1").addExpectedValue("Alpha", "A1", true).run();
 64    runner().addCell("Alpha", "A1", "= -1 <> M9").addExpectedValue("Alpha", "A1", true).run();
 65    runner().addCell("Alpha", "A1", "= M9 <> -1").addExpectedValue("Alpha", "A1", true).run();
 66  }
 67
 68  @Test
 69  public void test_StringToBoolean() {
 70    runner().addCell("Alpha", "A1", "= \"TRUE\" <> TRUE").addExpectedValue("Alpha", "A1", true).run();
 71    runner().addCell("Alpha", "A1", "= \"FALSE\" <> FALSE").addExpectedValue("Alpha", "A1", true).run();
 72  }
 73
 74  @Test
 75  public void test_StringToBlank() {
 76    runner().addCell("Alpha", "A1", "= \"\" <> M10").addExpectedValue("Alpha", "A1", false).run();
 77    runner().addCell("Alpha", "A1", "= M10 <> \"\"").addExpectedValue("Alpha", "A1", false).run();
 78    runner().addCell("Alpha", "A1", "= \" \" <> M10").addExpectedValue("Alpha", "A1", true).run();
 79    runner().addCell("Alpha", "A1", "= M10 <> \" \"").addExpectedValue("Alpha", "A1", true).run();
 80    runner().addCell("Alpha", "A1", "= \"One\" <> M10").addExpectedValue("Alpha", "A1", true).run();
 81    runner().addCell("Alpha", "A1", "= M10 <> \"One\"").addExpectedValue("Alpha", "A1", true).run();
 82  }
 83
 84  @Test
 85  public void test_BooleanToBlank() {
 86    runner().addCell("Alpha", "A1", "= TRUE <> M10").addExpectedValue("Alpha", "A1", true).run();
 87    runner().addCell("Alpha", "A1", "= FALSE <> M10").addExpectedValue("Alpha", "A1", false).run();
 88    runner().addCell("Alpha", "A1", "= M10 <> TRUE").addExpectedValue("Alpha", "A1", true).run();
 89    runner().addCell("Alpha", "A1", "= M10 <> FALSE").addExpectedValue("Alpha", "A1", false).run();
 90  }
 91
 92  @Test
 93  public void test_ArrayLiteralToString() {
 94    runner().addCell("Alpha", "A1", "= {\"A\", \"B\"} <> \"A\"").addExpectedValue("Alpha", "A1", false).run();
 95    runner().addCell("Alpha", "A1", "= \"A\" <> {\"A\", \"B\"}").addExpectedValue("Alpha", "A1", false).run();
 96    runner().addCell("Alpha", "A1", "= \"B\" <> {\"A\", \"B\"}").addExpectedValue("Alpha", "A1", true).run();
 97  }
 98
 99  @Test
100  public void test_ArrayLiteralToBoolean() {
101    runner().addCell("Alpha", "A1", "= {TRUE, FALSE} <> TRUE").addExpectedValue("Alpha", "A1", false).run();
102    runner().addCell("Alpha", "A1", "= TRUE <> {TRUE, FALSE}").addExpectedValue("Alpha", "A1", false).run();
103    runner().addCell("Alpha", "A1", "= {FALSE, FALSE} <> TRUE").addExpectedValue("Alpha", "A1", true).run();
104    runner().addCell("Alpha", "A1", "= TRUE <> {FALSE, FALSE}").addExpectedValue("Alpha", "A1", true).run();
105  }
106
107  @Test
108  public void test_Error() {
109    runner().addCell("Alpha", "A1", "= 10 <> #REF!").addExpectedValue("Alpha", "A1", new RefException()).run();
110    runner().addCell("Alpha", "A1", "= #REF! <> TRUE").addExpectedValue("Alpha", "A1", new RefException()).run();
111  }
112}