Beispiel #1
0
  @Test
  public void testVMSimple() throws RecognitionException, IOException {

    VM vm =
        new VM(
            ""
                + "ENTRY  { "
                + "  address "
                + "  author "
                + "  title "
                + "  type "
                + "}  {}  { label }"
                + "INTEGERS { output.state before.all"
                + " mid.sentence after.sentence after.block }"
                + "FUNCTION {init.state.consts}{ #0 'before.all := "
                + " #1 'mid.sentence :=  #2 'after.sentence :=  #3 'after.block := } "
                + "STRINGS { s t } "
                + "READ");

    Vector<BibtexEntry> v = new Vector<>();
    v.add(t1BibtexEntry());

    vm.run(v);

    Assert.assertEquals(2, vm.getStrings().size());
    Assert.assertEquals(7, vm.getIntegers().size());
    Assert.assertEquals(1, vm.getEntries().size());
    Assert.assertEquals(5, vm.getEntries().get(0).getFields().size());
    Assert.assertEquals(38, vm.getFunctions().size());
  }
Beispiel #2
0
  @Test
  public void testSort() throws RecognitionException, IOException {

    VM vm =
        new VM(
            "ENTRY  { title }  { }  { label }"
                + "FUNCTION {presort} { cite$ 'sort.key$ := } ITERATE { presort } SORT");

    List<BibEntry> v = new ArrayList<>();
    v.add(TestVM.bibtexString2BibtexEntry("@article{a, author=\"AAA\"}"));
    v.add(TestVM.bibtexString2BibtexEntry("@article{b, author=\"BBB\"}"));
    v.add(TestVM.bibtexString2BibtexEntry("@article{d, author=\"DDD\"}"));
    v.add(TestVM.bibtexString2BibtexEntry("@article{c, author=\"CCC\"}"));
    vm.run(v);

    List<BstEntry> v2 = vm.getEntries();
    Assert.assertEquals("a", v2.get(0).getBibtexEntry().getCiteKey());
    Assert.assertEquals("b", v2.get(1).getBibtexEntry().getCiteKey());
    Assert.assertEquals("c", v2.get(2).getBibtexEntry().getCiteKey());
    Assert.assertEquals("d", v2.get(3).getBibtexEntry().getCiteKey());
  }