package org.jdata.timeseries.test;

import org.jdata.timeseries.processing.Rule;
import org.jdata.timeseries.processing.Symbol;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class SequiturTest {
    @Before
    public void setup() {
    }

    @Test
    public void testSymbolEquals() {
        Symbol s1 = new Symbol(67);
        Symbol s2 = new Symbol(67);
        Symbol s3 = new Symbol(-1);
        Assert.assertEquals(s1, s2);
        Assert.assertNotEquals(s1, s3);
        Assert.assertNotEquals(s2, s3);
    }

    @Test
    public void testRuleAppend() {
        Rule r = new Rule(-1);
        Assert.assertEquals("toString failed","",r.toString());
        r.append(new Symbol(1));
        Assert.assertEquals("first append failed","1",r.toString());
        r.append(new Symbol(2));
        Assert.assertEquals("second append failed","1,2",r.toString());
        r.append(new Symbol(3));
        Assert.assertEquals("final append failed","1,2,3",r.toString());
    }

    @After
    public void cleanup() {
    }
}

@@ -1027,24 +1027,2241 @@
 ());%0A    %7D%0A%0A
+    @Test%0A    public void testRuleReferenceCounting() %7B%0A        Rule r = new Rule(-1);%0A        Assert.assertEquals(%22rule initialization failed%22,0,r.getRefCount());%0A        r.addReference();%0A        Assert.assertEquals(%22first increment failed%22,1,r.getRefCount());%0A        r.addReference();%0A        Assert.assertEquals(%22second increment failed%22,2,r.getRefCount());%0A        r.removeReference();%0A        Assert.assertEquals(%22first decrement failed%22,1,r.getRefCount());%0A        r.removeReference();%0A        Assert.assertEquals(%22second decrement failed%22,0,r.getRefCount());%0A    %7D%0A%0A    @Test%0A    public void testRuleReduce() %7B%0A        Symbol a = new Symbol(1);%0A        Symbol b = new Symbol(2);%0A        Symbol c = new Symbol(3);%0A        Rule r1 = new Rule(-1);%0A        r1.append(a);%0A        r1.append(b);%0A        r1.append(c);%0A        Assert.assertEquals(%22append failed%22,%221,2,3%22,r1.toString());%0A        Rule r2 = new Rule(-2);%0A        r1.reduce(b,r2);%0A        Symbol A = a.getNext();%0A        Assert.assertEquals(%22symbol created with incorrect value%22,-2,A.getValue());%0A        Assert.assertEquals(%22first reduce failed%22,%221,-2%22,r1.toString());%0A        Rule r3 = new Rule(-3);%0A        r1.reduce(a,r3);%0A        Assert.assertEquals(%22second reduce failed%22,%22-3%22,r1.toString());%0A    %7D%0A%0A    @Test%0A    public void testRuleExpand() %7B%0A        Symbol A = new Symbol(-2);%0A        Symbol B = new Symbol(-3);%0A        Symbol C = new Symbol(-4);%0A        Symbol a1 = new Symbol(1);%0A        Symbol a2 = new Symbol(1);%0A        Symbol b2 = new Symbol(2);%0A        Symbol c2 = new Symbol(3);%0A        Rule r1 = new Rule(-1);%0A        r1.append(A);%0A        Assert.assertEquals(%22append failed%22,%22-2%22,r1.toString());%0A        Rule r2 = new Rule(-2);%0A        r2.append(B);%0A        r1.expand(A, r2);%0A        Assert.assertEquals(%22first expand failed%22,%22-3%22,r1.toString());%0A        Rule r3 = new Rule(-3);%0A        r3.append(a1);%0A        r3.append(C);%0A        r1.expand(B, r3);%0A        Assert.assertEquals(%22second expand failed%22,%221,-4%22,r1.toString());%0A        Rule r4 = new Rule(-4);%0A        r4.append(a2);%0A        r4.append(b2);%0A        r4.append(c2);%0A        r1.expand(C, r4);%0A        Assert.assertEquals(%22third expand failed%22,%221,1,2,3%22,r1.toString());%0A    %7D%0A%0A
     @After%0A 

Add more tests