source: trunk/org.modelica.mdt.test/src/org/modelica/mdt/test/TestModelicaElement.java @ 180

Last change on this file since 180 was 142, checked in by remar, 19 years ago
  • Test ModelicaElement?.isLegalIdentifierName by giving it lots of strange identifiers
File size: 752 bytes
Line 
1
2package org.modelica.mdt.test;
3
4import org.modelica.mdt.internal.core.ModelicaElement;
5
6import junit.framework.TestCase;
7
8public class TestModelicaElement extends TestCase
9{
10    public void testIsLegalIdentifierName()
11    {
12        String[] legalIdentifiers = {"_", "abc", "_abc", "_000", "p00_2",
13                                     "'abc'", "'\\\\'", "'!323%%\"'",
14                                     "'!\"#$%&\\'()*+,-./:;<=>?@[\\\\]^_`{|}~'"};
15        String[] illegalIdentifiers = {"012a", "åäö", "'\\'", "'''", "'\n'"};
16        for(String s: legalIdentifiers)
17        {
18            assertTrue("Legal identifier rejected ("+s+")",
19                    ModelicaElement.isLegalIdentifierName(s));
20        }
21        for(String s: illegalIdentifiers)
22        {
23            assertFalse("Illegal identifier accepted ("+s+")",
24                    ModelicaElement.isLegalIdentifierName(s));
25        }
26    }
27}
Note: See TracBrowser for help on using the repository browser.