Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: fe62155696c0a51e152224be9beeb3b9e14d0aa8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*******************************************************************************
 * Copyright (c) 2011 IBM Corporation and others.
 * 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:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.ua.tests.help.webapp;

import org.eclipse.help.internal.webapp.data.PrintData;
import junit.framework.TestCase;

/**
 * Test for methods in PrintData
 */

public class PrintSubtopics extends TestCase {

	public void testHeadingInsertion() {
		String result = PrintData.injectHeading("<body> <p>Title</p>", "1");
		assertEquals("<body> <p><a id=\"section1\">1. </a>Title</p>", result);
	}
	
	public void testHeaderInsertionSkipsWhitespace() {
		checkHeadingInsertion("<body> <p>  \n\r</p><h1>", "Title</h1>");
	}

	public void testAccentedCharacter() {
		checkHeadingInsertion("<body> <p>", "\u00E1guila</p>");
	}

	public void testinvertedQuestionmark() {
		checkHeadingInsertion("<body> <p>", "\u00BFQu\u00E9 es Eclipse?</p>");
	}
	
	public void testSlash() {
		checkHeadingInsertion("<body> <p>", "/usr/bin</p>");
	}

	public void testChineseCharacter() {
		checkHeadingInsertion("<body> <p>", "\u623F\u5B50</p>");
	}
	
	public void testChineseExtbCharacter() {
		checkHeadingInsertion("<body> <p>", "\uD840\uDC06</p>");
	}
	
	/*
	 * Check that insertions occur between preInsert and postInsert 
	 */
	public void checkHeadingInsertion(String preInsert, String postInsert) {
		String result = PrintData.injectHeading(preInsert + postInsert, "1");
		assertEquals(preInsert + "<a id=\"section1\">1. </a>" + postInsert, result);
	}
	
}

Back to the top