Exemple #1
0
 /** Method: checkEqTypeTypesArray(String originalText, String[] types, int first) */
 public void testcheckEqTypeTypesArray05() {
   boolean ok;
   try {
     ok = true;
     String[] types = new String[] {"BAR", "ADD", "FOO"};
     TermUtilities.checkEqTypeTypesArray("COUNT[EQTYPE.BAR.ADD.FOO]", types, 0);
   } catch (TermEvaulatorException e) {
     ok = false;
   }
   is(ok, eq(true), "EqtypesTypesArray05 Include FOO");
 }
Exemple #2
0
 /** Method: checkEqTypeTypesArray(String originalText, String[] types, int first) */
 public void testcheckEqTypeTypesArray02() {
   boolean ok;
   try {
     ok = true;
     String[] types = new String[] {"NOTEQUIPPED"};
     TermUtilities.checkEqTypeTypesArray("COUNT[EQTYPE.NOTEQUIPPED]", types, 0);
   } catch (TermEvaulatorException e) {
     ok = false;
   }
   is(ok, eq(true), "EqtypesTypesArray02 Single Type NOTEQUIPPED");
 }
Exemple #3
0
 /** Method: checkEqTypeTypesArray(String originalText, String[] types, int first) */
 public void testcheckEqTypeTypesArray03() {
   boolean ok;
   try {
     ok = true;
     String[] types = new String[] {"EQUIPPED", "FOO"};
     TermUtilities.checkEqTypeTypesArray("COUNT[EQTYPE.EQUIPPED.FOO]", types, 0);
   } catch (TermEvaulatorException e) {
     ok = false;
   }
   is(ok, eq(false), "EqtypesTypesArray03 EQUIPPED with spurious type");
 }
Exemple #4
0
 /** Method: splitAndConvertIntegers(final String source, int numOfFields) */
 public void testConvertToIntegers04() {
   boolean ok;
   try {
     ok = true;
     String orig = "COUNT[MARSHMALLOWS.1.2.3.foo]";
     TermUtilities.convertToIntegers(orig, "1.2.3.foo", 6, 4);
   } catch (TermEvaulatorException e) {
     ok = false;
   }
   is(ok, eq(false), "ConvertToIntegers: three ints plus spurious non-int fails");
 }
Exemple #5
0
 /** Method: splitAndConvertIntegers(final String source, int numOfFields) */
 public void testConvertToIntegers05() {
   boolean ok;
   try {
     ok = true;
     String orig = "COUNT[MARSHMALLOWS.1.2.3.4]";
     TermUtilities.convertToIntegers(orig, "1.2.3.4", 6, 3);
   } catch (TermEvaulatorException e) {
     ok = false;
   }
   is(ok, eq(false), "ConvertToIntegers: ask for three with four present fails");
 }
Exemple #6
0
 /** Method: checkEquipmentTypesArray(String originalText, String[] types, int first) */
 public void testcheckEquipmentTypesArray07() {
   boolean ok;
   try {
     ok = true;
     String[] types = new String[] {"NOT", "FOO", "ADD", "BAR", "IS", "BAZ"};
     TermUtilities.checkEquipmentTypesArray("COUNT[EQUIPMENT.NOT.FOO.ADD.BAR.IS.BAZ]", types, 0);
   } catch (TermEvaulatorException e) {
     ok = false;
   }
   is(ok, eq(true), "EquipmentTypesArray07 All options");
 }
Exemple #7
0
 /** Method: checkEquipmentTypesArray(String originalText, String[] types, int first) */
 public void testcheckEquipmentTypesArray06() {
   boolean ok;
   try {
     ok = true;
     String[] types = new String[] {"IS", "FOO"};
     TermUtilities.checkEquipmentTypesArray("COUNT[EQUIPMENT.IS.FOO]", types, 0);
   } catch (TermEvaulatorException e) {
     ok = false;
   }
   is(ok, eq(true), "EquipmentTypesArray06 Only FOO");
 }
Exemple #8
0
 /** Method: checkEquipmentTypesArray(String originalText, String[] types, int first) */
 public void testcheckEquipmentTypesArray01() {
   boolean ok;
   try {
     ok = true;
     String[] types = new String[] {"EQUIPPED"};
     TermUtilities.checkEquipmentTypesArray("COUNT[EQUIPMENT.EQUIPPED]", types, 0);
   } catch (TermEvaulatorException e) {
     ok = false;
   }
   is(ok, eq(false), "EquipmentTypesArray01 Single Type EQUIPPED");
 }
