001 /* 002 * Copyright 2002 - 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: OperatorDictTest.java,v 92b6a7c39d7f 2010/08/11 20:23:17 max $ */ 018 019 package net.sourceforge.jeuclid.test; 020 021 import net.sourceforge.jeuclid.elements.support.operatordict.OperatorDictionary; 022 import net.sourceforge.jeuclid.elements.support.operatordict.OperatorDictionary2; 023 import net.sourceforge.jeuclid.elements.support.operatordict.OperatorDictionary3; 024 import net.sourceforge.jeuclid.elements.support.operatordict.UnknownAttributeException; 025 026 import org.junit.Assert; 027 import org.junit.Test; 028 029 /** 030 * Tests the OperatorDict class. 031 * 032 * @version $Revision: 92b6a7c39d7f $ 033 */ 034 public class OperatorDictTest { 035 /** 036 * Default Constructor. 037 */ 038 public OperatorDictTest() { 039 // Empty on purpose 040 } 041 042 /** 043 * Test various operators for correct default values. 044 * 045 * @throws Exception 046 * if the test fails. 047 */ 048 @Test 049 public void testAttrs2() throws Exception { 050 final OperatorDictionary opDict = OperatorDictionary2.getInstance(); 051 Assert.assertEquals(opDict.getDefaultAttributeValue("\u002d", "infix", 052 "lspace"), "mediummathspace"); 053 Assert.assertEquals(opDict.getDefaultAttributeValue("\u002d", "prefix", 054 "lspace"), "0em"); 055 Assert.assertEquals(opDict.getDefaultAttributeValue("\u002d", 056 "postfix", "lspace"), "verythinmathspace"); 057 Assert.assertEquals(opDict.getDefaultAttributeValue("\u0028", "prefix", 058 "lspace"), "0em"); 059 Assert.assertEquals(opDict.getDefaultAttributeValue("\u0028", "infix", 060 "lspace"), "0em"); 061 Assert.assertEquals(opDict.getDefaultAttributeValue("\u0028", 062 "postfix", "lspace"), "0em"); 063 Assert.assertEquals(opDict.getDefaultAttributeValue("\u2063", "infix", 064 "rspace"), "0em"); 065 Assert.assertEquals(opDict.getDefaultAttributeValue("\u2063", 066 "postfix", "rspace"), "0em"); 067 Assert.assertEquals(opDict.getDefaultAttributeValue("\u2063", "infix", 068 "fence"), "false"); 069 try { 070 opDict.getDefaultAttributeValue("\u2063", "infix", "foobar"); 071 Assert.fail("foobar should throw UnknownAttributeException!"); 072 } catch (final UnknownAttributeException uae) { 073 // Ignore 074 } 075 } 076 077 /** 078 * Test various operators for correct default values. 079 * 080 * @throws Exception 081 * if the test fails. 082 */ 083 @Test 084 public void testAttrs3() throws Exception { 085 final OperatorDictionary opDict = OperatorDictionary3.getInstance(); 086 Assert.assertEquals(opDict.getDefaultAttributeValue("\u002d", "infix", 087 "lspace"), "mediummathspace"); 088 Assert.assertEquals(opDict.getDefaultAttributeValue("\u002d", "prefix", 089 "lspace"), "mediummathspace"); 090 Assert.assertEquals(opDict.getDefaultAttributeValue("\u002d", 091 "postfix", "lspace"), "mediummathspace"); 092 Assert.assertEquals(opDict.getDefaultAttributeValue("\u0028", "prefix", 093 "lspace"), "0em"); 094 Assert.assertEquals(opDict.getDefaultAttributeValue("\u0028", "infix", 095 "lspace"), "0em"); 096 Assert.assertEquals(opDict.getDefaultAttributeValue("\u0028", 097 "postfix", "lspace"), "0em"); 098 Assert.assertEquals(opDict.getDefaultAttributeValue("\u2063", "infix", 099 "rspace"), "0em"); 100 Assert.assertEquals(opDict.getDefaultAttributeValue("\u2063", 101 "postfix", "rspace"), "0em"); 102 Assert.assertEquals(opDict.getDefaultAttributeValue("\u2063", "infix", 103 "fence"), "false"); 104 try { 105 opDict.getDefaultAttributeValue("\u2063", "infix", "foobar"); 106 Assert.fail("foobar should throw UnknownAttributeException!"); 107 } catch (final UnknownAttributeException uae) { 108 // Ignore 109 } 110 } 111 }