/*
 *  Draco Econometrics
 *  Copyright (C) 2006-2009 Approximatrix, LLC
 *  http://www.approximatrix.com
 *  
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.approximatrix.draco.editor.syntax.comments;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class RubyCommentEngineTest {

	private static final String TEST_COMMENTED_W_INDENTS = "    #Please comment\n   #This code\r\n  \n  #now";
	private static final String TEST_COMMENTED_NO_INDENTS = "#    Please comment\n#   This code\r\n  \n#  now";
	private static final String TEST_UNCOMMENTED = "    Please comment\n   This code\r\n  \n  now";
	
	private static final String TEST_COMMENTED_ONE_COMMENT = "#    Please comment\n   # This code\r\n  \n#  now";
	private static final String TEST_UNCOMMENTED_ONE_COMMENT = "    Please comment\n   # This code\r\n  \n  now";
	
	private RubyCommentEngine engine = null;
	
	@Before
	public void setUp() throws Exception {
		engine = new RubyCommentEngine();
	}

	@After
	public void tearDown() throws Exception {
		engine = null;
	}

	@Test
	public void testGetToken() {
		assertEquals("#",engine.getToken());
	}

	@Test
	public void testToggleComment() {
		assertEquals(TEST_UNCOMMENTED,engine.toggleComment(TEST_COMMENTED_W_INDENTS));
		assertEquals(TEST_UNCOMMENTED,engine.toggleComment(TEST_COMMENTED_NO_INDENTS));
		assertEquals("ruby code",engine.toggleComment("#ruby code"));
		
		assertEquals(TEST_COMMENTED_NO_INDENTS,engine.toggleComment(TEST_UNCOMMENTED));
		assertEquals(TEST_COMMENTED_ONE_COMMENT,engine.toggleComment(TEST_UNCOMMENTED_ONE_COMMENT));
		assertEquals("#ruby code",engine.toggleComment("ruby code"));
	}

}
