/**
 *  Copyright (c) 2013-2014 Angelo ZERR.
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License v1.0
 *  which accompanies this distribution, and is available at
 *  http://www.eclipse.org/legal/epl-v10.html
 *
 *  Contributors:
 *  Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
 */
package org.eclipse.angularjs.core.utils;

import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
import org.junit.Assert;
import org.junit.Test;

public class AngularRegionUtilsTest {

	@Test
	public void offsetBeforeStartEL() {
		AngularELRegion region = AngularRegionUtils.getAngularELRegion(
				DOMRegionContext.XML_CONTENT, "{{todo.text + to}}", 588, 588,
				"{{", "}}");
		Assert.assertNull(region);
	}

	@Test
	public void offsetAfterStartEL() {
		AngularELRegion region = AngularRegionUtils.getAngularELRegion(
				DOMRegionContext.XML_CONTENT, "{{todo.text + to}}", 588, 590,
				"{{", "}}");
		Assert.assertNotNull(region);
		Assert.assertEquals("todo.text + to", region.getExpression());
		Assert.assertEquals(0, region.getExpressionOffset());
	}

	@Test
	public void offsetBeforeEndEL() {
		AngularELRegion region = AngularRegionUtils.getAngularELRegion(
				DOMRegionContext.XML_CONTENT, "{{todo.text + to}}", 588, 603,
				"{{", "}}");
		Assert.assertNull(region);
	}

	@Test
	public void offsetAfterEndEL() {
		AngularELRegion region = AngularRegionUtils.getAngularELRegion(
				DOMRegionContext.XML_CONTENT, "{{todo.text + to}}", 588, 604,
				"{{", "}}");
		Assert.assertNotNull(region);
		Assert.assertEquals("todo.text + to", region.getExpression());
		Assert.assertEquals(14, region.getExpressionOffset());
	}

	@Test
	public void test2() {
		AngularELRegion region = AngularRegionUtils.getAngularELRegion(
				DOMRegionContext.XML_CONTENT, "{{", 588, 604, "{{", "}}");
		Assert.assertNull(region);
	}
}

@@ -1399,32 +1399,35 @@
 %09%09Assert.assertN
+otN
 ull(region);%0D%0A%09%7D
@@ -1416,32 +1416,156 @@
 tNull(region);%0D%0A
+%09%09Assert.assertEquals(%22todo.text + to%22, region.getExpression());%0D%0A%09%09Assert.assertEquals(13, region.getExpressionOffset());%0D%0A
 %09%7D%0D%0A%0D%0A%09@Test%0D%0A%09p

Fix build