001 /* 002 * Copyright 2010 - 2010 JEuclid, http://jeuclid.sf.net 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017 /* $Id: MiTest.java,v 92b6a7c39d7f 2010/08/11 20:23:17 max $ */ 018 019 package net.sourceforge.jeuclid.test.elements; 020 021 import net.sourceforge.jeuclid.DOMBuilder; 022 import net.sourceforge.jeuclid.MathMLParserSupport; 023 import net.sourceforge.jeuclid.elements.presentation.token.Mi; 024 025 import org.junit.Assert; 026 import org.junit.Test; 027 import org.w3c.dom.Document; 028 import org.w3c.dom.mathml.MathMLDocument; 029 import org.w3c.dom.mathml.MathMLMathElement; 030 031 /** 032 * Various tests for the {@link Mi} Element. 033 * 034 * @version $Revision: 92b6a7c39d7f $ 035 */ 036 public class MiTest { 037 038 /** Default constructor. */ 039 public MiTest() { 040 // nothing to do. 041 } 042 043 /** 044 * Tests behavior of non-printing characteres to be detected as 1-letter 045 * identifiers. 046 * 047 * @throws Exception 048 * if the test fails. 049 */ 050 @Test 051 public void testAutoItalic() throws Exception { 052 final Document doc = MathMLParserSupport 053 .parseString("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" 054 + "<math mode='display' " 055 + "xmlns='http://www.w3.org/1998/Math/MathML' " 056 + "xmlns:jattr='http://jeuclid.sf.net/ns/ext'>" 057 + "<mi>i</mi>" + "<mi>ij</mi>" + "<mi>î</mi>" 058 + "</math>"); 059 final MathMLDocument docElement = DOMBuilder.getInstance() 060 .createJeuclidDom(doc); 061 062 final MathMLMathElement mathElement = (MathMLMathElement) docElement 063 .getFirstChild(); 064 065 final Mi mi1 = (Mi) mathElement.getChildNodes().item(0); 066 Assert.assertEquals(mi1.getMathvariant(), "italic"); 067 068 final Mi mi2 = (Mi) mathElement.getChildNodes().item(1); 069 Assert.assertEquals(mi2.getMathvariant(), "normal"); 070 071 final Mi mi3 = (Mi) mathElement.getChildNodes().item(2); 072 Assert.assertEquals(mi3.getMathvariant(), "italic"); 073 } 074 }