blob: 3e89a8299caf51e1a65577f8b1437b9925e04011 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2015 David Green.
* 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:
* David Green - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.internal.wikitext.commonmark;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class CommonMarkIdGenerationStrategyTest {
private final CommonMarkIdGenerationStrategy strategy = new CommonMarkIdGenerationStrategy();
@Test
public void simple() {
assertId("abc", "abc");
assertId("abc123", "abc123");
assertId("a_bc", "a_bc");
}
@Test
public void mixedCase() {
assertId("abc", "AbC");
}
@Test
public void whitespace() {
assertId("a-bc", "a bc");
assertId("a-bc", "a \tbc");
assertId("abc", " abc");
assertId("abc", "abc ");
}
@Test
public void allWhitespace() {
assertId("", " \t");
}
@Test
public void hyphenated() {
assertId("a-b", "a-b");
assertId("ab", "-ab");
assertId("ab", "ab-");
}
@Test
public void punctuationAndSpecialCharacters() {
assertId("a-b", "a.b");
assertId("a-b", "a....b");
assertId("a-b", "a,b");
assertId("a-b", "a;b");
assertId("a-b", "a*b");
assertId("a-b", "a&b");
assertId("ab", ".ab");
}
private void assertId(String expected, String headingText) {
assertEquals(expected, strategy.generateId(headingText));
}
}