/*
 * ServerManagerTest.java
 * JUnit 4.x based test
 *
 */

package com.dmdirc.parser;

import com.dmdirc.parser.callbacks.CallbackNotFoundException;
import com.dmdirc.parser.callbacks.interfaces.IAwayState;
import junit.framework.TestCase;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Chris
 */
public class IRCParserTest extends TestCase {
    
    public IRCParserTest() {
    }
    
    @Test
    public void testIssue042() {
        boolean res = false;
        
        try {
            final IRCParser myParser = new IRCParser();
            myParser.getCallbackManager().addCallback("non-existant",new IAwayState() {
                public void onAwayState(IRCParser tParser, boolean currentState, String reason) {
                    throw new UnsupportedOperationException("Not supported yet.");
                }
            });
        } catch (CallbackNotFoundException ex) {
            res = true;
        }
        
        assertTrue("addCallback() should throw exception for non-existant callbacks", res);
    }
    
}

@@ -1061,10 +1061,872 @@
  %7D%0A    %0A
+    @Test%0A    public void testTokeniser() %7B%0A        final IRCParser myParser = new IRCParser();%0A        %0A        final String line1 = %22a b c d e%22;%0A        final String line2 = %22a b c :d e%22;%0A        final String line3 = %22:a b:c :d e%22;%0A        %0A        final String%5B%5D res1 = myParser.tokeniseLine(line1);%0A        final String%5B%5D res2 = myParser.tokeniseLine(line2);%0A        final String%5B%5D res3 = myParser.tokeniseLine(line3);%0A        %0A        arrayEquals(res1, new String%5B%5D%7B%22a%22, %22b%22, %22c%22, %22d%22, %22e%22%7D);%0A        arrayEquals(res2, new String%5B%5D%7B%22a%22, %22b%22, %22c%22, %22d e%22%7D);%0A        arrayEquals(res3, new String%5B%5D%7B%22:a%22, %22b:c%22, %22d e%22%7D);%0A    %7D%0A    %0A    private void arrayEquals(final String%5B%5D a1, final String%5B%5D a2) %7B%0A        assertEquals(a1.length, a2.length);%0A        %0A        for (int i = 0; i %3C a1.length; i++) %7B%0A            assertEquals(a1%5Bi%5D, a2%5Bi%5D);%0A        %7D%0A    %7D%0A    %0A
 %7D%0A

Add unit test for the parser's tokeniser