summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-09-19 12:48:05 (EDT)
committerEike Stepper2007-09-19 12:48:05 (EDT)
commitb953dfcb5052ac9e9236f5c7d0782d5ee47b6767 (patch)
tree5746e01f1c27f7f1b37b05f8a3eb7e56629d365a
parentd989d7881a0708758ccb500b9b8ed0568157b1e3 (diff)
downloadcdo-b953dfcb5052ac9e9236f5c7d0782d5ee47b6767.zip
cdo-b953dfcb5052ac9e9236f5c7d0782d5ee47b6767.tar.gz
cdo-b953dfcb5052ac9e9236f5c7d0782d5ee47b6767.tar.bz2
[203866] Support UTF string
https://bugs.eclipse.org/bugs/show_bug.cgi?id=203866
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/UTFTest.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/UTFTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/UTFTest.java
new file mode 100644
index 0000000..142bfc9
--- /dev/null
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/UTFTest.java
@@ -0,0 +1,46 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.util.tests;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class UTFTest extends AbstractOMTest
+{
+ private static final int UNSIGNED_SHORT_MAX = (1 << 16) - 1;
+
+ private static final int MAX = UNSIGNED_SHORT_MAX / 10 + 1;
+
+ public void testUTF8() throws Exception
+ {
+ String part = "0123456789";
+ assertEquals(10, part.length());
+
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0; i < MAX; i++)
+ {
+ builder.append(part);
+ }
+
+ String str = builder.toString();
+ assertTrue(str.length() > UNSIGNED_SHORT_MAX);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(baos);
+ dos.writeUTF(str);
+
+ String received = baos.toString("UTF-8");
+ assertEquals(str, received);
+ }
+}