EuroConverter.java revision 395
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/**
* @test
* @bug 4114080
* @summary Make sure the euro converters, which are derived from
* existing converters, only differ from their parents at the expected
* code point.
*/
/* Author: Alan Liu
* 7/14/98
*/
public class EuroConverter {
boolean pass = true;
try {
// Fill map with parent values
for (int j=-128; j<128; ++j) {
bytes[0] = (byte)j;
// NOTE: 0x25 doesn't round trip on the EBCDIC code pages,
// so we don't check that code point in the sanity check.
if (j != 0x0025) {
// This is a sanity check -- we aren't really testing the parent
// encoder here.
if (parentRoundTrip != j) {
pass = false;
" fails round-trip: " + j +
" -> " + parentRoundTrip);
}
}
}
// Modify map with new expected values. Each pair has code point, parent value, euro value.
// Terminated by null.
// This is a sanity check -- we aren't really testing the parent
// encoder here.
pass = false;
}
// Fill in new expected value
}
++i; // Skip over null at end of set
// Now verify the euro encoder
for (int j=-128; j<128; ++j) {
bytes[0] = (byte)j;
// NOTE: 0x15 doesn't round trip on the EBCDIC code pages,
// so we don't check that code point in the sanity check.
if (j != 0x0015) {
if (euroRoundTrip != j) {
pass = false;
" fails round-trip at " + j);
}
}
// Compare against the map
pass = false;
}
}
} catch (UnsupportedEncodingException e) {
pass = false;
++i; // Skip over null
}
}
if (!pass) {
throw new RuntimeException("Bug 4114080 - Euro encoder test failed");
}
}
// New converter, parent converter, [ code point that changed, parent code point value,
// euro code point value ], null
// Any number of changed code points may be specified, including zero.
"ISO8859_15_FDIS", "ISO8859_1",
"A4", "\u00A4", "\u20AC",
"A6", "\u00A6", "\u0160",
"A8", "\u00A8", "\u0161",
"B4", "\u00B4", "\u017D",
"B8", "\u00B8", "\u017E",
"BC", "\u00BC", "\u0152",
"BD", "\u00BD", "\u0153",
"BE", "\u00BE", "\u0178",
null,
// 923 is IBM's name for ISO 8859-15; make sure they're identical
};
}