001: /*
002: * Java HTML Tidy - JTidy
003: * HTML parser and pretty printer
004: *
005: * Copyright (c) 1998-2000 World Wide Web Consortium (Massachusetts
006: * Institute of Technology, Institut National de Recherche en
007: * Informatique et en Automatique, Keio University). All Rights
008: * Reserved.
009: *
010: * Contributing Author(s):
011: *
012: * Dave Raggett <dsr@w3.org>
013: * Andy Quick <ac.quick@sympatico.ca> (translation to Java)
014: * Gary L Peskin <garyp@firstech.com> (Java development)
015: * Sami Lempinen <sami@lempinen.net> (release management)
016: * Fabrizio Giustina <fgiust at users.sourceforge.net>
017: *
018: * The contributing author(s) would like to thank all those who
019: * helped with testing, bug fixes, and patience. This wouldn't
020: * have been possible without all of you.
021: *
022: * COPYRIGHT NOTICE:
023: *
024: * This software and documentation is provided "as is," and
025: * the copyright holders and contributing author(s) make no
026: * representations or warranties, express or implied, including
027: * but not limited to, warranties of merchantability or fitness
028: * for any particular purpose or that the use of the software or
029: * documentation will not infringe any third party patents,
030: * copyrights, trademarks or other rights.
031: *
032: * The copyright holders and contributing author(s) will not be
033: * liable for any direct, indirect, special or consequential damages
034: * arising out of any use of the software or documentation, even if
035: * advised of the possibility of such damage.
036: *
037: * Permission is hereby granted to use, copy, modify, and distribute
038: * this source code, or portions hereof, documentation and executables,
039: * for any purpose, without fee, subject to the following restrictions:
040: *
041: * 1. The origin of this source code must not be misrepresented.
042: * 2. Altered versions must be plainly marked as such and must
043: * not be misrepresented as being the original source.
044: * 3. This Copyright notice may not be removed or altered from any
045: * source or altered source distribution.
046: *
047: * The copyright holders and contributing author(s) specifically
048: * permit, without fee, and encourage the use of this source code
049: * as a component for supporting the Hypertext Markup Language in
050: * commercial products. If you use this source code in a product,
051: * acknowledgment is not required but would be appreciated.
052: *
053: */
054: package org.w3c.tidy;
055:
056: import junit.framework.TestCase;
057:
058: /**
059: * Test cases for TidyUtils.
060: * @author Fabrizio Giustina
061: * @version $Revision $ ($Author $)
062: */
063: public class TidyUtilsTest extends TestCase {
064:
065: /**
066: * instantiates a new test.
067: * @param name test name
068: */
069: public TidyUtilsTest(String name) {
070: super (name);
071: }
072:
073: /**
074: * Tests isInValuesIgnoreCase with a valid string.
075: */
076: public void testIsInValuesIgnoreCaseSuccessfull() {
077: String[] validValues = new String[] { "first", "Second",
078: "THIRD" };
079: String stringToCheck = "second";
080: assertTrue(TidyUtils.isInValuesIgnoreCase(validValues,
081: stringToCheck));
082: }
083:
084: /**
085: * Tests isInValuesIgnoreCase with an invalid string.
086: */
087: public void testIsInValuesIgnoreCaseFail() {
088: String[] validValues = new String[] { "first", "Second",
089: "THIRD" };
090: String stringToCheck = "secon";
091: assertFalse(TidyUtils.isInValuesIgnoreCase(validValues,
092: stringToCheck));
093: }
094:
095: /**
096: * Test for isCharEncodingSupported().
097: */
098: public void testIsCharEncodingSupported() {
099: assertTrue(TidyUtils.isCharEncodingSupported("utf8"));
100: assertTrue(TidyUtils.isCharEncodingSupported("UTF-8"));
101: assertTrue(TidyUtils.isCharEncodingSupported("US-ASCII"));
102: assertTrue(TidyUtils.isCharEncodingSupported("ASCII"));
103: assertTrue(TidyUtils.isCharEncodingSupported("LATIN1"));
104: assertTrue(TidyUtils.isCharEncodingSupported("ISO-8859-1"));
105: assertTrue(TidyUtils.isCharEncodingSupported("WINDOWS-1252"));
106: assertTrue(TidyUtils.isCharEncodingSupported("ISO2022"));
107: assertTrue(TidyUtils.isCharEncodingSupported("ISO-2022-JP"));
108: assertTrue(TidyUtils.isCharEncodingSupported("BIG5"));
109: assertTrue(TidyUtils.isCharEncodingSupported("UTF16"));
110: assertTrue(TidyUtils.isCharEncodingSupported("UTF16BE"));
111: assertTrue(TidyUtils.isCharEncodingSupported("UTF16LE"));
112: assertTrue(TidyUtils.isCharEncodingSupported("UTF-16"));
113: assertTrue(TidyUtils.isCharEncodingSupported("UTF-16BE"));
114: assertTrue(TidyUtils.isCharEncodingSupported("UTF-16LE"));
115: assertTrue(TidyUtils.isCharEncodingSupported("CP858"));
116: assertTrue(TidyUtils.isCharEncodingSupported("ibm858"));
117: assertTrue(TidyUtils.isCharEncodingSupported("Macintosh Roman"));
118: assertTrue(TidyUtils.isCharEncodingSupported("WiN1252"));
119: assertTrue(TidyUtils.isCharEncodingSupported("SHIFTJIS"));
120: }
121:
122: }
|