Exemple #9
0
 /** Method: checkEqTypeTypesArray(String originalText, String[] types, int first) */
 public void testcheckEqTypeTypesArray08() {
   boolean ok;
   try {
     ok = true;
     String[] types = new String[] {"QUUX", "NOT", "FOO", "ADD", "BAR", "IS", "BAZ", "QUX"};
     TermUtilities.checkEqTypeTypesArray(
         "COUNT[EQTYPE.QUUX.NOT.FOO.ADD.BAR.IS.BAZ.QUX]", types, 0);
   } catch (TermEvaulatorException e) {
     ok = false;
   }
   is(ok, eq(false), "EqtypesTypesArray08 All options with spurious");
 }
Exemple #10
0
 /** Method: splitAndConvertIntegers(final String source, int numOfFields) */
 public void testConvertToIntegers01() {
   boolean ok;
   int[] nums = new int[1];
   try {
     ok = true;
     String orig = "COUNT[MARSHMALLOWS.1]";
     nums = TermUtilities.convertToIntegers(orig, "1", 6, 1);
   } catch (TermEvaulatorException e) {
     ok = false;
   }
   is(ok, eq(true), "ConvertToIntegers: one int is ok");
   is(nums[0], eq(1), "ConvertToIntegers: one int is ok - first");
 }
Exemple #11
0
  /** Method: splitAndConvertIntegers(final String source, int numOfFields) */
  public void testSplitAndConvertIntegers04() {
    boolean ok;
    try {
      ok = true;
      TermUtilities.splitAndConvertIntegers("Test.3.57.67.foo", "3.57.67.foo", 3);
    } catch (NumberFormatException e) {
      ok = false;
    } catch (TermEvaulatorException e) {
      ok = false;
    }

    is(ok, eq(false), "three ints plus spurious non-int fails");
  }
Exemple #12
0
 /** Method: splitAndConvertIntegers(final String source, int numOfFields) */
 public void testConvertToIntegers02() {
   boolean ok;
   int[] nums = new int[1];
   try {
     ok = true;
     String orig = "COUNT[MARSHMALLOWS.1.2]";
     nums = TermUtilities.convertToIntegers(orig, "1.2", 6, 2);
   } catch (TermEvaulatorException e) {
     ok = false;
   }
   is(ok, eq(true), "ConvertToIntegers: two ints is ok");
   is(nums[0], eq(1), "ConvertToIntegers: two ints is ok:first");
   is(nums[1], eq(2), "ConvertToIntegers: two ints is ok:second");
 }
Exemple #13
0
  /** Method: extractContentsOfBrackets(String expressionString, String src, int fixed) */
  public void testExtractContentsOfBrackets03() {
    String orig = "COUNT[MARSHMALLOWS.FOO]B";
    int length = orig.indexOf('[');

    boolean ok;
    try {
      ok = true;
      TermUtilities.extractContentsOfBrackets(orig, "CLASS:Foo Bar", length + 1);
    } catch (TermEvaulatorException e) {
      ok = false;
    }

    is(ok, eq(false), "Fail, ] not the last char");
  }
Exemple #14
0
 /** Method: splitAndConvertIntegers(final String source, int numOfFields) */
 public void testSplitAndConvertIntegers01() {
   boolean ok;
   int[] nums = new int[1];
   try {
     ok = true;
     nums = TermUtilities.splitAndConvertIntegers("Test:3", "3", 1);
   } catch (NumberFormatException e) {
     ok = false;
   } catch (TermEvaulatorException e) {
     ok = false;
   }
   is(ok, eq(true), "one int is ok");
   is(nums[0], eq(3), "one int is ok:first");
 }
Exemple #15
0
  /** Method: extractContentsOfBrackets(String expressionString, String src, int fixed) */
  public void testExtractContentsOfBrackets01() {
    String orig = "COUNT[MARSHMALLOWS.FOO]";
    String inside = "";
    int length = orig.indexOf('[');

    boolean ok;
    try {
      ok = true;
      inside = TermUtilities.extractContentsOfBrackets(orig, "CLASS:Foo Bar", length + 1);
    } catch (TermEvaulatorException e) {
      ok = false;
    }

    is(ok, eq(true), "Extracts Text correctly");
    is(inside, strEq("MARSHMALLOWS.FOO"), "Text is correct ExtractContentsOfBrackets01");
  }
Exemple #16
0
  /** Method: splitAndConvertIntegers(final String source, int numOfFields) */
  public void testSplitAndConvertIntegers02() {
    boolean ok;
    int[] nums = new int[1];
    try {
      ok = true;
      nums = TermUtilities.splitAndConvertIntegers("Test:3.57", "3.57", 2);
    } catch (NumberFormatException e) {
      ok = false;
    } catch (TermEvaulatorException e) {
      ok = false;
    }

    is(ok, eq(true), "two ints is ok");
    is(nums[0], eq(3), "two ints is ok:first");
    is(nums[1], eq(57), "two ints is ok:second");
  }