@Test
public void testFormulaContextExtraction() {
Object[][] test = {
new Object[] { "test:IF()", true, "test", "IF()" },
new Object[] { "=IF()", true, "report", "IF()" },
new Object[] { "report-IF()", false, null, null },
new Object[] { "=IF(:)", true, "report", "IF(:)" },
new Object[] { "test=:IF()", false, null, null },
new Object[] { "test asd:IF()", false, null, null },
};
for ( Object[] objects : test ) {
String v = (String) objects[ 0 ];
String[] strings = FormulaUtil.extractFormulaContext( v );
if ( strings[ 0 ] == null ) {
Assert.assertFalse( "Failure in " + v, (Boolean) objects[ 1 ] );
} else {
assertTrue( "Failure in " + v, (Boolean) objects[ 1 ] );
assertEquals( "Failure in " + v, strings[ 0 ], objects[ 2 ] );
assertEquals( "Failure in " + v, strings[ 1 ], objects[ 3 ] );
}
}
}