summaryrefslogtreecommitdiffstats
path: root/tests/CoreTests
diff options
context:
space:
mode:
authorJesse Wilson <jessewilson@google.com>2010-12-14 15:19:48 -0800
committerJesse Wilson <jessewilson@google.com>2010-12-14 15:19:48 -0800
commit29ac247d21a15797bc4b3cc56d25f2fc81406538 (patch)
tree75483666b65e2c0cf4f064d85aeef5105947317f /tests/CoreTests
parentf5a1a0b63b9a232019b41f9c4d8d86b63fface47 (diff)
downloadframeworks_base-29ac247d21a15797bc4b3cc56d25f2fc81406538.zip
frameworks_base-29ac247d21a15797bc4b3cc56d25f2fc81406538.tar.gz
frameworks_base-29ac247d21a15797bc4b3cc56d25f2fc81406538.tar.bz2
Move 41 tests to libcore, closer to the tested code. (2nd half)
Change-Id: I18650718a7e49c84a0cc3c5b0c1172c71d2d54cf http://b/3073226
Diffstat (limited to 'tests/CoreTests')
-rw-r--r--tests/CoreTests/android/core/ArrayListTest.java94
-rw-r--r--tests/CoreTests/android/core/BooleanTest.java46
-rw-r--r--tests/CoreTests/android/core/BufferedInputStreamTest.java81
-rw-r--r--tests/CoreTests/android/core/BufferedOutputStreamTest.java50
-rw-r--r--tests/CoreTests/android/core/BufferedReaderTest.java66
-rw-r--r--tests/CoreTests/android/core/BufferedWriterTest.java53
-rw-r--r--tests/CoreTests/android/core/ByteArrayInputStreamTest.java43
-rw-r--r--tests/CoreTests/android/core/ByteArrayOutputStreamTest.java43
-rw-r--r--tests/CoreTests/android/core/CharArrayReaderTest.java42
-rw-r--r--tests/CoreTests/android/core/ChecksumTest.java97
-rw-r--r--tests/CoreTests/android/core/DataInputStreamTest.java107
-rw-r--r--tests/CoreTests/android/core/DataOutputStreamTest.java51
-rw-r--r--tests/CoreTests/android/core/DatagramTest.java192
-rw-r--r--tests/CoreTests/android/core/DeflateTest.java199
-rw-r--r--tests/CoreTests/android/core/EnumTest.java64
-rw-r--r--tests/CoreTests/android/core/FileTest.java38
-rw-r--r--tests/CoreTests/android/core/FloatDoubleTest.java152
-rw-r--r--tests/CoreTests/android/core/GZIPStreamTest.java114
-rw-r--r--tests/CoreTests/android/core/IOUtil.java193
-rw-r--r--tests/CoreTests/android/core/InputStreamReaderTest.java114
-rw-r--r--tests/CoreTests/android/core/InstanceofTest.java141
-rw-r--r--tests/CoreTests/android/core/LineNumberReaderTest.java79
-rw-r--r--tests/CoreTests/android/core/LocaleTest.java243
-rw-r--r--tests/CoreTests/android/core/MathTest.java831
-rw-r--r--tests/CoreTests/android/core/MonitorTest.java469
-rw-r--r--tests/CoreTests/android/core/NIOTest.java707
-rw-r--r--tests/CoreTests/android/core/OutputStreamWriterTest.java48
-rw-r--r--tests/CoreTests/android/core/ParseIntTest.java110
-rw-r--r--tests/CoreTests/android/core/PipedStreamTest.java300
-rw-r--r--tests/CoreTests/android/core/PrintWriterTest.java75
-rw-r--r--tests/CoreTests/android/core/PushbackInputStreamTest.java57
-rw-r--r--tests/CoreTests/android/core/PushbackReaderTest.java57
-rw-r--r--tests/CoreTests/android/core/ReflectArrayTest.java136
-rw-r--r--tests/CoreTests/android/core/SerializationTest.java47
-rw-r--r--tests/CoreTests/android/core/StreamTokenizerTest.java96
-rw-r--r--tests/CoreTests/android/core/StrictMathTest.java855
-rw-r--r--tests/CoreTests/android/core/StringReaderTest.java40
-rw-r--r--tests/CoreTests/android/core/StringWriterTest.java42
-rw-r--r--tests/CoreTests/android/core/TreeMapTest.java105
-rw-r--r--tests/CoreTests/android/core/URITest.java55
-rw-r--r--tests/CoreTests/android/core/ZipFileTest.java200
-rw-r--r--tests/CoreTests/android/core/ZipStreamTest.java171
42 files changed, 0 insertions, 6703 deletions
diff --git a/tests/CoreTests/android/core/ArrayListTest.java b/tests/CoreTests/android/core/ArrayListTest.java
deleted file mode 100644
index 763bf99..0000000
--- a/tests/CoreTests/android/core/ArrayListTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.util.ArrayList;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * This test case tests several often used functionality of ArrayLists.
- */
-public class ArrayListTest extends TestCase {
-
- @SuppressWarnings("unchecked")
- @SmallTest
- public void testArrayList() throws Exception {
- ArrayList array = new ArrayList();
- assertEquals(0, array.size());
- assertTrue(array.isEmpty());
-
- array.add(new Integer(0));
- array.add(0, new Integer(1));
- array.add(1, new Integer(2));
- array.add(new Integer(3));
- array.add(new Integer(1));
-
- assertEquals(5, array.size());
- assertFalse(array.isEmpty());
-
- assertEquals(1, ((Integer) array.get(0)).intValue());
- assertEquals(2, ((Integer) array.get(1)).intValue());
- assertEquals(0, ((Integer) array.get(2)).intValue());
- assertEquals(3, ((Integer) array.get(3)).intValue());
- assertEquals(1, ((Integer) array.get(4)).intValue());
-
- assertFalse(array.contains(null));
- assertTrue(array.contains(new Integer(2)));
- assertEquals(0, array.indexOf(new Integer(1)));
- assertEquals(4, array.lastIndexOf(new Integer(1)));
- assertTrue(array.indexOf(new Integer(5)) < 0);
- assertTrue(array.lastIndexOf(new Integer(5)) < 0);
-
-
- array.remove(1);
- array.remove(1);
-
- assertEquals(3, array.size());
- assertFalse(array.isEmpty());
- assertEquals(1, ((Integer) array.get(0)).intValue());
- assertEquals(3, ((Integer) array.get(1)).intValue());
- assertEquals(1, ((Integer) array.get(2)).intValue());
-
- assertFalse(array.contains(null));
- assertFalse(array.contains(new Integer(2)));
- assertEquals(0, array.indexOf(new Integer(1)));
- assertEquals(2, array.lastIndexOf(new Integer(1)));
- assertTrue(array.indexOf(new Integer(5)) < 0);
- assertTrue(array.lastIndexOf(new Integer(5)) < 0);
-
- array.clear();
-
- assertEquals(0, array.size());
- assertTrue(array.isEmpty());
- assertTrue(array.indexOf(new Integer(5)) < 0);
- assertTrue(array.lastIndexOf(new Integer(5)) < 0);
-
- ArrayList al = new ArrayList();
-
- assertFalse(al.remove(null));
- assertFalse(al.remove("string"));
-
- al.add("string");
- al.add(null);
-
- assertTrue(al.remove(null));
- assertTrue(al.remove("string"));
- }
-}
-
diff --git a/tests/CoreTests/android/core/BooleanTest.java b/tests/CoreTests/android/core/BooleanTest.java
deleted file mode 100644
index 211947e..0000000
--- a/tests/CoreTests/android/core/BooleanTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Tests some basic functionality of Booleans.
- */
-public class BooleanTest extends TestCase {
-
- @SmallTest
- public void testBoolean() throws Exception {
- Boolean a = new Boolean(true);
- Boolean b = new Boolean("True");
- Boolean c = new Boolean(false);
- Boolean d = new Boolean("Yes");
-
- assertEquals(a, b);
- assertEquals(c, d);
- assertTrue(a.booleanValue());
- assertFalse(c.booleanValue());
- assertEquals("true", a.toString());
- assertEquals("false", c.toString());
- assertEquals(Boolean.TRUE, a);
- assertEquals(Boolean.FALSE, c);
- assertSame(Boolean.valueOf(true), Boolean.TRUE);
- assertSame(Boolean.valueOf(false), Boolean.FALSE);
- }
-}
-
diff --git a/tests/CoreTests/android/core/BufferedInputStreamTest.java b/tests/CoreTests/android/core/BufferedInputStreamTest.java
deleted file mode 100644
index 1ad95a1..0000000
--- a/tests/CoreTests/android/core/BufferedInputStreamTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Tests to verify that simple functionality works for BufferedInputStreams.
- */
-public class BufferedInputStreamTest extends TestCase {
-
- @SmallTest
- public void testBufferedInputStream() throws Exception {
- String str = "AbCdEfGhIjKlM\nOpQrStUvWxYz";
- ByteArrayInputStream aa = new ByteArrayInputStream(str.getBytes());
- ByteArrayInputStream ba = new ByteArrayInputStream(str.getBytes());
- ByteArrayInputStream ca = new ByteArrayInputStream(str.getBytes());
- ByteArrayInputStream da = new ByteArrayInputStream(str.getBytes());
- ByteArrayInputStream ea = new ByteArrayInputStream(str.getBytes());
-
- BufferedInputStream a = new BufferedInputStream(aa, 6);
- try {
- assertEquals(str, IOUtil.read(a));
- } finally {
- a.close();
- }
-
- BufferedInputStream b = new BufferedInputStream(ba, 7);
- try {
- assertEquals("AbCdEfGhIj", IOUtil.read(b, 10));
- } finally {
- b.close();
- }
-
- BufferedInputStream c = new BufferedInputStream(ca, 9);
- try {
- assertEquals("bdfhjl\nprtvxz", IOUtil.skipRead(c));
- } finally {
- c.close();
- }
-
- BufferedInputStream d = new BufferedInputStream(da, 9);
- try {
- assertEquals('A', d.read());
- d.mark(15);
- assertEquals('b', d.read());
- assertEquals('C', d.read());
- d.reset();
- assertEquals('b', d.read());
- } finally {
- d.close();
- }
-
- BufferedInputStream e = new BufferedInputStream(ea, 11);
- try {
- // test that we can ask for more than is present, and that we'll get
- // back only what is there.
- assertEquals(str, IOUtil.read(e, 10000));
- } finally {
- e.close();
- }
- }
-}
diff --git a/tests/CoreTests/android/core/BufferedOutputStreamTest.java b/tests/CoreTests/android/core/BufferedOutputStreamTest.java
deleted file mode 100644
index cd8ec08..0000000
--- a/tests/CoreTests/android/core/BufferedOutputStreamTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayOutputStream;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Tests to verify that simple functionality works for BufferedOutputStreams.
- */
-public class BufferedOutputStreamTest extends TestCase {
-
- @SmallTest
- public void testBufferedOutputStream() throws Exception {
- String str = "AbCdEfGhIjKlMnOpQrStUvWxYz";
- ByteArrayOutputStream aa = new ByteArrayOutputStream();
- BufferedOutputStream a = new BufferedOutputStream(aa, 15);
- try {
- a.write(str.getBytes(), 0, 26);
- a.write('A');
-
- assertEquals(26, aa.size());
- assertEquals(aa.toString(), str);
-
- a.flush();
-
- assertEquals(27, aa.size());
- assertEquals("AbCdEfGhIjKlMnOpQrStUvWxYzA", aa.toString());
- } finally {
- a.close();
- }
- }
-}
diff --git a/tests/CoreTests/android/core/BufferedReaderTest.java b/tests/CoreTests/android/core/BufferedReaderTest.java
deleted file mode 100644
index a94ca02..0000000
--- a/tests/CoreTests/android/core/BufferedReaderTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.BufferedReader;
-import java.io.StringReader;
-import android.test.suitebuilder.annotation.MediumTest;
-
-/**
- * Tests to verify that simple functionality works for BufferedReaders.
- */
-public class BufferedReaderTest extends TestCase {
-
- @MediumTest
- public void testBufferedReader() throws Exception {
- String str = "AbCdEfGhIjKlMnOpQrStUvWxYz";
- StringReader aa = new StringReader(str);
- StringReader ba = new StringReader(str);
- StringReader ca = new StringReader(str);
- StringReader da = new StringReader(str);
-
- BufferedReader a = new BufferedReader(aa, 5);
- try {
- assertEquals(str, IOUtil.read(a));
- } finally {
- a.close();
- }
-
- BufferedReader b = new BufferedReader(ba, 15);
- try {
- assertEquals("AbCdEfGhIj", IOUtil.read(b, 10));
- } finally {
- b.close();
- }
-
- BufferedReader c = new BufferedReader(ca);
- try {
- assertEquals("bdfhjlnprtvxz", IOUtil.skipRead(c));
- } finally {
- c.close();
- }
-
- BufferedReader d = new BufferedReader(da);
- try {
- assertEquals("AbCdEfGdEfGhIjKlMnOpQrStUvWxYz", IOUtil.markRead(d, 3, 4));
- } finally {
- d.close();
- }
- }
-}
diff --git a/tests/CoreTests/android/core/BufferedWriterTest.java b/tests/CoreTests/android/core/BufferedWriterTest.java
deleted file mode 100644
index 12dfcef..0000000
--- a/tests/CoreTests/android/core/BufferedWriterTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.BufferedWriter;
-import java.io.StringWriter;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Some basic tests for BufferedWriter.
- */
-public class BufferedWriterTest extends TestCase {
-
- @SmallTest
- public void testBufferedWriter() throws Exception {
- String str = "AbCdEfGhIjKlMnOpQrStUvWxYz";
- StringWriter aa = new StringWriter();
-
- BufferedWriter a = new BufferedWriter(aa, 20);
- try {
- a.write(str.toCharArray(), 0, 26);
- a.write('X');
- a.flush();
- assertEquals("AbCdEfGhIjKlMnOpQrStUvWxYzX", aa.toString());
-
- a.write("alphabravodelta", 5, 5);
- a.flush();
- assertEquals("AbCdEfGhIjKlMnOpQrStUvWxYzXbravo", aa.toString());
- a.newLine();
- a.write("I'm on a new line.");
- a.flush();
- assertEquals("AbCdEfGhIjKlMnOpQrStUvWxYzXbravo\nI\'m on a new line.", aa.toString());
- } finally {
- a.close();
- }
- }
-}
diff --git a/tests/CoreTests/android/core/ByteArrayInputStreamTest.java b/tests/CoreTests/android/core/ByteArrayInputStreamTest.java
deleted file mode 100644
index d964102..0000000
--- a/tests/CoreTests/android/core/ByteArrayInputStreamTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.ByteArrayInputStream;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Tests to verify that simple functionality works for ByteArrayInputStreams.
- */
-public class ByteArrayInputStreamTest extends TestCase {
-
- @SmallTest
- public void testByteArrayInputStream() throws Exception {
- String str = "AbCdEfGhIjKlMnOpQrStUvWxYz";
-
- ByteArrayInputStream a = new ByteArrayInputStream(str.getBytes());
- ByteArrayInputStream b = new ByteArrayInputStream(str.getBytes());
- ByteArrayInputStream c = new ByteArrayInputStream(str.getBytes());
- ByteArrayInputStream d = new ByteArrayInputStream(str.getBytes());
-
- assertEquals(str, IOUtil.read(a));
- assertEquals("AbCdEfGhIj", IOUtil.read(b, 10));
- assertEquals("bdfhjlnprtvxz", IOUtil.skipRead(c));
- assertEquals("AbCdEfGdEfGhIjKlMnOpQrStUvWxYz", IOUtil.markRead(d, 3, 4));
- }
-}
diff --git a/tests/CoreTests/android/core/ByteArrayOutputStreamTest.java b/tests/CoreTests/android/core/ByteArrayOutputStreamTest.java
deleted file mode 100644
index e605214..0000000
--- a/tests/CoreTests/android/core/ByteArrayOutputStreamTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.ByteArrayOutputStream;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * A basic test for ByteArrayOutputStraem.
- */
-public class ByteArrayOutputStreamTest extends TestCase {
-
- @SmallTest
- public void testByteArrayOutputStream() throws Exception {
- String str = "AbCdEfGhIjKlMnOpQrStUvWxYz";
- ByteArrayOutputStream a = new ByteArrayOutputStream();
- ByteArrayOutputStream b = new ByteArrayOutputStream(10);
-
- a.write(str.getBytes(), 0, 26);
- a.write('X');
- a.writeTo(b);
-
- assertEquals(27, a.size());
- assertEquals("AbCdEfGhIjKlMnOpQrStUvWxYzX", a.toString());
- assertEquals("AbCdEfGhIjKlMnOpQrStUvWxYzX", b.toString());
- }
-}
diff --git a/tests/CoreTests/android/core/CharArrayReaderTest.java b/tests/CoreTests/android/core/CharArrayReaderTest.java
deleted file mode 100644
index 50a217a..0000000
--- a/tests/CoreTests/android/core/CharArrayReaderTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.CharArrayReader;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Basic tests for CharArrayReader.
- */
-public class CharArrayReaderTest extends TestCase {
-
- @SmallTest
- public void testCharArrayReader() throws Exception {
- String str = "AbCdEfGhIjKlMnOpQrStUvWxYz";
- CharArrayReader a = new CharArrayReader(str.toCharArray());
- CharArrayReader b = new CharArrayReader(str.toCharArray());
- CharArrayReader c = new CharArrayReader(str.toCharArray());
- CharArrayReader d = new CharArrayReader(str.toCharArray());
-
- assertEquals(str, IOUtil.read(a));
- assertEquals("AbCdEfGhIj", IOUtil.read(b, 10));
- assertEquals("bdfhjlnprtvxz", IOUtil.skipRead(c));
- assertEquals("AbCdEfGdEfGhIjKlMnOpQrStUvWxYz", IOUtil.markRead(d, 3, 4));
- }
-}
diff --git a/tests/CoreTests/android/core/ChecksumTest.java b/tests/CoreTests/android/core/ChecksumTest.java
deleted file mode 100644
index 24fb739..0000000
--- a/tests/CoreTests/android/core/ChecksumTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.util.zip.Adler32;
-import java.util.zip.CRC32;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * tests for CRC32 and Adler32 checksum algorithms.
- */
-public class ChecksumTest extends TestCase {
-
- @SmallTest
- public void testChecksum() throws Exception {
- /*
- * Values computed experimentally, using C interfaces.
- */
- adler32Test(mTestString, 0x9de210dbL);
- cRC32Test(mTestString, 0x939f04afL);
-
- // Test for issue 1016037
- wrongChecksumWithAdler32Test();
- }
-
- private void adler32Test(byte[] values, long expected) {
- Adler32 adler = new Adler32();
-
- // try it all at once
- adler.update(values);
- assertEquals(adler.getValue(), expected);
-
- // try resetting and computing one byte at a time
- adler.reset();
- for (int i = 0; i < values.length; i++) {
- adler.update(values[i]);
- }
- assertEquals(adler.getValue(), expected);
- }
-
- private void cRC32Test(byte[] values, long expected) {
- CRC32 crc = new CRC32();
-
- // try it all at once
- crc.update(values);
- assertEquals(crc.getValue(), expected);
-
- // try resetting and computing one byte at a time
- crc.reset();
- for (int i = 0; i < values.length; i++) {
- crc.update(values[i]);
- }
- assertEquals(crc.getValue(), expected);
- }
-
- // "The quick brown fox jumped over the lazy dogs\n"
- private static byte[] mTestString = {
- 0x54, 0x68, 0x65, 0x20, 0x71, 0x75, 0x69, 0x63,
- 0x6b, 0x20, 0x62, 0x72, 0x6f, 0x77, 0x6e, 0x20,
- 0x66, 0x6f, 0x78, 0x20, 0x6a, 0x75, 0x6d, 0x70,
- 0x65, 0x64, 0x20, 0x6f, 0x76, 0x65, 0x72, 0x20,
- 0x74, 0x68, 0x65, 0x20, 0x6c, 0x61, 0x7a, 0x79,
- 0x20, 0x64, 0x6f, 0x67, 0x73, 0x2e, 0x0a
- };
-
-
- // Test for issue 1016037
- private void wrongChecksumWithAdler32Test() {
- byte[] bytes = {1, 0, 5, 0, 15, 0, 1, 11, 0, 1};
- Adler32 adler = new Adler32();
- adler.update(bytes);
- long arrayChecksum = adler.getValue();
- adler.reset();
- for (int i = 0; i < bytes.length; i++) {
- adler.update(bytes[i]);
- }
- assertEquals("Checksums not equal: expected: " + arrayChecksum +
- " actual: " + adler.getValue(), arrayChecksum, adler.getValue());
- }
-}
-
diff --git a/tests/CoreTests/android/core/DataInputStreamTest.java b/tests/CoreTests/android/core/DataInputStreamTest.java
deleted file mode 100644
index ca801d6..0000000
--- a/tests/CoreTests/android/core/DataInputStreamTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import android.test.suitebuilder.annotation.SmallTest;
-
-public class DataInputStreamTest extends TestCase {
-
- @SmallTest
- public void testDataInputStream() throws Exception {
- String str = "AbCdEfGhIjKlM\nOpQ\rStUvWxYz";
- ByteArrayInputStream aa = new ByteArrayInputStream(str.getBytes());
- ByteArrayInputStream ba = new ByteArrayInputStream(str.getBytes());
- ByteArrayInputStream ca = new ByteArrayInputStream(str.getBytes());
- ByteArrayInputStream da = new ByteArrayInputStream(str.getBytes());
-
- DataInputStream a = new DataInputStream(aa);
- try {
- assertEquals(str, IOUtil.read(a));
- } finally {
- a.close();
- }
-
- DataInputStream b = new DataInputStream(ba);
- try {
- assertEquals("AbCdEfGhIj", IOUtil.read(b, 10));
- } finally {
- b.close();
- }
-
- DataInputStream c = new DataInputStream(ca);
- try {
- assertEquals("bdfhjl\np\rtvxz", IOUtil.skipRead(c));
- } finally {
- c.close();
- }
-
- DataInputStream d = new DataInputStream(da);
- try {
- assertEquals("AbCdEfGhIjKlM", d.readLine());
- assertEquals("OpQ", d.readLine());
- assertEquals("StUvWxYz", d.readLine());
- } finally {
- d.close();
- }
-
- ByteArrayOutputStream e = new ByteArrayOutputStream();
- DataOutputStream f = new DataOutputStream(e);
- try {
- f.writeBoolean(true);
- f.writeByte('a');
- f.writeBytes("BCD");
- f.writeChar('e');
- f.writeChars("FGH");
- f.writeUTF("ijklm");
- f.writeDouble(1);
- f.writeFloat(2);
- f.writeInt(3);
- f.writeLong(4);
- f.writeShort(5);
- } finally {
- f.close();
- }
-
- ByteArrayInputStream ga = new ByteArrayInputStream(e.toByteArray());
- DataInputStream g = new DataInputStream(ga);
-
- try {
- assertTrue(g.readBoolean());
- assertEquals('a', g.readByte());
- assertEquals(2, g.skipBytes(2));
- assertEquals('D', g.readByte());
- assertEquals('e', g.readChar());
- assertEquals('F', g.readChar());
- assertEquals('G', g.readChar());
- assertEquals('H', g.readChar());
- assertEquals("ijklm", g.readUTF());
- assertEquals(1, g.readDouble(), 0);
- assertEquals(2f, g.readFloat(), 0f);
- assertEquals(3, g.readInt());
- assertEquals(4, g.readLong());
- assertEquals(5, g.readShort());
- } finally {
- g.close();
- }
- }
-}
diff --git a/tests/CoreTests/android/core/DataOutputStreamTest.java b/tests/CoreTests/android/core/DataOutputStreamTest.java
deleted file mode 100644
index 95502b3..0000000
--- a/tests/CoreTests/android/core/DataOutputStreamTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Basic tests for DataOutputStreams.
- */
-public class DataOutputStreamTest extends TestCase {
-
- @SmallTest
- public void testDataOutputStream() throws Exception {
- String str = "AbCdEfGhIjKlMnOpQrStUvWxYz";
- ByteArrayOutputStream aa = new ByteArrayOutputStream();
- DataOutputStream a = new DataOutputStream(aa);
-
- try {
- a.write(str.getBytes(), 0, 26);
- a.write('A');
-
- assertEquals(27, aa.size());
- assertEquals("AbCdEfGhIjKlMnOpQrStUvWxYzA", aa.toString());
-
- a.writeByte('B');
- assertEquals("AbCdEfGhIjKlMnOpQrStUvWxYzAB", aa.toString());
- a.writeBytes("BYTES");
- assertEquals("AbCdEfGhIjKlMnOpQrStUvWxYzABBYTES", aa.toString());
- } finally {
- a.close();
- }
- }
-}
diff --git a/tests/CoreTests/android/core/DatagramTest.java b/tests/CoreTests/android/core/DatagramTest.java
deleted file mode 100644
index 355a267..0000000
--- a/tests/CoreTests/android/core/DatagramTest.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.IOException;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.InetAddress;
-import java.net.SocketTimeoutException;
-import android.test.suitebuilder.annotation.LargeTest;
-
-/**
- * Implements some simple tests for datagrams. Not as excessive as the core
- * tests, but good enough for the harness.
- */
-public class DatagramTest extends TestCase {
-
- /**
- * Helper class that listens to incoming datagrams and reflects them to the
- * sender. Incoming datagram is interpreted as a String. It is uppercased
- * before being sent back.
- */
-
- class Reflector extends Thread {
- // Helper class for reflecting incoming datagrams.
- DatagramSocket socket;
-
- boolean alive = true;
-
- byte[] buffer = new byte[256];
-
- DatagramPacket packet;
-
- /**
- * Main loop. Receives datagrams and reflects them.
- */
- @Override
- public void run() {
- try {
- while (alive) {
- try {
- packet.setLength(buffer.length);
- socket.receive(packet);
- String s = stringFromPacket(packet);
- // System.out.println(s + " (from " + packet.getAddress() + ":" + packet.getPort() + ")");
-
- try {
- Thread.sleep(100);
- } catch (InterruptedException ex) {
- // Ignore.
- }
-
- stringToPacket(s.toUpperCase(), packet);
-
- packet.setAddress(InetAddress.getLocalHost());
- packet.setPort(2345);
-
- socket.send(packet);
- } catch (java.io.InterruptedIOException e) {
- }
- }
- } catch (java.io.IOException ex) {
- ex.printStackTrace();
- } finally {
- socket.close();
- }
- }
-
- /**
- * Creates a new Relfector object for the given local address and port.
- */
- public Reflector(int port, InetAddress address) {
- try {
- packet = new DatagramPacket(buffer, buffer.length);
- socket = new DatagramSocket(port, address);
- } catch (IOException ex) {
- throw new RuntimeException(
- "Creating datagram reflector failed", ex);
- }
- }
- }
-
- /**
- * Converts a given datagram packet's contents to a String.
- */
- static String stringFromPacket(DatagramPacket packet) {
- return new String(packet.getData(), 0, packet.getLength());
- }
-
- /**
- * Converts a given String into a datagram packet.
- */
- static void stringToPacket(String s, DatagramPacket packet) {
- byte[] bytes = s.getBytes();
- System.arraycopy(bytes, 0, packet.getData(), 0, bytes.length);
- packet.setLength(bytes.length);
- }
-
- /**
- * Implements the main part of the Datagram test.
- */
- @LargeTest
- public void testDatagram() throws Exception {
-
- Reflector reflector = null;
- DatagramSocket socket = null;
-
- try {
- // Setup the reflector, so we have a partner to send to
- reflector = new Reflector(1234, InetAddress.getLocalHost());
- reflector.start();
-
- byte[] buffer = new byte[256];
-
- DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
- socket = new DatagramSocket(2345, InetAddress.getLocalHost());
-
- // Send ten simple packets and check for the expected responses.
- for (int i = 1; i <= 10; i++) {
- String s = "Hello, Android world #" + i + "!";
- stringToPacket(s, packet);
-
- packet.setAddress(InetAddress.getLocalHost());
- packet.setPort(1234);
-
- socket.send(packet);
-
- try {
- Thread.sleep(100);
- } catch (InterruptedException ex) {
- // Ignore.
- }
-
- packet.setLength(buffer.length);
- socket.receive(packet);
- String t = stringFromPacket(packet);
- // System.out.println(t + " (from " + packet.getAddress() + ":" + packet.getPort() + ")");
-
- assertEquals(s.toUpperCase(), t);
- }
- } finally {
- if (reflector != null) {
- reflector.alive = false;
- }
-
- if (socket != null) {
- socket.close();
- }
- }
- }
-
- // Regression test for issue 1018003: DatagramSocket ignored a set timeout.
- @LargeTest
- public void testDatagramSocketSetSOTimeout() throws Exception {
- DatagramSocket sock = null;
- int timeout = 5000;
- long start = System.currentTimeMillis();
- try {
- sock = new DatagramSocket();
- DatagramPacket pack = new DatagramPacket(new byte[100], 100);
- sock.setSoTimeout(timeout);
- sock.receive(pack);
- } catch (SocketTimeoutException e) {
- // expected
- long delay = System.currentTimeMillis() - start;
- if (Math.abs(delay - timeout) > 1000) {
- fail("timeout was not accurate. expected: " + timeout
- + " actual: " + delay + " miliseconds.");
- }
- } finally {
- if (sock != null) {
- sock.close();
- }
- }
- }
-}
diff --git a/tests/CoreTests/android/core/DeflateTest.java b/tests/CoreTests/android/core/DeflateTest.java
deleted file mode 100644
index d68d697..0000000
--- a/tests/CoreTests/android/core/DeflateTest.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.UnsupportedEncodingException;
-import java.util.zip.DataFormatException;
-import java.util.zip.Deflater;
-import java.util.zip.Inflater;
-import android.test.suitebuilder.annotation.LargeTest;
-
-public class DeflateTest extends TestCase {
-
- @LargeTest
- public void testDeflate() throws Exception {
- simpleTest();
-
- bigTest(0, 1738149618);
- bigTest(1, 934350518);
- bigTest(2, -532869390);
- }
-
- /*
- * Simple inflate/deflate test, taken from the reference docs for the
- * Inflater/Deflater classes.
- */
- private void simpleTest()
- throws UnsupportedEncodingException, DataFormatException {
- // Encode a String into bytes
- String inputString = "blahblahblah??";
- byte[] input = inputString.getBytes("UTF-8");
-
- // Compress the bytes
- byte[] output = new byte[100];
- Deflater compresser = new Deflater();
- compresser.setInput(input);
- compresser.finish();
- int compressedDataLength = compresser.deflate(output);
-
- // Decompress the bytes
- Inflater decompresser = new Inflater();
- decompresser.setInput(output, 0, compressedDataLength);
- byte[] result = new byte[100];
- int resultLength = decompresser.inflate(result);
-
- // Decode the bytes into a String
- String outputString = new String(result, 0, resultLength, "UTF-8");
-
- assertEquals(inputString, outputString);
- assertEquals(compresser.getAdler(), decompresser.getAdler());
-
- decompresser.end();
- }
-
- /*
- * "step" determines how compressible the data is.
- *
- * Note we must set "nowrap" to false, or the Adler-32 doesn't get
- * computed.
- */
- private void bigTest(int step, int expectedAdler)
- throws UnsupportedEncodingException, DataFormatException {
- byte[] input = new byte[128 * 1024];
- byte[] comp = new byte[128 * 1024 + 512];
- byte[] output = new byte[128 * 1024 + 512];
- Inflater inflater = new Inflater(false);
- Deflater deflater = new Deflater(Deflater.BEST_COMPRESSION, false);
-
- createSample(input, step);
-
- compress(deflater, input, comp);
- expand(inflater, comp, (int) deflater.getBytesWritten(), output);
-
- assertEquals(inflater.getBytesWritten(), input.length);
- assertEquals(deflater.getAdler(), inflater.getAdler());
- assertEquals(deflater.getAdler(), expectedAdler);
- }
-
- /*
- * Create a large data sample.
- * stepStep = 0 --> >99% compression
- * stepStep = 1 --> ~30% compression
- * stepStep = 2 --> no compression
- */
- private void createSample(byte[] sample, int stepStep) {
- byte val, step;
- int i, j, offset;
-
- assertTrue(sample.length >= 128 * 1024);
-
- val = 0;
- step = 1;
- offset = 0;
- for (i = 0; i < (128 * 1024) / 256; i++) {
- for (j = 0; j < 256; j++) {
- sample[offset++] = val;
- val += step;
- }
-
- step += stepStep;
- }
- }
-
- private static final int LOCAL_BUF_SIZE = 256;
-
- /*
- * Compress all data in "in" to "out". We use a small window on input
- * and output to exercise that part of the code.
- *
- * It's the caller's responsibility to ensure that "out" has enough
- * space.
- */
- private void compress(Deflater deflater, byte[] inBuf, byte[] outBuf) {
- int inCount = inBuf.length; // use all
- int inPosn;
- int outPosn;
-
- inPosn = outPosn = 0;
-
- //System.out.println("### starting compress");
-
- while (!deflater.finished()) {
- int want = -1, got;
-
- // only read if the input buffer is empty
- if (deflater.needsInput() && inCount != 0) {
- want = (inCount < LOCAL_BUF_SIZE) ? inCount : LOCAL_BUF_SIZE;
-
- deflater.setInput(inBuf, inPosn, want);
-
- inCount -= want;
- inPosn += want;
- if (inCount == 0) {
- deflater.finish();
- }
- }
-
- // deflate to current position in output buffer
- int compCount;
-
- compCount = deflater.deflate(outBuf, outPosn, LOCAL_BUF_SIZE);
- outPosn += compCount;
-
- //System.out.println("Compressed " + want + ", output " + compCount);
- }
- }
-
- /*
- * Expand data from "inBuf" to "outBuf". Uses a small window to better
- * exercise the code.
- */
- private void expand(Inflater inflater, byte[] inBuf, int inCount,
- byte[] outBuf) throws DataFormatException {
- int inPosn;
- int outPosn;
-
- inPosn = outPosn = 0;
-
- //System.out.println("### starting expand, inCount is " + inCount);
-
- while (!inflater.finished()) {
- int want = -1, got;
-
- // only read if the input buffer is empty
- if (inflater.needsInput() && inCount != 0) {
- want = (inCount < LOCAL_BUF_SIZE) ? inCount : LOCAL_BUF_SIZE;
-
- inflater.setInput(inBuf, inPosn, want);
-
- inCount -= want;
- inPosn += want;
- }
-
- // inflate to current position in output buffer
- int compCount;
-
- compCount = inflater.inflate(outBuf, outPosn, LOCAL_BUF_SIZE);
- outPosn += compCount;
-
- //System.out.println("Expanded " + want + ", output " + compCount);
- }
- }
-}
-
diff --git a/tests/CoreTests/android/core/EnumTest.java b/tests/CoreTests/android/core/EnumTest.java
deleted file mode 100644
index d479491..0000000
--- a/tests/CoreTests/android/core/EnumTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Tests basic behavior of enums.
- */
-public class EnumTest extends TestCase {
- enum MyEnum {
- ZERO, ONE, TWO, THREE, FOUR {boolean isFour() {
- return true;
- }};
-
- boolean isFour() {
- return false;
- }
- }
-
- enum MyEnumTwo {
- FIVE, SIX
- }
-
- @SmallTest
- public void testEnum() throws Exception {
- assertTrue(MyEnum.ZERO.compareTo(MyEnum.ONE) < 0);
- assertEquals(MyEnum.ZERO, MyEnum.ZERO);
- assertTrue(MyEnum.TWO.compareTo(MyEnum.ONE) > 0);
- assertTrue(MyEnum.FOUR.compareTo(MyEnum.ONE) > 0);
-
- assertEquals("ONE", MyEnum.ONE.name());
- assertSame(MyEnum.ONE.getDeclaringClass(), MyEnum.class);
- assertSame(MyEnum.FOUR.getDeclaringClass(), MyEnum.class);
-
- assertTrue(MyEnum.FOUR.isFour());
-
- MyEnum e;
-
- e = MyEnum.ZERO;
-
- switch (e) {
- case ZERO:
- break;
- default:
- fail("wrong switch");
- }
- }
-}
diff --git a/tests/CoreTests/android/core/FileTest.java b/tests/CoreTests/android/core/FileTest.java
deleted file mode 100644
index 980452e..0000000
--- a/tests/CoreTests/android/core/FileTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.File;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Checks creation and deletion of a file.
- */
-public class FileTest extends TestCase {
-
- @SmallTest
- public void testFile() throws Exception {
-
- File file = File.createTempFile(String.valueOf(System.currentTimeMillis()), null, null);
-
- assertTrue(file.exists());
- assertTrue(file.delete());
- assertFalse(file.exists());
- }
-}
diff --git a/tests/CoreTests/android/core/FloatDoubleTest.java b/tests/CoreTests/android/core/FloatDoubleTest.java
deleted file mode 100644
index 8c8455b..0000000
--- a/tests/CoreTests/android/core/FloatDoubleTest.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Tests for basic functionality of floats and doubles.
- */
-public class FloatDoubleTest extends TestCase {
-
- @SmallTest
- public void testFloatDouble() throws Exception {
- Double d = Double.valueOf(1.0);
- Float f = Float.valueOf(1.0f);
- Object o = new Object();
-
- assertFalse(f.equals(d));
- assertFalse(d.equals(f));
- assertFalse(f.equals(o));
- assertFalse(d.equals(o));
- assertFalse(f.equals(null));
- assertFalse(d.equals(null));
- }
-
- @SmallTest
- public void testFloat() throws Exception {
- float pz = 0.0f;
- float nz = -0.0f;
-
- float pzero = 1.0f / Float.POSITIVE_INFINITY;
- float nzero = 1.0f / Float.NEGATIVE_INFINITY;
-
- // Everything compares as '=='
- assertTrue(pz == pz);
- assertTrue(pz == nz);
- assertTrue(pz == pzero);
- assertTrue(pz == nzero);
-
- assertTrue(nz == pz);
- assertTrue(nz == nz);
- assertTrue(nz == pzero);
- assertTrue(nz == nzero);
-
- assertTrue(pzero == pz);
- assertTrue(pzero == nz);
- assertTrue(pzero == pzero);
- assertTrue(pzero == nzero);
-
- assertTrue(nzero == pz);
- assertTrue(nzero == nz);
- assertTrue(nzero == pzero);
- assertTrue(nzero == nzero);
-
- // +-0 are distinct as Floats
- assertEquals(Float.valueOf(pz), Float.valueOf(pz));
- assertTrue(!Float.valueOf(pz).equals(Float.valueOf(nz)));
- assertEquals(Float.valueOf(pz), Float.valueOf(pzero));
- assertTrue(!Float.valueOf(pz).equals(Float.valueOf(nzero)));
-
- assertTrue(!Float.valueOf(nz).equals(Float.valueOf(pz)));
- assertEquals(Float.valueOf(nz), Float.valueOf(nz));
- assertTrue(!Float.valueOf(nz).equals(Float.valueOf(pzero)));
- assertEquals(Float.valueOf(nz), Float.valueOf(nzero));
-
- assertEquals(Float.valueOf(pzero), Float.valueOf(pz));
- assertTrue(!Float.valueOf(pzero).equals(Float.valueOf(nz)));
- assertEquals(Float.valueOf(pzero), Float.valueOf(pzero));
- assertTrue(!Float.valueOf(pzero).equals(Float.valueOf(nzero)));
-
- assertTrue(!Float.valueOf(nzero).equals(Float.valueOf(pz)));
- assertEquals(Float.valueOf(nzero), Float.valueOf(nz));
- assertTrue(!Float.valueOf(nzero).equals(Float.valueOf(pzero)));
- assertEquals(Float.valueOf(nzero), Float.valueOf(nzero));
-
- // Nan's compare as equal
- Float sqrtm2 = Float.valueOf((float) Math.sqrt(-2.0f));
- Float sqrtm3 = Float.valueOf((float) Math.sqrt(-3.0f));
- assertEquals(sqrtm2, sqrtm3);
- }
-
- @SmallTest
- public void testDouble() throws Exception {
- double pz = 0.0;
- double nz = -0.0;
-
- double pzero = 1.0 / Double.POSITIVE_INFINITY;
- double nzero = 1.0 / Double.NEGATIVE_INFINITY;
-
- // Everything compares as '=='
- assertTrue(pz == pz);
- assertTrue(pz == nz);
- assertTrue(pz == pzero);
- assertTrue(pz == nzero);
-
- assertTrue(nz == pz);
- assertTrue(nz == nz);
- assertTrue(nz == pzero);
- assertTrue(nz == nzero);
-
- assertTrue(pzero == pz);
- assertTrue(pzero == nz);
- assertTrue(pzero == pzero);
- assertTrue(pzero == nzero);
-
- assertTrue(nzero == pz);
- assertTrue(nzero == nz);
- assertTrue(nzero == pzero);
- assertTrue(nzero == nzero);
-
- // +-0 are distinct as Doubles
- assertEquals(Double.valueOf(pz), Double.valueOf(pz));
- assertTrue(!Double.valueOf(pz).equals(Double.valueOf(nz)));
- assertEquals(Double.valueOf(pz), Double.valueOf(pzero));
- assertTrue(!Double.valueOf(pz).equals(Double.valueOf(nzero)));
-
- assertTrue(!Double.valueOf(nz).equals(Double.valueOf(pz)));
- assertEquals(Double.valueOf(nz), Double.valueOf(nz));
- assertTrue(!Double.valueOf(nz).equals(Double.valueOf(pzero)));
- assertEquals(Double.valueOf(nz), Double.valueOf(nzero));
-
- assertEquals(Double.valueOf(pzero), Double.valueOf(pz));
- assertTrue(!Double.valueOf(pzero).equals(Double.valueOf(nz)));
- assertEquals(Double.valueOf(pzero), Double.valueOf(pzero));
- assertTrue(!Double.valueOf(pzero).equals(Double.valueOf(nzero)));
-
- assertTrue(!Double.valueOf(nzero).equals(Double.valueOf(pz)));
- assertEquals(Double.valueOf(nzero), Double.valueOf(nz));
- assertTrue(!Double.valueOf(nzero).equals(Double.valueOf(pzero)));
- assertEquals(Double.valueOf(nzero), Double.valueOf(nzero));
-
- // Nan's compare as equal
- Double sqrtm2 = Double.valueOf(Math.sqrt(-2.0));
- Double sqrtm3 = Double.valueOf(Math.sqrt(-3.0));
- assertEquals(sqrtm2, sqrtm3);
- }
-}
diff --git a/tests/CoreTests/android/core/GZIPStreamTest.java b/tests/CoreTests/android/core/GZIPStreamTest.java
deleted file mode 100644
index dd56fb7..0000000
--- a/tests/CoreTests/android/core/GZIPStreamTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.zip.GZIPInputStream;
-import java.util.zip.GZIPOutputStream;
-import android.test.suitebuilder.annotation.MediumTest;
-
-/**
- * Deflates and inflates some test data with GZipStreams
- */
-public class GZIPStreamTest extends TestCase {
-
- @MediumTest
- public void testGZIPStream() throws Exception {
- ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
- createGZIP(bytesOut);
-
- byte[] zipData;
- zipData = bytesOut.toByteArray();
-
- /*
- FileOutputStream outFile = new FileOutputStream("/tmp/foo.gz");
- outFile.write(zipData, 0, zipData.length);
- outFile.close();
- */
-
- /*
- FileInputStream inFile = new FileInputStream("/tmp/foo.gz");
- int inputLength = inFile.available();
- zipData = new byte[inputLength];
- if (inFile.read(zipData) != inputLength)
- throw new RuntimeException();
- inFile.close();
- */
-
- ByteArrayInputStream bytesIn = new ByteArrayInputStream(zipData);
- scanGZIP(bytesIn);
- }
-
- /*
- * stepStep == 0 --> >99% compression
- * stepStep == 1 --> ~30% compression
- * stepStep == 2 --> no compression
- */
- static byte[] makeSampleFile(int stepStep) throws IOException {
- byte[] sample = new byte[128 * 1024];
- byte val, step;
- int i, j, offset;
-
- val = 0;
- step = 1;
- offset = 0;
- for (i = 0; i < (128 * 1024) / 256; i++) {
- for (j = 0; j < 256; j++) {
- sample[offset++] = val;
- val += step;
- }
-
- step += stepStep;
- }
-
- return sample;
- }
-
- static void createGZIP(ByteArrayOutputStream bytesOut) throws IOException {
- GZIPOutputStream out = new GZIPOutputStream(bytesOut);
- try {
- byte[] input = makeSampleFile(1);
- out.write(input, 0, input.length);
- //out.finish();
- } finally {
- out.close();
- }
- }
-
- static void scanGZIP(ByteArrayInputStream bytesIn) throws IOException {
- GZIPInputStream in = new GZIPInputStream(bytesIn);
- try {
- ByteArrayOutputStream contents = new ByteArrayOutputStream();
- byte[] buf = new byte[4096];
- int len, totalLen = 0;
-
- while ((len = in.read(buf)) > 0) {
- contents.write(buf, 0, len);
- totalLen += len;
- }
-
- assertEquals(totalLen, 128 * 1024);
- } finally {
- in.close();
- }
- }
-}
-
diff --git a/tests/CoreTests/android/core/IOUtil.java b/tests/CoreTests/android/core/IOUtil.java
deleted file mode 100644
index 6f69418..0000000
--- a/tests/CoreTests/android/core/IOUtil.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.InputStreamReader;
-
-public final class IOUtil {
-
- private IOUtil() {
- }
-
- /**
- * returns the content of an InputStream as a String.
- *
- * @param a the input stream.
- * @return the string
- * @throws java.io.IOException
- */
- public static String read(InputStream a) throws IOException {
- int r;
- StringBuilder builder = new StringBuilder();
- do {
- r = a.read();
- if (r != -1)
- builder.append((char) r);
- } while (r != -1);
- return builder.toString();
- }
-
- /**
- * reads characters from a reader and returns them as a string.
- *
- * @param a the reader.
- * @return the string.
- * @throws IOException
- */
- public static String read(Reader a) throws IOException {
- int r;
- StringBuilder builder = new StringBuilder();
- do {
- r = a.read();
- if (r != -1)
- builder.append((char) r);
- } while (r != -1);
- return builder.toString();
- }
-
- /**
- * returns the content of an InputStream as a String. It reads x characters.
- *
- * @param a the input stream.
- * @param x number of characters to read.
- * @return the string
- * @throws IOException
- */
- public static String read(InputStream a, int x) throws IOException {
- byte[] b = new byte[x];
- int len = a.read(b, 0, x);
- if (len < 0) {
- return "";
- }
- return new String(b, 0, len);
- }
-
- /**
- * reads a number of characters from a reader and returns them as a string.
- *
- * @param a the reader.
- * @param x the number of characters to read.
- * @return the string.
- * @throws IOException
- */
- public static String read(Reader a, int x) throws IOException {
- char[] b = new char[x];
- int len = a.read(b, 0, x);
- if (len < 0) {
- return "";
- }
- return new String(b, 0, len);
- }
-
- /**
- * returns the content of the input stream as a String. It only appends
- * every second character.
- *
- * @param a the input stream.
- * @return the string created from every second character of the input stream.
- * @throws IOException
- */
- public static String skipRead(InputStream a) throws IOException {
- int r;
- StringBuilder builder = new StringBuilder();
- do {
- a.skip(1);
- r = a.read();
- if (r != -1)
- builder.append((char) r);
- } while (r != -1);
- return builder.toString();
- }
-
- /**
- * reads every second characters from a reader and returns them as a string.
- *
- * @param a the reader.
- * @return the string.
- * @throws IOException
- */
- public static String skipRead(Reader a) throws IOException {
- int r;
- StringBuilder builder = new StringBuilder();
- do {
- a.skip(1);
- r = a.read();
- if (r != -1)
- builder.append((char) r);
- } while (r != -1);
- return builder.toString();
- }
-
- /**
- * reads characters from a InputStream, skips back y characters and continues
- * reading from that new position up to the end.
- *
- * @param a the InputStream.
- * @param x the position of the mark. the marks position is x+y
- * @param y the number of characters to jump back after the position x+y was reached.
- * @return the string.
- * @throws IOException
- */
- public static String markRead(InputStream a, int x, int y) throws IOException {
- int m = 0;
- int r;
- StringBuilder builder = new StringBuilder();
- do {
- m++;
- r = a.read();
- if (m == x)
- a.mark((x + y));
- if (m == (x + y))
- a.reset();
-
- if (r != -1)
- builder.append((char) r);
- } while (r != -1);
- return builder.toString();
- }
-
- /**
- * reads characters from a reader, skips back y characters and continues
- * reading from that new position up to the end.
- *
- * @param a the reader.
- * @param x the position of the mark. the marks position is x+y
- * @param y the number of characters to jump back after the position x+y was reached.
- * @return the string.
- * @throws IOException
- */
- public static String markRead(Reader a, int x, int y) throws IOException {
- int m = 0;
- int r;
- StringBuilder builder = new StringBuilder();
- do {
- m++;
- r = a.read();
- if (m == x)
- a.mark((x + y));
- if (m == (x + y))
- a.reset();
-
- if (r != -1)
- builder.append((char) r);
- } while (r != -1);
- return builder.toString();
- }
-}
diff --git a/tests/CoreTests/android/core/InputStreamReaderTest.java b/tests/CoreTests/android/core/InputStreamReaderTest.java
deleted file mode 100644
index 1e8d87c..0000000
--- a/tests/CoreTests/android/core/InputStreamReaderTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStreamReader;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Checks basic InputStreamReader functionality.
- */
-public class InputStreamReaderTest extends TestCase {
-
- /**
- * Checks if ASCII encoding works with InputStreamReader
- */
- @SmallTest
- public void testAscii() throws Exception {
- String str = "AbCdEfGhIjKlMnOpQrStUvWxYzX";
- ByteArrayInputStream aa = new ByteArrayInputStream(str.getBytes("ISO8859_1"));
- InputStreamReader a = new InputStreamReader(aa, "ISO8859_1");
-
- try {
- int x = a.read();
- assertEquals('A', x);
- char[] c = new char[26];
- x = a.read(c, 0, 26);
- assertTrue(a.getEncoding().equalsIgnoreCase("ISO8859_1"));
- assertEquals(26, x);
- assertEquals("bCdEfGhIjKlMnOpQrStUvWxYzX", String.valueOf(c));
- } finally {
- a.close();
- }
- }
-
- /**
- * Checks if Utf8 encoding works with InputStreamReader
- */
- @SmallTest
- public void testUtf8() throws Exception {
- String str = "AbCdEfGhIjKlMnOpQrStUvWxYzX" +
- "\u00a3\u00c5\u00c9"; // total of 30 characters
- ByteArrayInputStream aa =
- new ByteArrayInputStream(str.getBytes());
-
- InputStreamReader a = new InputStreamReader(aa);
-
- try {
- assertEquals("UTF8", a.getEncoding());
-
- int x = a.read();
- assertEquals('A', x);
-
- char[] c = new char[29];
- x = a.read(c, 0, 3);
- assertEquals(3, x);
- assertEquals("bCd", new String(c, 0, 3));
-
- x = a.read(c, 3, 26);
- assertEquals(26, x);
- assertEquals("EfGhIjKlMnOpQrStUvWxYzX\u00a3\u00c5\u00c9", new String(c, 3, 26));
- } finally {
- a.close();
- }
- }
-
- /**
- * Checks if several encodings works with InputStreamReader
- */
- @SmallTest
- public void testStringy() throws Exception {
- String src = "The quick brown fox\u00A0\u00FF" +
- "\uFFFC\uD7C5\uDC03bloof";
-
- String[] enc = new String[]{
- "utf-8", "us-ascii", "iso-8859-1", "utf-16be", "utf-16le",
- "utf-16",
- };
-
- for (int i = 0; i < enc.length; i++) {
- byte[] ba = src.getBytes(enc[i]);
-
- String s1 = new String(ba, enc[i]);
-
- ByteArrayInputStream bais = new ByteArrayInputStream(ba);
- InputStreamReader r = new InputStreamReader(bais, enc[i]);
- try {
- char[] ca = new char[600];
- int n = r.read(ca, 0, 600);
-
- String s2 = new String(ca, 0, n);
- assertEquals(s1, s2);
- } finally {
- r.close();
- }
- }
- }
-}
diff --git a/tests/CoreTests/android/core/InstanceofTest.java b/tests/CoreTests/android/core/InstanceofTest.java
deleted file mode 100644
index b35ef6b..0000000
--- a/tests/CoreTests/android/core/InstanceofTest.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-
-
-public class InstanceofTest extends TestCase {
-
- protected A mA;
- protected ChildOfAOne mOne;
- protected ChildOfAOne mTwo;
- protected ChildOfAOne mThree;
- protected ChildOfAOne mFour;
- protected ChildOfAFive mFive;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- mA = new A();
- mOne = new ChildOfAOne();
- mTwo = new ChildOfATwo();
- mThree = new ChildOfAThree();
- mFour = new ChildOfAFour();
- mFive = new ChildOfAFive();
- }
-
-
- @MediumTest
- public void testNoInterface() throws Exception {
- A a = mA;
- for (int i = 0; i < 100000; i++) {
- assertFalse("m_a should not be a ChildOfAFive", a instanceof ChildOfAFive);
- }
- }
-
- @MediumTest
- public void testDerivedOne() throws Exception {
- InterfaceOne one = mOne;
- for (int i = 0; i < 100000; i++) {
- assertFalse("m_one should not be a ChildOfAFive", one instanceof ChildOfAFive);
- }
- }
-
- @MediumTest
- public void testDerivedTwo() throws Exception {
- InterfaceTwo two = mTwo;
- for (int i = 0; i < 100000; i++) {
- assertFalse("m_two should not be a ChildOfAFive", two instanceof ChildOfAFive);
- }
- }
-
- @MediumTest
- public void testDerivedThree() throws Exception {
- InterfaceThree three = mThree;
- for (int i = 0; i < 100000; i++) {
- assertFalse("m_three should not be a ChildOfAFive", three instanceof ChildOfAFive);
- }
- }
-
- @MediumTest
- public void testDerivedFour() throws Exception {
- InterfaceFour four = mFour;
- for (int i = 0; i < 100000; i++) {
- assertFalse("m_four should not be a ChildOfAFive", four instanceof ChildOfAFive);
- }
- }
-
- @MediumTest
- public void testSuccessClass() throws Exception {
- ChildOfAOne five = mFive;
- for (int i = 0; i < 100000; i++) {
- assertTrue("m_five is suppose to be a ChildOfAFive", five instanceof ChildOfAFive);
- }
- }
-
- @MediumTest
- public void testSuccessInterface() throws Exception {
- ChildOfAFive five = mFive;
- for (int i = 0; i < 100000; i++) {
- assertTrue("m_five is suppose to be a InterfaceFour", five instanceof InterfaceFour);
- }
- }
-
- @MediumTest
- public void testFailInterface() throws Exception {
- InterfaceOne one = mFive;
- for (int i = 0; i < 100000; i++) {
- assertFalse("m_five does not implement InterfaceFive", one instanceof InterfaceFive);
- }
- }
-
- private interface InterfaceOne {
- }
-
- private interface InterfaceTwo {
- }
-
- private interface InterfaceThree {
- }
-
- private interface InterfaceFour {
- }
-
- private interface InterfaceFive {
- }
-
- private static class A {
- }
-
- private static class ChildOfAOne extends A implements InterfaceOne, InterfaceTwo, InterfaceThree, InterfaceFour {
- }
-
- private static class ChildOfATwo extends ChildOfAOne {
- }
-
- private static class ChildOfAThree extends ChildOfATwo {
- }
-
- private static class ChildOfAFour extends ChildOfAThree {
- }
-
- private static class ChildOfAFive extends ChildOfAFour {
- }
-}
diff --git a/tests/CoreTests/android/core/LineNumberReaderTest.java b/tests/CoreTests/android/core/LineNumberReaderTest.java
deleted file mode 100644
index 6380ebe..0000000
--- a/tests/CoreTests/android/core/LineNumberReaderTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.LineNumberReader;
-import java.io.StringReader;
-import android.test.suitebuilder.annotation.MediumTest;
-
-/**
- * Checks basic functionality for LineNumberReader.
- */
-public class LineNumberReaderTest extends TestCase {
-
- @MediumTest
- public void testLineNumberReader() throws Exception {
- String str = "AbCdEfGhIjKlM\nOpQrStUvWxYz";
-
- StringReader aa = new StringReader(str);
- StringReader ba = new StringReader(str);
- StringReader ca = new StringReader(str);
- StringReader da = new StringReader(str);
- StringReader ea = new StringReader(str);
-
- LineNumberReader a = new LineNumberReader(aa);
- try {
- assertEquals(0, a.getLineNumber());
- assertEquals(str, IOUtil.read(a));
- assertEquals(1, a.getLineNumber());
- a.setLineNumber(5);
- assertEquals(5, a.getLineNumber());
- } finally {
- a.close();
- }
-
- LineNumberReader b = new LineNumberReader(ba);
- try {
- assertEquals("AbCdEfGhIj", IOUtil.read(b, 10));
- } finally {
- b.close();
- }
-
- LineNumberReader c = new LineNumberReader(ca);
- try {
- assertEquals("bdfhjl\nprtvxz", IOUtil.skipRead(c));
- } finally {
- c.close();
- }
-
- LineNumberReader d = new LineNumberReader(da);
- try {
- assertEquals("AbCdEfGdEfGhIjKlM\nOpQrStUvWxYz", IOUtil.markRead(d, 3, 4));
- } finally {
- d.close();
- }
-
- LineNumberReader e = new LineNumberReader(ea);
- try {
- assertEquals("AbCdEfGhIjKlM", e.readLine());
- } finally {
- e.close();
- }
- }
-}
diff --git a/tests/CoreTests/android/core/LocaleTest.java b/tests/CoreTests/android/core/LocaleTest.java
deleted file mode 100644
index 72489c6..0000000
--- a/tests/CoreTests/android/core/LocaleTest.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.nio.charset.Charset;
-import java.text.DateFormatSymbols;
-import java.util.Calendar;
-import java.util.Currency;
-import java.util.Locale;
-import java.util.Set;
-import java.util.TimeZone;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.test.suitebuilder.annotation.Suppress;
-
-/**
- * Test some locale-dependent stuff for Android. This test mainly ensures that
- * our ICU configuration is correct and contains all the needed locales and
- * resource bundles.
- */
-public class LocaleTest extends TestCase {
-
- // Test basic Locale infrastructure.
- @SmallTest
- public void testLocale() throws Exception {
- Locale locale = new Locale("en");
- assertEquals("en", locale.toString());
-
- locale = new Locale("en", "US");
- assertEquals("en_US", locale.toString());
-
- locale = new Locale("en", "", "POSIX");
- assertEquals("en__POSIX", locale.toString());
-
- locale = new Locale("en", "US", "POSIX");
- assertEquals("en_US_POSIX", locale.toString());
- }
-
- /*
- * Tests some must-have locales. TODO: Add back "de". See discussion
- * immediately below this method.
- */
- @LargeTest
- public void testResourceBundles() throws Exception {
- Locale eng = new Locale("en", "US");
- DateFormatSymbols engSymbols = new DateFormatSymbols(eng);
-
- //Locale deu = new Locale("de", "DE");
- //DateFormatSymbols deuSymbols = new DateFormatSymbols(deu);
-
- TimeZone berlin = TimeZone.getTimeZone("Europe/Berlin");
-
- assertEquals("January", engSymbols.getMonths()[0]);
- //assertEquals("Januar", deuSymbols.getMonths()[0]);
-
- assertEquals("Sunday", engSymbols.getWeekdays()[Calendar.SUNDAY]);
- //assertEquals("Sonntag", deuSymbols.getWeekdays()[Calendar.SUNDAY]);
-
- assertEquals("Central European Time",
- berlin.getDisplayName(false, TimeZone.LONG, eng));
- assertEquals("Central European Summer Time",
- berlin.getDisplayName(true, TimeZone.LONG, eng));
-
- //assertEquals("Mitteleurop\u00E4ische Zeit",
- // berlin.getDisplayName(false, TimeZone.LONG, deu));
- //assertEquals("Mitteleurop\u00E4ische Sommerzeit",
- // berlin.getDisplayName(true, TimeZone.LONG, deu));
-
- assertTrue(engSymbols.getZoneStrings().length > 100);
- }
-
- /*
- * Disabled version of the above test. The version above omits
- * checks for stuff in the "de" locale, because we stripped that
- * out as part of the flash reduction effort (so that we could
- * still ship on Dream). We expect to have a baseline target that
- * includes a large enough system partition to include "de"
- * immediately after the last official release for Dream (whenever
- * that may be).
- *
- // Test some must-have locales.
- @LargeTest
- public void testResourceBundles() throws Exception {
- Locale eng = new Locale("en", "US");
- DateFormatSymbols engSymbols = new DateFormatSymbols(eng);
-
- Locale deu = new Locale("de", "DE");
- DateFormatSymbols deuSymbols = new DateFormatSymbols(deu);
-
- TimeZone berlin = TimeZone.getTimeZone("Europe/Berlin");
-
- assertEquals("January", engSymbols.getMonths()[0]);
- assertEquals("Januar", deuSymbols.getMonths()[0]);
-
- assertEquals("Sunday", engSymbols.getWeekdays()[Calendar.SUNDAY]);
- assertEquals("Sonntag", deuSymbols.getWeekdays()[Calendar.SUNDAY]);
-
- assertEquals("Central European Time",
- berlin.getDisplayName(false, TimeZone.LONG, eng));
- assertEquals("Central European Summer Time",
- berlin.getDisplayName(true, TimeZone.LONG, eng));
-
- assertEquals("Mitteleurop\u00E4ische Zeit",
- berlin.getDisplayName(false, TimeZone.LONG, deu));
- assertEquals("Mitteleurop\u00E4ische Sommerzeit",
- berlin.getDisplayName(true, TimeZone.LONG, deu));
-
- assertTrue(engSymbols.getZoneStrings().length > 100);
- }
- */
-
- // This one makes sure we have all necessary locales installed.
- // Suppress this flaky test for now.
- @Suppress
- public void testICULocales() {
- String[] locales = new String[] {
- // List of locales currently required for Android.
- "en_US", "es_US", "en_GB", "fr_FR", "de_DE", "de_AT", "cs_CZ", "nl_NL" };
-
- String[] mondays = new String[] {
- "Monday", "lunes", "Monday", "lundi", "Montag", "Montag", "pond\u011bl\u00ed", "maandag" };
-
- String[] currencies = new String[] {
- "USD", "USD", "GBP", "EUR", "EUR", "EUR", "CZK", "EUR"};
-
- for (int i = 0; i < locales.length; i++) {
- Locale l = new Locale(locales[i].substring(0, 2), locales[i].substring(3));
-
- // Check language part of locale.
- DateFormatSymbols d = new DateFormatSymbols(l);
- assertEquals("Monday name for " + locales[i] + " must match",
- mondays[i], d.getWeekdays()[2]);
-
- // Check country part of locale.
- Currency c = Currency.getInstance(l);
- assertEquals("Currency code for " + locales[i] + " must match",
- currencies[i], c.getCurrencyCode());
- }
- }
-
- // Regression test for 1118570: Create test cases for tracking ICU config
- // changes. This one makes sure we have the necessary converters installed
- // and don't lose the changes to the converter alias table.
- @MediumTest
- public void testICUConverters() {
- // List of encodings currently required for Android.
- String[] encodings = new String[] {
- // Encoding required by the language specification.
- "US-ASCII",
- "UTF-8",
- "UTF-16",
- "UTF-16BE",
- "UTF-16LE",
- "ISO-8859-1",
-
- // Additional encodings included in standard ICU
- "ISO-8859-2",
- "ISO-8859-3",
- "ISO-8859-4",
- "ISO-8859-5",
- "ISO-8859-6",
- "ISO-8859-7",
- "ISO-8859-8",
- "ISO-8859-8-I",
- "ISO-8859-9",
- "ISO-8859-10",
- "ISO-8859-11",
- "ISO-8859-13",
- "ISO-8859-14",
- "ISO-8859-15",
- "ISO-8859-16",
- "ISO-2022-JP",
- "Windows-950",
- "Windows-1250",
- "Windows-1251",
- "Windows-1252",
- "Windows-1253",
- "Windows-1254",
- "Windows-1255",
- "Windows-1256",
- "Windows-1257",
- "Windows-1258",
- "Big5",
- "CP864",
- "CP874",
- "EUC-CN",
- "EUC-JP",
- "KOI8-R",
- "Macintosh",
- "GBK",
- "GB2312",
- "EUC-KR",
-
- // Additional encoding not included in standard ICU.
- "GSM0338" };
-
- for (int i = 0; i < encodings.length; i++) {
- assertTrue("Charset " + encodings[i] + " must be supported",
- Charset.isSupported(encodings[i]));
-
- Charset cs = Charset.forName(encodings[i]);
- android.util.Log.d("LocaleTest", cs.name());
-
- Set<String> aliases = cs.aliases();
- for (String s: aliases) {
- android.util.Log.d("LocaleTest", " - " + s);
- }
- }
-
- // Test for valid encoding that is not included in Android. IBM-37 is
- // a perfect candidate for this, as it is being used for mainframes and
- // thus somewhat out of the scope of Android.
- assertFalse("Charset IBM-37 must not be supported",
- Charset.isSupported("IBM-37"));
-
- // Test for a bogus encoding.
- assertFalse("Charset KLINGON must not be supported",
- Charset.isSupported("KLINGON"));
-
- // Make sure our local change to the real translation table used for
- // EUC-JP doesn't get lost.
- Charset cs = Charset.forName("EUC-JP");
- assertTrue("EUC-JP must use 'ibm-954_P101-2007'", cs.aliases().contains("ibm-954_P101-2007"));
- }
-
-}
diff --git a/tests/CoreTests/android/core/MathTest.java b/tests/CoreTests/android/core/MathTest.java
deleted file mode 100644
index 50009db..0000000
--- a/tests/CoreTests/android/core/MathTest.java
+++ /dev/null
@@ -1,831 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.test.suitebuilder.annotation.MediumTest;
-
-public class MathTest extends TestCase {
-
- private final double HYP = Math.sqrt(2.0);
-
- private final double OPP = 1.0;
-
- private final double ADJ = 1.0;
-
- /* Required to make previous preprocessor flags work - do not remove */
- int unused = 0;
-
- public static void assertEquals(String message, double expected, double actual, double delta) {
- if (delta == 0D) {
- Assert.assertEquals(message, expected, actual, Math.ulp(expected));
- } else {
- Assert.assertEquals(message, expected, actual, delta);
- }
- }
-
- public static void assertEquals(String message, float expected, float actual, float delta) {
- if (delta == 0F) {
- Assert.assertEquals(message, expected, actual, Math.ulp(expected));
- } else {
- Assert.assertEquals(message, expected, actual, delta);
- }
- }
-
- /**
- * @tests java.lang.Math#abs(double)
- */
- @SmallTest
- public void testAbsD() {
- // Test for method double java.lang.Math.abs(double)
-
- assertTrue("Incorrect double abs value",
- (Math.abs(-1908.8976) == 1908.8976));
- assertTrue("Incorrect double abs value",
- (Math.abs(1908.8976) == 1908.8976));
- }
-
- /**
- * @tests java.lang.Math#abs(float)
- */
- @SmallTest
- public void testAbsF() {
- // Test for method float java.lang.Math.abs(float)
- assertTrue("Incorrect float abs value",
- (Math.abs(-1908.8976f) == 1908.8976f));
- assertTrue("Incorrect float abs value",
- (Math.abs(1908.8976f) == 1908.8976f));
- }
-
- /**
- * @tests java.lang.Math#abs(int)
- */
- @SmallTest
- public void testAbsI() {
- // Test for method int java.lang.Math.abs(int)
- assertTrue("Incorrect int abs value", (Math.abs(-1908897) == 1908897));
- assertTrue("Incorrect int abs value", (Math.abs(1908897) == 1908897));
- }
-
- /**
- * @tests java.lang.Math#abs(long)
- */
- @SmallTest
- public void testAbsJ() {
- // Test for method long java.lang.Math.abs(long)
- assertTrue("Incorrect long abs value",
- (Math.abs(-19088976000089L) == 19088976000089L));
- assertTrue("Incorrect long abs value",
- (Math.abs(19088976000089L) == 19088976000089L));
- }
-
- /**
- * @tests java.lang.Math#acos(double)
- */
- @SmallTest
- public void testAcosD() {
- // Test for method double java.lang.Math.acos(double)
- double r = Math.cos(Math.acos(ADJ / HYP));
- long lr = Double.doubleToLongBits(r);
- long t = Double.doubleToLongBits(ADJ / HYP);
- assertTrue("Returned incorrect arc cosine", lr == t || (lr + 1) == t
- || (lr - 1) == t);
- }
-
- /**
- * @tests java.lang.Math#asin(double)
- */
- @SmallTest
- public void testAsinD() {
- // Test for method double java.lang.Math.asin(double)
- double r = Math.sin(Math.asin(OPP / HYP));
- long lr = Double.doubleToLongBits(r);
- long t = Double.doubleToLongBits(OPP / HYP);
- assertTrue("Returned incorrect arc sine", lr == t || (lr + 1) == t
- || (lr - 1) == t);
- }
-
- /**
- * @tests java.lang.Math#atan(double)
- */
- @SmallTest
- public void testAtanD() {
- // Test for method double java.lang.Math.atan(double)
- double answer = Math.tan(Math.atan(1.0));
- assertTrue("Returned incorrect arc tangent: " + answer, answer <= 1.0
- && answer >= 9.9999999999999983E-1);
- }
-
- /**
- * @tests java.lang.Math#atan2(double, double)
- */
- @SmallTest
- public void testAtan2DD() {
- // Test for method double java.lang.Math.atan2(double, double)
- double answer = Math.atan(Math.tan(1.0));
- assertTrue("Returned incorrect arc tangent: " + answer, answer <= 1.0
- && answer >= 9.9999999999999983E-1);
- }
-
- /**
- * @tests java.lang.Math#cbrt(double)
- */
- @SmallTest
- public void testCbrtD() {
- //Test for special situations
- assertTrue("Should return Double.NaN", Double.isNaN(Math
- .cbrt(Double.NaN)));
- assertEquals("Should return Double.POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math
- .cbrt(Double.POSITIVE_INFINITY), 0D);
- assertEquals("Should return Double.NEGATIVE_INFINITY",
- Double.NEGATIVE_INFINITY, Math
- .cbrt(Double.NEGATIVE_INFINITY), 0D);
- assertEquals(Double.doubleToLongBits(0.0), Double.doubleToLongBits(Math
- .cbrt(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double.doubleToLongBits(Math
- .cbrt(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double.doubleToLongBits(Math
- .cbrt(-0.0)));
-
- assertEquals("Should return 3.0", 3.0, Math.cbrt(27.0), 0D);
- assertEquals("Should return 23.111993172558684", 23.111993172558684,
- Math.cbrt(12345.6), 0D);
- assertEquals("Should return 5.643803094122362E102",
- 5.643803094122362E102, Math.cbrt(Double.MAX_VALUE), 0D);
- assertEquals("Should return 0.01", 0.01, Math.cbrt(0.000001), 0D);
-
- assertEquals("Should return -3.0", -3.0, Math.cbrt(-27.0), 0D);
- assertEquals("Should return -23.111993172558684", -23.111993172558684,
- Math.cbrt(-12345.6), 0D);
- assertEquals("Should return 1.7031839360032603E-108",
- 1.7031839360032603E-108, Math.cbrt(Double.MIN_VALUE), 0D);
- assertEquals("Should return -0.01", -0.01, Math.cbrt(-0.000001), 0D);
- }
-
- /**
- * @tests java.lang.Math#ceil(double)
- */
- @SmallTest
- public void testCeilD() {
- // Test for method double java.lang.Math.ceil(double)
- assertEquals("Incorrect ceiling for double",
- 79, Math.ceil(78.89), 0);
- assertEquals("Incorrect ceiling for double",
- -78, Math.ceil(-78.89), 0);
- }
-
- /**
- * @tests java.lang.Math#cos(double)
- */
- @SmallTest
- public void testCosD() {
- // Test for method double java.lang.Math.cos(double)
- assertEquals("Incorrect answer", 1.0, Math.cos(0), 0D);
- assertEquals("Incorrect answer", 0.5403023058681398, Math.cos(1), 0D);
- }
-
- /**
- * @tests java.lang.Math#cosh(double)
- */
- @SmallTest
- public void testCoshD() {
- // Test for special situations
- assertTrue(Double.isNaN(Math.cosh(Double.NaN)));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.cosh(Double.POSITIVE_INFINITY), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.cosh(Double.NEGATIVE_INFINITY), 0D);
- assertEquals("Should return 1.0", 1.0, Math.cosh(+0.0), 0D);
- assertEquals("Should return 1.0", 1.0, Math.cosh(-0.0), 0D);
-
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.cosh(1234.56), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.cosh(-1234.56), 0D);
- assertEquals("Should return 1.0000000000005", 1.0000000000005, Math
- .cosh(0.000001), 0D);
- assertEquals("Should return 1.0000000000005", 1.0000000000005, Math
- .cosh(-0.000001), 0D);
- assertEquals("Should return 5.212214351945598", 5.212214351945598, Math
- .cosh(2.33482), 0D);
-
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.cosh(Double.MAX_VALUE), 0D);
- assertEquals("Should return 1.0", 1.0, Math.cosh(Double.MIN_VALUE), 0D);
- }
-
- /**
- * @tests java.lang.Math#exp(double)
- */
- @SmallTest
- public void testExpD() {
- // Test for method double java.lang.Math.exp(double)
- assertTrue("Incorrect answer returned for simple power", Math.abs(Math
- .exp(4D)
- - Math.E * Math.E * Math.E * Math.E) < 0.1D);
- assertTrue("Incorrect answer returned for larger power", Math.log(Math
- .abs(Math.exp(5.5D)) - 5.5D) < 10.0D);
- }
-
- /**
- * @tests java.lang.Math#expm1(double)
- */
- @SmallTest
- public void testExpm1D() {
- // Test for special cases
- assertTrue("Should return NaN", Double.isNaN(Math.expm1(Double.NaN)));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.expm1(Double.POSITIVE_INFINITY), 0D);
- assertEquals("Should return -1.0", -1.0, Math
- .expm1(Double.NEGATIVE_INFINITY), 0D);
- assertEquals(Double.doubleToLongBits(0.0), Double.doubleToLongBits(Math
- .expm1(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(Math.expm1(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(Math.expm1(-0.0)));
-
- assertEquals("Should return -9.999950000166666E-6",
- -9.999950000166666E-6, Math.expm1(-0.00001), 0D);
- assertEquals("Should return 1.0145103074469635E60",
- 1.0145103074469635E60, Math.expm1(138.16951162), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math
- .expm1(123456789123456789123456789.4521584223), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.expm1(Double.MAX_VALUE), 0D);
- assertEquals("Should return MIN_VALUE", Double.MIN_VALUE, Math
- .expm1(Double.MIN_VALUE), 0D);
- }
-
- /**
- * @tests java.lang.Math#floor(double)
- */
- @SmallTest
- public void testFloorD() {
- // Test for method double java.lang.Math.floor(double)
- assertEquals("Incorrect floor for double",
- 78, Math.floor(78.89), 0);
- assertEquals("Incorrect floor for double",
- -79, Math.floor(-78.89), 0);
- }
-
- /**
- * @tests java.lang.Math#hypot(double, double)
- */
- @SmallTest
- public void testHypotDD() {
- // Test for special cases
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.hypot(Double.POSITIVE_INFINITY,
- 1.0), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.hypot(Double.NEGATIVE_INFINITY,
- 123.324), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.hypot(-758.2587,
- Double.POSITIVE_INFINITY), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.hypot(5687.21,
- Double.NEGATIVE_INFINITY), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.hypot(Double.POSITIVE_INFINITY,
- Double.NEGATIVE_INFINITY), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.hypot(Double.NEGATIVE_INFINITY,
- Double.POSITIVE_INFINITY), 0D);
- assertTrue("Should be NaN", Double.isNaN(Math.hypot(Double.NaN,
- 2342301.89843)));
- assertTrue("Should be NaN", Double.isNaN(Math.hypot(-345.2680,
- Double.NaN)));
-
- assertEquals("Should return 2396424.905416697", 2396424.905416697, Math
- .hypot(12322.12, -2396393.2258), 0D);
- assertEquals("Should return 138.16958070558556", 138.16958070558556,
- Math.hypot(-138.16951162, 0.13817035864), 0D);
- assertEquals("Should return 1.7976931348623157E308",
- 1.7976931348623157E308, Math.hypot(Double.MAX_VALUE, 211370.35), 0D);
- assertEquals("Should return 5413.7185", 5413.7185, Math.hypot(
- -5413.7185, Double.MIN_VALUE), 0D);
- }
-
- /**
- * @tests java.lang.Math#IEEEremainder(double, double)
- */
- @SmallTest
- public void testIEEEremainderDD() {
- // Test for method double java.lang.Math.IEEEremainder(double, double)
- assertEquals("Incorrect remainder returned",
- 0.0, Math.IEEEremainder(1.0, 1.0), 0D);
- assertTrue("Incorrect remainder returned", Math.IEEEremainder(1.32,
- 89.765) >= 1.4705063220631647E-2
- || Math.IEEEremainder(1.32, 89.765) >= 1.4705063220631649E-2);
- }
-
- /**
- * @tests java.lang.Math#log(double)
- */
- @SmallTest
- public void testLogD() {
- // Test for method double java.lang.Math.log(double)
- for (double d = 10; d >= -10; d -= 0.5) {
- double answer = Math.log(Math.exp(d));
- assertTrue("Answer does not equal expected answer for d = " + d
- + " answer = " + answer, Math.abs(answer - d) <= Math
- .abs(d * 0.00000001));
- }
- }
-
- /**
- * @tests java.lang.Math#log10(double)
- */
- @SuppressWarnings("boxing")
- @SmallTest
- public void testLog10D() {
- // Test for special cases
- assertTrue(Double.isNaN(Math.log10(Double.NaN)));
- assertTrue(Double.isNaN(Math.log10(-2541.05745687234187532)));
- assertTrue(Double.isNaN(Math.log10(-0.1)));
- assertEquals(Double.POSITIVE_INFINITY, Math.log10(Double.POSITIVE_INFINITY));
- assertEquals(Double.NEGATIVE_INFINITY, Math.log10(0.0));
- assertEquals(Double.NEGATIVE_INFINITY, Math.log10(+0.0));
- assertEquals(Double.NEGATIVE_INFINITY, Math.log10(-0.0));
-
- assertEquals(3.0, Math.log10(1000.0));
- assertEquals(14.0, Math.log10(Math.pow(10, 14)));
- assertEquals(3.7389561269540406, Math.log10(5482.2158));
- assertEquals(14.661551142893833, Math.log10(458723662312872.125782332587));
- assertEquals(-0.9083828622192334, Math.log10(0.12348583358871));
- assertEquals(308.25471555991675, Math.log10(Double.MAX_VALUE));
- assertEquals(-323.3062153431158, Math.log10(Double.MIN_VALUE));
- }
-
- /**
- * @tests java.lang.Math#log1p(double)
- */
- @SmallTest
- public void testLog1pD() {
- // Test for special cases
- assertTrue("Should return NaN", Double.isNaN(Math.log1p(Double.NaN)));
- assertTrue("Should return NaN", Double.isNaN(Math.log1p(-32.0482175)));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.log1p(Double.POSITIVE_INFINITY), 0D);
- assertEquals(Double.doubleToLongBits(0.0), Double.doubleToLongBits(Math
- .log1p(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(Math.log1p(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(Math.log1p(-0.0)));
-
- assertEquals("Should return -0.2941782295312541", -0.2941782295312541,
- Math.log1p(-0.254856327), 0D);
- assertEquals("Should return 7.368050685564151", 7.368050685564151, Math
- .log1p(1583.542), 0D);
- assertEquals("Should return 0.4633708685409921", 0.4633708685409921,
- Math.log1p(0.5894227), 0D);
- assertEquals("Should return 709.782712893384", 709.782712893384, Math
- .log1p(Double.MAX_VALUE), 0D);
- assertEquals("Should return Double.MIN_VALUE", Double.MIN_VALUE, Math
- .log1p(Double.MIN_VALUE), 0D);
- }
-
- /**
- * @tests java.lang.Math#max(double, double)
- */
- @SmallTest
- public void testMaxDD() {
- // Test for method double java.lang.Math.max(double, double)
- assertEquals("Incorrect double max value", 1908897.6000089, Math.max(-1908897.6000089,
- 1908897.6000089), 0D);
- assertEquals("Incorrect double max value",
- 1908897.6000089, Math.max(2.0, 1908897.6000089), 0D);
- assertEquals("Incorrect double max value", -2.0, Math.max(-2.0,
- -1908897.6000089), 0D);
-
- }
-
- /**
- * @tests java.lang.Math#max(float, float)
- */
- @SmallTest
- public void testMaxFF() {
- // Test for method float java.lang.Math.max(float, float)
- assertTrue("Incorrect float max value", Math.max(-1908897.600f,
- 1908897.600f) == 1908897.600f);
- assertTrue("Incorrect float max value",
- Math.max(2.0f, 1908897.600f) == 1908897.600f);
- assertTrue("Incorrect float max value",
- Math.max(-2.0f, -1908897.600f) == -2.0f);
- }
-
- /**
- * @tests java.lang.Math#max(int, int)
- */
- @SmallTest
- public void testMaxII() {
- // Test for method int java.lang.Math.max(int, int)
- assertEquals("Incorrect int max value",
- 19088976, Math.max(-19088976, 19088976));
- assertEquals("Incorrect int max value",
- 19088976, Math.max(20, 19088976));
- assertEquals("Incorrect int max value", -20, Math.max(-20, -19088976));
- }
-
- /**
- * @tests java.lang.Math#max(long, long)
- */
- @SmallTest
- public void testMaxJJ() {
- // Test for method long java.lang.Math.max(long, long)
- assertEquals("Incorrect long max value", 19088976000089L, Math.max(-19088976000089L,
- 19088976000089L));
- assertEquals("Incorrect long max value",
- 19088976000089L, Math.max(20, 19088976000089L));
- assertEquals("Incorrect long max value",
- -20, Math.max(-20, -19088976000089L));
- }
-
- /**
- * @tests java.lang.Math#min(double, double)
- */
- @SmallTest
- public void testMinDD() {
- // Test for method double java.lang.Math.min(double, double)
- assertEquals("Incorrect double min value", -1908897.6000089, Math.min(-1908897.6000089,
- 1908897.6000089), 0D);
- assertEquals("Incorrect double min value",
- 2.0, Math.min(2.0, 1908897.6000089), 0D);
- assertEquals("Incorrect double min value", -1908897.6000089, Math.min(-2.0,
- -1908897.6000089), 0D);
- }
-
- /**
- * @tests java.lang.Math#min(float, float)
- */
- @SmallTest
- public void testMinFF() {
- // Test for method float java.lang.Math.min(float, float)
- assertTrue("Incorrect float min value", Math.min(-1908897.600f,
- 1908897.600f) == -1908897.600f);
- assertTrue("Incorrect float min value",
- Math.min(2.0f, 1908897.600f) == 2.0f);
- assertTrue("Incorrect float min value",
- Math.min(-2.0f, -1908897.600f) == -1908897.600f);
- }
-
- /**
- * @tests java.lang.Math#min(int, int)
- */
- @SmallTest
- public void testMinII() {
- // Test for method int java.lang.Math.min(int, int)
- assertEquals("Incorrect int min value",
- -19088976, Math.min(-19088976, 19088976));
- assertEquals("Incorrect int min value", 20, Math.min(20, 19088976));
- assertEquals("Incorrect int min value",
- -19088976, Math.min(-20, -19088976));
-
- }
-
- /**
- * @tests java.lang.Math#min(long, long)
- */
- @SmallTest
- public void testMinJJ() {
- // Test for method long java.lang.Math.min(long, long)
- assertEquals("Incorrect long min value", -19088976000089L, Math.min(-19088976000089L,
- 19088976000089L));
- assertEquals("Incorrect long min value",
- 20, Math.min(20, 19088976000089L));
- assertEquals("Incorrect long min value",
- -19088976000089L, Math.min(-20, -19088976000089L));
- }
-
- /**
- * @tests java.lang.Math#pow(double, double)
- */
- @SmallTest
- public void testPowDD() {
- // Test for method double java.lang.Math.pow(double, double)
- assertTrue("pow returned incorrect value",
- (long) Math.pow(2, 8) == 256l);
- assertTrue("pow returned incorrect value",
- Math.pow(2, -8) == 0.00390625d);
- assertEquals("Incorrect root returned1",
- 2, Math.sqrt(Math.pow(Math.sqrt(2), 4)), 0);
- }
-
- /**
- * @tests java.lang.Math#rint(double)
- */
- @SmallTest
- public void testRintD() {
- // Test for method double java.lang.Math.rint(double)
- assertEquals("Failed to round properly - up to odd",
- 3.0, Math.rint(2.9), 0D);
- assertTrue("Failed to round properly - NaN", Double.isNaN(Math
- .rint(Double.NaN)));
- assertEquals("Failed to round properly down to even",
- 2.0, Math.rint(2.1), 0D);
- assertTrue("Failed to round properly " + 2.5 + " to even", Math
- .rint(2.5) == 2.0);
- }
-
- /**
- * @tests java.lang.Math#round(double)
- */
- @SmallTest
- public void testRoundD() {
- // Test for method long java.lang.Math.round(double)
- assertEquals("Incorrect rounding of a float", -91, Math.round(-90.89d));
- }
-
- /**
- * @tests java.lang.Math#round(float)
- */
- @SmallTest
- public void testRoundF() {
- // Test for method int java.lang.Math.round(float)
- assertEquals("Incorrect rounding of a float", -91, Math.round(-90.89f));
- }
-
- /**
- * @tests java.lang.Math#signum(double)
- */
- @SmallTest
- public void testSignumD() {
- assertTrue(Double.isNaN(Math.signum(Double.NaN)));
- assertTrue(Double.isNaN(Math.signum(Double.NaN)));
- assertEquals(Double.doubleToLongBits(0.0), Double.doubleToLongBits(Math
- .signum(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(Math.signum(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(Math.signum(-0.0)));
-
- assertEquals(1.0, Math.signum(253681.2187962), 0D);
- assertEquals(-1.0, Math.signum(-125874693.56), 0D);
- assertEquals(1.0, Math.signum(1.2587E-308), 0D);
- assertEquals(-1.0, Math.signum(-1.2587E-308), 0D);
-
- assertEquals(1.0, Math.signum(Double.MAX_VALUE), 0D);
- assertEquals(1.0, Math.signum(Double.MIN_VALUE), 0D);
- assertEquals(-1.0, Math.signum(-Double.MAX_VALUE), 0D);
- assertEquals(-1.0, Math.signum(-Double.MIN_VALUE), 0D);
- assertEquals(1.0, Math.signum(Double.POSITIVE_INFINITY), 0D);
- assertEquals(-1.0, Math.signum(Double.NEGATIVE_INFINITY), 0D);
- }
-
- /**
- * @tests java.lang.Math#signum(float)
- */
- @SmallTest
- public void testSignumF() {
- assertTrue(Float.isNaN(Math.signum(Float.NaN)));
- assertEquals(Float.floatToIntBits(0.0f), Float
- .floatToIntBits(Math.signum(0.0f)));
- assertEquals(Float.floatToIntBits(+0.0f), Float
- .floatToIntBits(Math.signum(+0.0f)));
- assertEquals(Float.floatToIntBits(-0.0f), Float
- .floatToIntBits(Math.signum(-0.0f)));
-
- assertEquals(1.0f, Math.signum(253681.2187962f), 0f);
- assertEquals(-1.0f, Math.signum(-125874693.56f), 0f);
- assertEquals(1.0f, Math.signum(1.2587E-11f), 0f);
- assertEquals(-1.0f, Math.signum(-1.2587E-11f), 0f);
-
- assertEquals(1.0f, Math.signum(Float.MAX_VALUE), 0f);
- assertEquals(1.0f, Math.signum(Float.MIN_VALUE), 0f);
- assertEquals(-1.0f, Math.signum(-Float.MAX_VALUE), 0f);
- assertEquals(-1.0f, Math.signum(-Float.MIN_VALUE), 0f);
- assertEquals(1.0f, Math.signum(Float.POSITIVE_INFINITY), 0f);
- assertEquals(-1.0f, Math.signum(Float.NEGATIVE_INFINITY), 0f);
- }
-
- /**
- * @tests java.lang.Math#sin(double)
- */
- @SmallTest
- public void testSinD() {
- // Test for method double java.lang.Math.sin(double)
- assertEquals("Incorrect answer", 0.0, Math.sin(0), 0D);
- assertEquals("Incorrect answer", 0.8414709848078965, Math.sin(1), 0D);
- }
-
- /**
- * @tests java.lang.Math#sinh(double)
- */
- @SmallTest
- public void testSinhD() {
- // Test for special situations
- assertTrue("Should return NaN", Double.isNaN(Math.sinh(Double.NaN)));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.sinh(Double.POSITIVE_INFINITY), 0D);
- assertEquals("Should return NEGATIVE_INFINITY",
- Double.NEGATIVE_INFINITY, Math.sinh(Double.NEGATIVE_INFINITY), 0D);
- assertEquals(Double.doubleToLongBits(0.0), Double.doubleToLongBits(Math
- .sinh(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(Math.sinh(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(Math.sinh(-0.0)));
-
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.sinh(1234.56), 0D);
- assertEquals("Should return NEGATIVE_INFINITY",
- Double.NEGATIVE_INFINITY, Math.sinh(-1234.56), 0D);
- assertEquals("Should return 1.0000000000001666E-6",
- 1.0000000000001666E-6, Math.sinh(0.000001), 0D);
- assertEquals("Should return -1.0000000000001666E-6",
- -1.0000000000001666E-6, Math.sinh(-0.000001), 0D);
- assertEquals("Should return 5.115386441963859", 5.115386441963859, Math
- .sinh(2.33482), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, Math.sinh(Double.MAX_VALUE), 0D);
- assertEquals("Should return 4.9E-324", 4.9E-324, Math
- .sinh(Double.MIN_VALUE), 0D);
- }
-
- /**
- * @tests java.lang.Math#sqrt(double)
- */
- @SmallTest
- public void testSqrtD() {
- // Test for method double java.lang.Math.sqrt(double)
- assertEquals("Incorrect root returned2", 7, Math.sqrt(49), 0);
- }
-
- /**
- * @tests java.lang.Math#tan(double)
- */
- @SmallTest
- public void testTanD() {
- // Test for method double java.lang.Math.tan(double)
- assertEquals("Incorrect answer", 0.0, Math.tan(0), 0D);
- assertEquals("Incorrect answer", 1.5574077246549023, Math.tan(1), 0D);
-
- }
-
- /**
- * @tests java.lang.Math#tanh(double)
- */
- @SmallTest
- public void testTanhD() {
- // Test for special situations
- assertTrue("Should return NaN", Double.isNaN(Math.tanh(Double.NaN)));
- assertEquals("Should return +1.0", +1.0, Math
- .tanh(Double.POSITIVE_INFINITY), 0D);
- assertEquals("Should return -1.0", -1.0, Math
- .tanh(Double.NEGATIVE_INFINITY), 0D);
- assertEquals(Double.doubleToLongBits(0.0), Double.doubleToLongBits(Math
- .tanh(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(Math.tanh(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(Math.tanh(-0.0)));
-
- assertEquals("Should return 1.0", 1.0, Math.tanh(1234.56), 0D);
- assertEquals("Should return -1.0", -1.0, Math.tanh(-1234.56), 0D);
- assertEquals("Should return 9.999999999996666E-7",
- 9.999999999996666E-7, Math.tanh(0.000001), 0D);
- assertEquals("Should return 0.981422884124941", 0.981422884124941, Math
- .tanh(2.33482), 0D);
- assertEquals("Should return 1.0", 1.0, Math.tanh(Double.MAX_VALUE), 0D);
- assertEquals("Should return 4.9E-324", 4.9E-324, Math
- .tanh(Double.MIN_VALUE), 0D);
- }
-
- /**
- * @tests java.lang.Math#random()
- */
- @MediumTest
- public void testRandom() {
- // There isn't a place for these tests so just stick them here
- assertEquals("Wrong value E",
- 4613303445314885481L, Double.doubleToLongBits(Math.E));
- assertEquals("Wrong value PI",
- 4614256656552045848L, Double.doubleToLongBits(Math.PI));
-
- for (int i = 500; i >= 0; i--) {
- double d = Math.random();
- assertTrue("Generated number is out of range: " + d, d >= 0.0
- && d < 1.0);
- }
- }
-
- /**
- * @tests java.lang.Math#toRadians(double)
- */
- @MediumTest
- public void testToRadiansD() {
- for (double d = 500; d >= 0; d -= 1.0) {
- double converted = Math.toDegrees(Math.toRadians(d));
- assertTrue("Converted number not equal to original. d = " + d,
- converted >= d * 0.99999999 && converted <= d * 1.00000001);
- }
- }
-
- /**
- * @tests java.lang.Math#toDegrees(double)
- */
- @MediumTest
- public void testToDegreesD() {
- for (double d = 500; d >= 0; d -= 1.0) {
- double converted = Math.toRadians(Math.toDegrees(d));
- assertTrue("Converted number not equal to original. d = " + d,
- converted >= d * 0.99999999 && converted <= d * 1.00000001);
- }
- }
-
- /**
- * @tests java.lang.Math#ulp(double)
- */
- @SuppressWarnings("boxing")
- @SmallTest
- public void testUlpD() {
- // Test for special cases
- assertTrue("Should return NaN", Double.isNaN(Math.ulp(Double.NaN)));
- assertEquals("Returned incorrect value", Double.POSITIVE_INFINITY, Math
- .ulp(Double.POSITIVE_INFINITY), 0D);
- assertEquals("Returned incorrect value", Double.POSITIVE_INFINITY, Math
- .ulp(Double.NEGATIVE_INFINITY), 0D);
- assertEquals("Returned incorrect value", Double.MIN_VALUE, Math
- .ulp(0.0), 0D);
- assertEquals("Returned incorrect value", Double.MIN_VALUE, Math
- .ulp(+0.0), 0D);
- assertEquals("Returned incorrect value", Double.MIN_VALUE, Math
- .ulp(-0.0), 0D);
- assertEquals("Returned incorrect value", Math.pow(2, 971), Math
- .ulp(Double.MAX_VALUE), 0D);
- assertEquals("Returned incorrect value", Math.pow(2, 971), Math
- .ulp(-Double.MAX_VALUE), 0D);
-
- assertEquals("Returned incorrect value", Double.MIN_VALUE, Math
- .ulp(Double.MIN_VALUE), 0D);
- assertEquals("Returned incorrect value", Double.MIN_VALUE, Math
- .ulp(-Double.MIN_VALUE), 0D);
-
- assertEquals("Returned incorrect value", 2.220446049250313E-16, Math
- .ulp(1.0), 0D);
- assertEquals("Returned incorrect value", 2.220446049250313E-16, Math
- .ulp(-1.0), 0D);
- assertEquals("Returned incorrect value", 2.2737367544323206E-13, Math
- .ulp(1153.0), 0D);
- }
-
- /**
- * @tests java.lang.Math#ulp(float)
- */
- @SuppressWarnings("boxing")
- @SmallTest
- public void testUlpf() {
- // Test for special cases
- assertTrue("Should return NaN", Float.isNaN(Math.ulp(Float.NaN)));
- assertEquals("Returned incorrect value", Float.POSITIVE_INFINITY, Math
- .ulp(Float.POSITIVE_INFINITY), 0f);
- assertEquals("Returned incorrect value", Float.POSITIVE_INFINITY, Math
- .ulp(Float.NEGATIVE_INFINITY), 0f);
- assertEquals("Returned incorrect value", Float.MIN_VALUE, Math
- .ulp(0.0f), 0f);
- assertEquals("Returned incorrect value", Float.MIN_VALUE, Math
- .ulp(+0.0f), 0f);
- assertEquals("Returned incorrect value", Float.MIN_VALUE, Math
- .ulp(-0.0f), 0f);
- assertEquals("Returned incorrect value", 2.028241E31f, Math
- .ulp(Float.MAX_VALUE), 0f);
- assertEquals("Returned incorrect value", 2.028241E31f, Math
- .ulp(-Float.MAX_VALUE), 0f);
-
- assertEquals("Returned incorrect value", 1.4E-45f, Math
- .ulp(Float.MIN_VALUE), 0f);
- assertEquals("Returned incorrect value", 1.4E-45f, Math
- .ulp(-Float.MIN_VALUE), 0f);
-
- assertEquals("Returned incorrect value", 1.1920929E-7f, Math.ulp(1.0f),
- 0f);
- assertEquals("Returned incorrect value", 1.1920929E-7f,
- Math.ulp(-1.0f), 0f);
- assertEquals("Returned incorrect value", 1.2207031E-4f, Math
- .ulp(1153.0f), 0f);
- assertEquals("Returned incorrect value", 5.6E-45f, Math
- .ulp(9.403954E-38f), 0f);
- }
-}
diff --git a/tests/CoreTests/android/core/MonitorTest.java b/tests/CoreTests/android/core/MonitorTest.java
deleted file mode 100644
index 73c33db..0000000
--- a/tests/CoreTests/android/core/MonitorTest.java
+++ /dev/null
@@ -1,469 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.test.suitebuilder.annotation.SmallTest;
-
-public class MonitorTest extends TestCase {
-
- @MediumTest
- public void testWaitArgumentsTest() throws Exception {
- /* Try some valid arguments. These should all
- * return very quickly.
- */
- try {
- synchronized (this) {
- /* millisecond version */
- wait(1);
- wait(10);
-
- /* millisecond + nanosecond version */
- wait(0, 1);
- wait(0, 999999);
- wait(1, 1);
- wait(1, 999999);
- }
- } catch (InterruptedException ex) {
- throw new RuntimeException("good Object.wait() interrupted",
- ex);
- } catch (Exception ex) {
- throw new RuntimeException("Unexpected exception when calling" +
- "Object.wait() with good arguments", ex);
- }
-
- /* Try some invalid arguments.
- */
- boolean sawException = false;
- try {
- synchronized (this) {
- wait(-1);
- }
- } catch (InterruptedException ex) {
- throw new RuntimeException("bad Object.wait() interrupted", ex);
- } catch (IllegalArgumentException ex) {
- sawException = true;
- } catch (Exception ex) {
- throw new RuntimeException("Unexpected exception when calling" +
- "Object.wait() with bad arguments", ex);
- }
- if (!sawException) {
- throw new RuntimeException("bad call to Object.wait() should " +
- "have thrown IllegalArgumentException");
- }
-
- sawException = false;
- try {
- synchronized (this) {
- wait(0, -1);
- }
- } catch (InterruptedException ex) {
- throw new RuntimeException("bad Object.wait() interrupted", ex);
- } catch (IllegalArgumentException ex) {
- sawException = true;
- } catch (Exception ex) {
- throw new RuntimeException("Unexpected exception when calling" +
- "Object.wait() with bad arguments", ex);
- }
- if (!sawException) {
- throw new RuntimeException("bad call to Object.wait() should " +
- "have thrown IllegalArgumentException");
- }
-
- sawException = false;
- try {
- synchronized (this) {
- /* The legal range of nanos is 0-999999. */
- wait(0, 1000000);
- }
- } catch (InterruptedException ex) {
- throw new RuntimeException("bad Object.wait() interrupted", ex);
- } catch (IllegalArgumentException ex) {
- sawException = true;
- } catch (Exception ex) {
- throw new RuntimeException("Unexpected exception when calling" +
- "Object.wait() with bad arguments", ex);
- }
- if (!sawException) {
- throw new RuntimeException("bad call to Object.wait() should " +
- "have thrown IllegalArgumentException");
- }
- }
-
- private class Interrupter extends Thread {
- Waiter waiter;
-
- Interrupter(String name, Waiter waiter) {
- super(name);
- this.waiter = waiter;
- }
-
- public void run() {
- try {
- run_inner();
- } catch (Throwable t) {
- MonitorTest.errorException = t;
- MonitorTest.testThread.interrupt();
- }
- }
-
- void run_inner() {
- waiter.spin = true;
- // System.out.println("InterruptTest: starting waiter");
- waiter.start();
-
- try {
- Thread.currentThread().sleep(500);
- } catch (InterruptedException ex) {
- throw new RuntimeException("Test sleep interrupted.", ex);
- }
-
- /* Waiter is spinning, and its monitor should still be thin.
- */
- // System.out.println("Test interrupting waiter");
- waiter.interrupt();
- waiter.spin = false;
-
- for (int i = 0; i < 3; i++) {
- /* Wait for the waiter to start waiting.
- */
- synchronized (waiter.interrupterLock) {
- try {
- waiter.interrupterLock.wait();
- } catch (InterruptedException ex) {
- throw new RuntimeException("Test wait interrupted.", ex);
- }
- }
-
- /* Before interrupting, grab the waiter lock, which
- * guarantees that the waiter is already sitting in wait().
- */
- synchronized (waiter) {
- //System.out.println("Test interrupting waiter (" + i + ")");
- waiter.interrupt();
- }
- }
-
- // System.out.println("Test waiting for waiter to die.");
- try {
- waiter.join();
- } catch (InterruptedException ex) {
- throw new RuntimeException("Test join interrupted.", ex);
- }
- // System.out.println("InterruptTest done.");
- }
- }
-
- private class Waiter extends Thread {
- Object interrupterLock = new Object();
- Boolean spin = false;
-
- Waiter(String name) {
- super(name);
- }
-
- public void run() {
- try {
- run_inner();
- } catch (Throwable t) {
- MonitorTest.errorException = t;
- MonitorTest.testThread.interrupt();
- }
- }
-
- void run_inner() {
- // System.out.println("Waiter spinning");
- while (spin) {
- // We're going to get interrupted while we spin.
- }
- if (interrupted()) {
- // System.out.println("Waiter done spinning; interrupted.");
- } else {
- throw new RuntimeException("Thread not interrupted " +
- "during spin");
- }
-
- synchronized (this) {
- Boolean sawEx = false;
-
- try {
- synchronized (interrupterLock) {
- interrupterLock.notify();
- }
- // System.out.println("Waiter calling wait()");
- this.wait();
- } catch (InterruptedException ex) {
- sawEx = true;
- // System.out.println("wait(): Waiter caught " + ex);
- }
- // System.out.println("wait() finished");
-
- if (!sawEx) {
- throw new RuntimeException("Thread not interrupted " +
- "during wait()");
- }
- }
- synchronized (this) {
- Boolean sawEx = false;
-
- try {
- synchronized (interrupterLock) {
- interrupterLock.notify();
- }
- // System.out.println("Waiter calling wait(1000)");
- this.wait(1000);
- } catch (InterruptedException ex) {
- sawEx = true;
- // System.out.println("wait(1000): Waiter caught " + ex);
- }
- // System.out.println("wait(1000) finished");
-
- if (!sawEx) {
- throw new RuntimeException("Thread not interrupted " +
- "during wait(1000)");
- }
- }
- synchronized (this) {
- Boolean sawEx = false;
-
- try {
- synchronized (interrupterLock) {
- interrupterLock.notify();
- }
- // System.out.println("Waiter calling wait(1000, 5000)");
- this.wait(1000, 5000);
- } catch (InterruptedException ex) {
- sawEx = true;
- // System.out.println("wait(1000, 5000): Waiter caught " + ex);
- }
- // System.out.println("wait(1000, 5000) finished");
-
- if (!sawEx) {
- throw new RuntimeException("Thread not interrupted " +
- "during wait(1000, 5000)");
- }
- }
-
- // System.out.println("Waiter returning");
- }
- }
-
- private static Throwable errorException;
- private static Thread testThread;
-
- // TODO: Flaky test. Add back MediumTest annotation once fixed
- public void testInterruptTest() throws Exception {
-
-
- testThread = Thread.currentThread();
- errorException = null;
-
- Waiter waiter = new Waiter("InterruptTest Waiter");
- Interrupter interrupter =
- new Interrupter("InterruptTest Interrupter", waiter);
- interrupter.start();
-
- try {
- interrupter.join();
- waiter.join();
- } catch (InterruptedException ex) {
- throw new RuntimeException("Test join interrupted.", ex);
- }
-
- if (errorException != null) {
- throw new RuntimeException("InterruptTest failed",
- errorException);
- }
-
-
-
-
- }
-
- private static void deepWait(int depth, Object lock) {
- synchronized (lock) {
- if (depth > 0) {
- deepWait(depth - 1, lock);
- } else {
- String threadName = Thread.currentThread().getName();
- try {
- // System.out.println(threadName + " waiting");
- lock.wait();
- // System.out.println(threadName + " done waiting");
- } catch (InterruptedException ex) {
- // System.out.println(threadName + " interrupted.");
- }
- }
- }
- }
-
- private class Worker extends Thread {
- Object lock;
- int id;
-
- Worker(int id, Object lock) {
- super("Worker(" + id + ")");
- this.id = id;
- this.lock = lock;
- }
-
- public void run() {
- int iterations = 0;
-
- while (MonitorTest.running) {
- MonitorTest.deepWait(id, lock);
- iterations++;
- }
- // System.out.println(getName() + " done after " + iterations + " iterations.");
- }
- }
-
- private static Object commonLock = new Object();
- private static Boolean running = false;
-
-
- @LargeTest
- public void testNestedMonitors() throws Exception {
- final int NUM_WORKERS = 5;
-
- Worker w[] = new Worker[NUM_WORKERS];
- int i;
-
- for (i = 0; i < NUM_WORKERS; i++) {
- w[i] = new Worker(i * 2 - 1, new Object());
- }
-
- running = true;
-
- // System.out.println("NestedMonitors: starting workers");
- for (i = 0; i < NUM_WORKERS; i++) {
- w[i].start();
- }
-
- try {
- Thread.currentThread().sleep(1000);
- } catch (InterruptedException ex) {
- // System.out.println("Test sleep interrupted.");
- }
-
- for (i = 0; i < 100; i++) {
- for (int j = 0; j < NUM_WORKERS; j++) {
- synchronized (w[j].lock) {
- w[j].lock.notify();
- }
- }
- }
-
- // System.out.println("NesterMonitors: stopping workers");
- running = false;
- for (i = 0; i < NUM_WORKERS; i++) {
- synchronized (w[i].lock) {
- w[i].lock.notifyAll();
- }
- }
- }
-
- private static class CompareAndExchange extends Thread {
- static Object toggleLock = null;
- static int toggle = -1;
- static Boolean running = false;
-
- public void run() {
- toggleLock = new Object();
- toggle = -1;
-
- Worker w1 = new Worker(0, 1);
- Worker w2 = new Worker(2, 3);
- Worker w3 = new Worker(4, 5);
- Worker w4 = new Worker(6, 7);
-
- running = true;
-
- // System.out.println("CompareAndExchange: starting workers");
-
- w1.start();
- w2.start();
- w3.start();
- w4.start();
-
- try {
- this.sleep(10000);
- } catch (InterruptedException ex) {
- // System.out.println(getName() + " interrupted.");
- }
-
- // System.out.println("MonitorTest: stopping workers");
- running = false;
-
- toggleLock = null;
- }
-
- class Worker extends Thread {
- int i1;
- int i2;
-
- Worker(int i1, int i2) {
- super("Worker(" + i1 + ", " + i2 + ")");
- this.i1 = i1;
- this.i2 = i2;
- }
-
- public void run() {
- int iterations = 0;
-
- /* Latch this because run() may set the static field to
- * null at some point.
- */
- Object toggleLock = CompareAndExchange.toggleLock;
-
- // System.out.println(getName() + " running");
- try {
- while (CompareAndExchange.running) {
- synchronized (toggleLock) {
- int test;
- int check;
-
- if (CompareAndExchange.toggle == i1) {
- this.sleep(5 + i2);
- CompareAndExchange.toggle = test = i2;
- } else {
- this.sleep(5 + i1);
- CompareAndExchange.toggle = test = i1;
- }
- if ((check = CompareAndExchange.toggle) != test) {
-// System.out.println("Worker(" + i1 + ", " +
-// i2 + ") " + "test " + test +
-// " != toggle " + check);
- throw new RuntimeException(
- "locked value changed");
- }
- }
-
- iterations++;
- }
- } catch (InterruptedException ex) {
- // System.out.println(getName() + " interrupted.");
- }
-
-// System.out.println(getName() + " done after " +
-// iterations + " iterations.");
- }
- }
- }
-}
diff --git a/tests/CoreTests/android/core/NIOTest.java b/tests/CoreTests/android/core/NIOTest.java
deleted file mode 100644
index 9476d07..0000000
--- a/tests/CoreTests/android/core/NIOTest.java
+++ /dev/null
@@ -1,707 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.nio.Buffer;
-import java.nio.BufferOverflowException;
-import java.nio.BufferUnderflowException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
-import java.nio.ShortBuffer;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Tests for some buffers from the java.nio package.
- */
-public class NIOTest extends TestCase {
-
- void checkBuffer(Buffer b) {
- assertTrue(0 <= b.position());
- assertTrue(b.position() <= b.limit());
- assertTrue(b.limit() <= b.capacity());
- }
-
- @SmallTest
- public void testNIO_byte_array() throws Exception {
- // Test byte array-based buffer
- byteBufferTest(ByteBuffer.allocate(12));
- }
-
- public void testNIO_direct() throws Exception {
- // Test native heap-allocated buffer
- byteBufferTest(ByteBuffer.allocateDirect(12));
- }
-
- public void testNIO_short_array() throws Exception {
- // Test short array-based buffer
- short[] shortArray = new short[8];
- ShortBuffer sb = ShortBuffer.wrap(shortArray);
- shortBufferTest(sb);
- }
-
- public void testNIO_int_array() throws Exception {
- // Test int array-based buffer
- int[] intArray = new int[8];
- IntBuffer ib = IntBuffer.wrap(intArray);
- intBufferTest(ib);
- }
-
- public void testNIO_float_array() throws Exception {
- // Test float array-based buffer
- float[] floatArray = new float[8];
- FloatBuffer fb = FloatBuffer.wrap(floatArray);
- floatBufferTest(fb);
- }
-
- private void byteBufferTest(ByteBuffer b) {
- checkBuffer(b);
-
- // Duplicate buffers revert to big-endian.
- b.order(ByteOrder.LITTLE_ENDIAN);
- ByteBuffer dupe = b.duplicate();
- assertEquals(ByteOrder.BIG_ENDIAN, dupe.order());
- b.order(ByteOrder.BIG_ENDIAN);
-
- // Bounds checks
- try {
- b.put(-1, (byte) 0);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- try {
- b.put(b.limit(), (byte) 0);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- // IndexOutOfBoundsException: offset < 0
- try {
- byte[] data = new byte[8];
- b.position(0);
- b.put(data, -1, 2);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- // IndexOutOfBoundsException: length > array.length - offset
- try {
- byte[] data = new byte[8];
- b.position(0);
- b.put(data, 1, 8);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- // BufferOverflowException: length > remaining()
- try {
- byte[] data = new byte[8];
- b.position(b.limit() - 2);
- b.put(data, 0, 3);
- fail("expected exception not thrown");
- } catch (BufferOverflowException e) {
- // expected
- }
-
- // Fill buffer with bytes A0 A1 A2 A3 ...
- b.position(0);
- for (int i = 0; i < b.capacity(); i++) {
- b.put((byte) (0xA0 + i));
- }
- try {
- b.put((byte) 0xFF);
- fail("expected exception not thrown");
- } catch (BufferOverflowException e) {
- // expected
- }
-
- b.position(0);
- assertEquals((byte) 0xA7, b.get(7));
- try {
- b.get(12);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
- try {
- b.get(-10);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- b.position(0);
- b.order(ByteOrder.LITTLE_ENDIAN);
- assertEquals((byte) 0xA0, b.get());
- assertEquals((byte) 0xA1, b.get());
- assertEquals((byte) 0xA2, b.get());
- assertEquals((byte) 0xA3, b.get());
- assertEquals((byte) 0xA4, b.get());
- assertEquals((byte) 0xA5, b.get());
- assertEquals((byte) 0xA6, b.get());
- assertEquals((byte) 0xA7, b.get());
- assertEquals((byte) 0xA8, b.get());
- assertEquals((byte) 0xA9, b.get());
- assertEquals((byte) 0xAA, b.get());
- assertEquals((byte) 0xAB, b.get());
- try {
- b.get();
- fail("expected exception not thrown");
- } catch (BufferUnderflowException e) {
- // expected
- }
-
- b.position(0);
- b.order(ByteOrder.BIG_ENDIAN);
- assertEquals((byte) 0xA0, b.get());
- assertEquals((byte) 0xA1, b.get());
- assertEquals((byte) 0xA2, b.get());
- assertEquals((byte) 0xA3, b.get());
- assertEquals((byte) 0xA4, b.get());
- assertEquals((byte) 0xA5, b.get());
- assertEquals((byte) 0xA6, b.get());
- assertEquals((byte) 0xA7, b.get());
- assertEquals((byte) 0xA8, b.get());
- assertEquals((byte) 0xA9, b.get());
- assertEquals((byte) 0xAA, b.get());
- assertEquals((byte) 0xAB, b.get());
- try {
- b.get();
- fail("expected exception not thrown");
- } catch (BufferUnderflowException e) {
- // expected
- }
-
- b.position(6);
- b.limit(10);
- assertEquals((byte) 0xA6, b.get());
-
- // Check sliced buffer
- b.position(6);
-
- ByteBuffer bb = b.slice();
- checkBuffer(bb);
-
- assertEquals(0, bb.position());
- assertEquals(4, bb.limit());
- assertEquals(4, bb.capacity());
-
- assertEquals((byte) 0xA6, bb.get());
- assertEquals((byte) 0xA7, bb.get());
- assertEquals((byte) 0xA8, bb.get());
- assertEquals((byte) 0xA9, bb.get());
- try {
- bb.get();
- fail("expected exception not thrown");
- } catch (BufferUnderflowException e) {
- // expected
- }
-
- // Reset position and limit
- b.position(0);
- b.limit(b.capacity());
-
- // Check 'getShort'
- b.order(ByteOrder.LITTLE_ENDIAN);
- b.position(0);
- assertEquals((short) 0xA1A0, b.getShort());
- assertEquals((short) 0xA3A2, b.getShort());
- assertEquals((short) 0xA5A4, b.getShort());
- assertEquals((short) 0xA7A6, b.getShort());
- assertEquals((short) 0xA9A8, b.getShort());
- assertEquals((short) 0xABAA, b.getShort());
- try {
- bb.getShort();
- fail("expected exception not thrown");
- } catch (BufferUnderflowException e) {
- // expected
- }
-
- b.order(ByteOrder.BIG_ENDIAN);
- b.position(0);
- assertEquals((short) 0xA0A1, b.getShort());
- assertEquals((short) 0xA2A3, b.getShort());
- assertEquals((short) 0xA4A5, b.getShort());
- assertEquals((short) 0xA6A7, b.getShort());
- assertEquals((short) 0xA8A9, b.getShort());
- assertEquals((short) 0xAAAB, b.getShort());
- try {
- bb.getShort();
- fail("expected exception not thrown");
- } catch (BufferUnderflowException e) {
- // expected
- }
-
- // Check 'getInt'
- b.order(ByteOrder.LITTLE_ENDIAN);
- b.position(0);
- assertEquals(0xA3A2A1A0, b.getInt());
- assertEquals(0xA7A6A5A4, b.getInt());
- assertEquals(0xABAAA9A8, b.getInt());
- try {
- bb.getInt();
- fail("expected exception not thrown");
- } catch (BufferUnderflowException e) {
- // expected
- }
-
- b.order(ByteOrder.BIG_ENDIAN);
- b.position(0);
- assertEquals(0xA0A1A2A3, b.getInt());
- assertEquals(0xA4A5A6A7, b.getInt());
- assertEquals(0xA8A9AAAB, b.getInt());
- try {
- bb.getInt();
- fail("expected exception not thrown");
- } catch (BufferUnderflowException e) {
- // expected
- }
-
- // Check 'getFloat'
- b.order(ByteOrder.LITTLE_ENDIAN);
- b.position(0);
- assertEquals(0xA3A2A1A0, Float.floatToRawIntBits(b.getFloat()));
- assertEquals(0xA7A6A5A4, Float.floatToRawIntBits(b.getFloat()));
- assertEquals(0xABAAA9A8, Float.floatToRawIntBits(b.getFloat()));
- try {
- b.getFloat();
- fail("expected exception not thrown");
- } catch (BufferUnderflowException e) {
- // expected
- }
-
- b.order(ByteOrder.BIG_ENDIAN);
- b.position(0);
- assertEquals(0xA0A1A2A3, Float.floatToRawIntBits(b.getFloat()));
- assertEquals(0xA4A5A6A7, Float.floatToRawIntBits(b.getFloat()));
- assertEquals(0xA8A9AAAB, Float.floatToRawIntBits(b.getFloat()));
- try {
- b.getFloat();
- fail("expected exception not thrown");
- } catch (BufferUnderflowException e) {
- // expected
- }
-
- // Check 'getDouble(int position)'
- b.order(ByteOrder.LITTLE_ENDIAN);
- assertEquals(0xA7A6A5A4A3A2A1A0L, Double.doubleToRawLongBits(b.getDouble(0)));
- assertEquals(0xA8A7A6A5A4A3A2A1L, Double.doubleToRawLongBits(b.getDouble(1)));
- try {
- b.getDouble(-1);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
- try {
- b.getDouble(5);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- b.order(ByteOrder.BIG_ENDIAN);
- assertEquals(0xA0A1A2A3A4A5A6A7L, Double.doubleToRawLongBits(b.getDouble(0)));
- assertEquals(0xA1A2A3A4A5A6A7A8L, Double.doubleToRawLongBits(b.getDouble(1)));
- try {
- b.getDouble(-1);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
- try {
- b.getDouble(5);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- // Slice and check 'getInt'
- b.position(1);
- b.limit(5);
- b.order(ByteOrder.LITTLE_ENDIAN);
- bb = b.slice();
- assertEquals(4, bb.capacity());
- assertEquals(ByteOrder.BIG_ENDIAN, bb.order());
- assertEquals(0xA1A2A3A4, bb.getInt(0));
- bb.order(ByteOrder.LITTLE_ENDIAN);
- assertEquals(0xA4A3A2A1, bb.getInt(0));
-
- bb.order(ByteOrder.LITTLE_ENDIAN);
- ShortBuffer sb = bb.asShortBuffer();
-
- checkBuffer(sb);
- assertEquals(2, sb.capacity());
- assertEquals((short) 0xA2A1, sb.get());
- assertEquals((short) 0xA4A3, sb.get());
-
- bb.order(ByteOrder.BIG_ENDIAN);
- sb = bb.asShortBuffer();
-
- checkBuffer(sb);
- assertEquals(2, sb.capacity());
- assertEquals((short) 0xA1A2, sb.get());
- assertEquals((short) 0xA3A4, sb.get());
-
- bb.order(ByteOrder.LITTLE_ENDIAN);
- IntBuffer ib = bb.asIntBuffer();
-
- checkBuffer(ib);
- assertEquals(1, ib.capacity());
- assertEquals(0xA4A3A2A1, ib.get());
-
- bb.order(ByteOrder.BIG_ENDIAN);
- ib = bb.asIntBuffer();
-
- checkBuffer(ib);
- assertEquals(1, ib.capacity());
- assertEquals(0xA1A2A3A4, ib.get());
-
- bb.order(ByteOrder.LITTLE_ENDIAN);
- FloatBuffer fb = bb.asFloatBuffer();
-
- checkBuffer(fb);
- assertEquals(1, fb.capacity());
- assertEquals(0xA4A3A2A1, Float.floatToRawIntBits(fb.get()));
-
- bb.order(ByteOrder.BIG_ENDIAN);
- fb = bb.asFloatBuffer();
-
- checkBuffer(fb);
- assertEquals(1, fb.capacity());
- assertEquals(0xA1A2A3A4, Float.floatToRawIntBits(fb.get()));
- }
-
- private void shortBufferTest(ShortBuffer sb) {
- checkBuffer(sb);
-
- try {
- sb.put(-1, (short) 0);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- try {
- sb.put(sb.limit(), (short) 0);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- // IndexOutOfBoundsException: offset < 0
- try {
- short[] data = new short[8];
- sb.position(0);
- sb.put(data, -1, 2);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- // IndexOutOfBoundsException: length > array.length - offset
- try {
- short[] data = new short[8];
- sb.position(0);
- sb.put(data, 1, 8);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- // BufferOverflowException: length > remaining()
- try {
- short[] data = new short[8];
- sb.position(sb.limit() - 2);
- sb.put(data, 0, 3);
- fail("expected exception not thrown");
- } catch (BufferOverflowException e) {
- // expected
- }
-
- short[] data = {0, 10, 20, 30, 40, 50, 60, 70};
- sb.position(0);
- sb.put(data);
-
- try {
- sb.get();
- fail("expected exception not thrown");
- } catch (BufferUnderflowException e) {
- // expected
- }
-
- sb.position(0);
- assertEquals((short) 0, sb.get());
- assertEquals((short) 10, sb.get());
- assertEquals((short) 20, sb.get());
- assertEquals((short) 30, sb.get());
- assertEquals((short) 40, sb.get());
- assertEquals((short) 50, sb.get());
- assertEquals((short) 60, sb.get());
- assertEquals((short) 70, sb.get());
- try {
- sb.get();
- fail("expected exception not thrown");
- } catch (BufferUnderflowException e) {
- // expected
- }
- sb.position(1);
- sb.put((short) 11);
- assertEquals((short) 11, sb.get(1));
-
- short[] ss1 = {33, 44, 55, 66};
- sb.position(3);
- sb.put(ss1);
- sb.position(0);
- assertEquals((short) 0, sb.get());
- assertEquals((short) 11, sb.get());
- assertEquals((short) 20, sb.get());
- assertEquals((short) 33, sb.get());
- assertEquals((short) 44, sb.get());
- assertEquals((short) 55, sb.get());
- assertEquals((short) 66, sb.get());
- assertEquals((short) 70, sb.get());
-
- short[] ss2 = {10, 22, 30};
- sb.position(2);
- sb.put(ss2, 1, 1);
- sb.position(0);
- assertEquals((short) 0, sb.get());
- assertEquals((short) 11, sb.get());
- assertEquals((short) 22, sb.get());
- assertEquals((short) 33, sb.get());
- assertEquals((short) 44, sb.get());
- assertEquals((short) 55, sb.get());
- assertEquals((short) 66, sb.get());
- assertEquals((short) 70, sb.get());
- }
-
- private void intBufferTest(IntBuffer ib) {
- checkBuffer(ib);
-
- try {
- ib.put(-1, (int) 0);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- try {
- ib.put(ib.limit(), (int) 0);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- // IndexOutOfBoundsException: offset < 0
- try {
- int[] data = new int[8];
- ib.position(0);
- ib.put(data, -1, 2);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- // IndexOutOfBoundsException: length > array.length - offset
- try {
- int[] data = new int[8];
- ib.position(0);
- ib.put(data, 1, 8);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- // BufferOverflowException: length > remaining()
- try {
- int[] data = new int[8];
- ib.position(ib.limit() - 2);
- ib.put(data, 0, 3);
- fail("expected exception not thrown");
- } catch (BufferOverflowException e) {
- // expected
- }
-
- int[] data = {0, 10, 20, 30, 40, 50, 60, 70};
- ib.position(0);
- ib.put(data);
-
- try {
- ib.get();
- fail("expected exception not thrown");
- } catch (BufferUnderflowException e) {
- // expected
- }
-
- ib.position(0);
- assertEquals((int) 0, ib.get());
- assertEquals((int) 10, ib.get());
- assertEquals((int) 20, ib.get());
- assertEquals((int) 30, ib.get());
- assertEquals((int) 40, ib.get());
- assertEquals((int) 50, ib.get());
- assertEquals((int) 60, ib.get());
- assertEquals((int) 70, ib.get());
- try {
- ib.get();
- fail("expected exception not thrown");
- } catch (BufferUnderflowException e) {
- // expected
- }
- ib.position(1);
- ib.put((int) 11);
- assertEquals((int) 11, ib.get(1));
-
- int[] ss1 = {33, 44, 55, 66};
- ib.position(3);
- ib.put(ss1);
- ib.position(0);
- assertEquals((int) 0, ib.get());
- assertEquals((int) 11, ib.get());
- assertEquals((int) 20, ib.get());
- assertEquals((int) 33, ib.get());
- assertEquals((int) 44, ib.get());
- assertEquals((int) 55, ib.get());
- assertEquals((int) 66, ib.get());
- assertEquals((int) 70, ib.get());
-
- int[] ss2 = {10, 22, 30};
- ib.position(2);
- ib.put(ss2, 1, 1);
- ib.position(0);
- assertEquals((int) 0, ib.get());
- assertEquals((int) 11, ib.get());
- assertEquals((int) 22, ib.get());
- assertEquals((int) 33, ib.get());
- assertEquals((int) 44, ib.get());
- assertEquals((int) 55, ib.get());
- assertEquals((int) 66, ib.get());
- assertEquals((int) 70, ib.get());
- }
-
- void floatBufferTest(FloatBuffer fb) {
- checkBuffer(fb);
-
- try {
- fb.put(-1, (float) 0);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- try {
- fb.put(fb.limit(), (float) 0);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- // IndexOutOfBoundsException: offset < 0
- try {
- float[] data = new float[8];
- fb.position(0);
- fb.put(data, -1, 2);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- // IndexOutOfBoundsException: length > array.length - offset
- try {
- float[] data = new float[8];
- fb.position(0);
- fb.put(data, 1, 8);
- fail("expected exception not thrown");
- } catch (IndexOutOfBoundsException e) {
- // expected
- }
-
- // BufferOverflowException: length > remaining()
- try {
- float[] data = new float[8];
- fb.position(fb.limit() - 2);
- fb.put(data, 0, 3);
- fail("expected exception not thrown");
- } catch (BufferOverflowException e) {
- // expected
- }
-
- float[] data = {0, 10, 20, 30, 40, 50, 60, 70};
- fb.position(0);
- fb.put(data);
-
- try {
- fb.get();
- fail("expected exception not thrown");
- } catch (BufferUnderflowException e) {
- // expected
- }
-
- fb.position(0);
- assertEquals((float) 0, fb.get());
- assertEquals((float) 10, fb.get());
- assertEquals((float) 20, fb.get());
- assertEquals((float) 30, fb.get());
- assertEquals((float) 40, fb.get());
- assertEquals((float) 50, fb.get());
- assertEquals((float) 60, fb.get());
- assertEquals((float) 70, fb.get());
- try {
- fb.get();
- fail("expected exception not thrown");
- } catch (BufferUnderflowException e) {
- // expected
- }
- fb.position(1);
- fb.put((float) 11);
- assertEquals((float) 11, fb.get(1));
-
- float[] ss1 = {33, 44, 55, 66};
- fb.position(3);
- fb.put(ss1);
- fb.position(0);
- assertEquals((float) 0, fb.get());
- assertEquals((float) 11, fb.get());
- assertEquals((float) 20, fb.get());
- assertEquals((float) 33, fb.get());
- assertEquals((float) 44, fb.get());
- assertEquals((float) 55, fb.get());
- assertEquals((float) 66, fb.get());
- assertEquals((float) 70, fb.get());
-
- float[] ss2 = {10, 22, 30};
- fb.position(2);
- fb.put(ss2, 1, 1);
- fb.position(0);
- assertEquals((float) 0, fb.get());
- assertEquals((float) 11, fb.get());
- assertEquals((float) 22, fb.get());
- assertEquals((float) 33, fb.get());
- assertEquals((float) 44, fb.get());
- assertEquals((float) 55, fb.get());
- assertEquals((float) 66, fb.get());
- assertEquals((float) 70, fb.get());
- }
-}
diff --git a/tests/CoreTests/android/core/OutputStreamWriterTest.java b/tests/CoreTests/android/core/OutputStreamWriterTest.java
deleted file mode 100644
index 1c0901e..0000000
--- a/tests/CoreTests/android/core/OutputStreamWriterTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStreamWriter;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Tests basic functionality of an OutputStreamWriter.
- */
-public class OutputStreamWriterTest extends TestCase {
-
- @SmallTest
- public void testOutputStreamWriter() throws Exception {
- String str = "AbCdEfGhIjKlMnOpQrStUvWxYz";
- ByteArrayOutputStream aa = new ByteArrayOutputStream();
- OutputStreamWriter a = new OutputStreamWriter(aa, "ISO8859_1");
- try {
- a.write(str, 0, 4);
- a.write('A');
- // We have to flush the OutputStreamWriter to guarantee
- // that the results will appear in the underlying OutputStream
- a.flush();
- assertEquals("ISO8859_1", a.getEncoding());
- assertEquals(5, aa.size());
- assertEquals("AbCdA", aa.toString());
- } finally {
- a.close();
- }
- }
-}
diff --git a/tests/CoreTests/android/core/ParseIntTest.java b/tests/CoreTests/android/core/ParseIntTest.java
deleted file mode 100644
index 0e3b0c6..0000000
--- a/tests/CoreTests/android/core/ParseIntTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Tests for functionality of class Integer to parse integers.
- */
-public class ParseIntTest extends TestCase {
-
- @SmallTest
- public void testParseInt() throws Exception {
- assertEquals(0, Integer.parseInt("0", 10));
- assertEquals(473, Integer.parseInt("473", 10));
- assertEquals(0, Integer.parseInt("-0", 10));
- assertEquals(-255, Integer.parseInt("-FF", 16));
- assertEquals(102, Integer.parseInt("1100110", 2));
- assertEquals(2147483647, Integer.parseInt("2147483647", 10));
- assertEquals(-2147483648, Integer.parseInt("-2147483648", 10));
-
- try {
- Integer.parseInt("2147483648", 10);
- fail();
- } catch (NumberFormatException e) {
- // ok
- }
-
- try {
- Integer.parseInt("-2147483649", 10);
- fail();
- } catch (NumberFormatException e) {
- // ok
- }
-
- // One digit too many
- try {
- Integer.parseInt("21474836470", 10);
- fail();
- } catch (NumberFormatException e) {
- // ok
- }
-
- try {
- Integer.parseInt("-21474836480", 10);
- fail();
- } catch (NumberFormatException e) {
- // ok
- }
-
- try {
- Integer.parseInt("21474836471", 10);
- fail();
- } catch (NumberFormatException e) {
- // ok
- }
-
- try {
- Integer.parseInt("-21474836481", 10);
- fail();
- } catch (NumberFormatException e) {
- // ok
- }
-
- try {
- Integer.parseInt("214748364710", 10);
- fail();
- } catch (NumberFormatException e) {
- // ok
- }
-
- try {
- Integer.parseInt("-214748364811", 10);
- fail();
- } catch (NumberFormatException e) {
- // ok
- }
-
- try {
- Integer.parseInt("99", 8);
- fail();
- } catch (NumberFormatException e) {
- // ok
- }
-
- try {
- Integer.parseInt("Kona", 10);
- fail();
- } catch (NumberFormatException e) {
- // ok
- }
-
- assertEquals(411787, Integer.parseInt("Kona", 27));
- }
-}
diff --git a/tests/CoreTests/android/core/PipedStreamTest.java b/tests/CoreTests/android/core/PipedStreamTest.java
deleted file mode 100644
index d98bc10..0000000
--- a/tests/CoreTests/android/core/PipedStreamTest.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.test.suitebuilder.annotation.SmallTest;
-
-class Fibonacci {
- int n1 = -1;
- int n2;
-
- public int next() {
- if (n1 < 0) {
- n1 = 0;
- return 0;
- } else if (n1 == 0) {
- n2 = 0;
- n1 = 1;
- return 1;
- } else {
- int ret = n1 + n2;
- n2 = n1;
- n1 = ret;
- return ret;
- }
- }
-}
-
-
-public class PipedStreamTest extends TestCase {
-
- private abstract static class TestThread extends Thread {
- public abstract void runTest() throws Exception;
-
- public final void run() {
- try {
- runTest();
- } catch (Throwable e) {
- android.util.Log.e("PST", "Got exception " + e, e);
- android.util.Log.e("PST", android.util.Log.getStackTraceString(e));
- exception = e;
- }
- }
-
- Throwable exception;
- int countRead = 0;
- }
-
- @MediumTest
- public void testA() throws Exception {
-
- final PipedInputStream in = new PipedInputStream();
- final PipedOutputStream out = new PipedOutputStream(in);
-
- assertEquals(0, in.available());
-
- TestThread reader, writer;
-
- reader = new TestThread() {
- Fibonacci fib = new Fibonacci();
-
- @Override
- public void runTest() throws Exception {
- int readInt;
- byte readByte;
-
- for (; ;) {
- readInt = in.read();
-
- if (readInt == -1) {
- return;
- }
-
- readByte = (byte) readInt;
- assertEquals(readByte, (byte) fib.next());
- countRead++;
- }
- }
- };
-
- reader.start();
-
- writer = new TestThread() {
- Fibonacci fib = new Fibonacci();
-
- @Override
- public void runTest() throws Exception {
- for (int i = 0; i < 2000; i++) {
- int toWrite = fib.next();
- out.write(toWrite);
- }
- out.close();
- }
- };
-
- writer.start();
-
-
- for (; ;) {
- try {
- reader.join(60 * 1000);
- writer.join(1000);
- break;
- } catch (InterruptedException ex) {
- }
- }
-
- assertEquals(2000, reader.countRead);
-
- if (writer.exception != null) {
- throw new Exception(writer.exception);
- }
- if (reader.exception != null) {
- throw new Exception(reader.exception);
- }
- }
-
- @MediumTest
- public void testB() throws Exception {
- final PipedInputStream in = new PipedInputStream();
- final PipedOutputStream out = new PipedOutputStream(in);
-
- assertEquals(0, in.available());
-
- TestThread reader, writer;
-
- reader = new TestThread() {
- Fibonacci fib = new Fibonacci();
-
- @Override
- public void runTest() throws Exception {
- byte readBytes[] = new byte[5];
- int ret;
-
- for (; ;) {
- int nread = 0;
- while (nread < 5) {
- ret = in.read(readBytes, nread, readBytes.length - nread);
-
- if (ret == -1) {
- return;
- }
- nread += ret;
- }
-
- assertEquals(5, nread);
-
- int readInt = (((int) readBytes[0] & 0xff) << 24)
- | (((int) readBytes[1] & 0xff) << 16)
- | (((int) readBytes[2] & 0xff) << 8)
- | (((int) readBytes[3] & 0xff));
-
-
- assertEquals("Error at " + countRead, fib.next(), readInt);
- assertEquals("Error at " + countRead, 0, readBytes[4]);
- countRead++;
- }
- }
- };
-
- reader.start();
-
- writer = new TestThread() {
- Fibonacci fib = new Fibonacci();
-
- @Override
- public void runTest() throws Exception {
- byte writeBytes[] = new byte[5];
- for (int i = 0; i < 2000; i++) {
- int toWrite = fib.next();
- writeBytes[0] = (byte) (toWrite >> 24);
- writeBytes[1] = (byte) (toWrite >> 16);
- writeBytes[2] = (byte) (toWrite >> 8);
- writeBytes[3] = (byte) (toWrite);
- writeBytes[4] = 0;
- out.write(writeBytes, 0, writeBytes.length);
- }
- out.close();
- }
- };
-
- writer.start();
-
-
- for (; ;) {
- try {
- reader.join(60 * 1000);
- writer.join(1000);
- break;
- } catch (InterruptedException ex) {
- }
- }
-
- if (reader.exception != null) {
- throw new Exception(reader.exception);
- }
- if (writer.exception != null) {
- throw new Exception(writer.exception);
- }
-
- assertEquals(2000, reader.countRead);
- }
-
- @SmallTest
- public void testC() throws Exception {
- final PipedInputStream in = new PipedInputStream();
- final PipedOutputStream out = new PipedOutputStream(in);
- final byte readBytes[] = new byte[1024 * 2];
-
- assertEquals(0, in.available());
-
- TestThread reader, writer;
-
- reader = new TestThread() {
- @Override
- public void runTest() throws Exception {
- int ret;
-
- for (; ;) {
- int nread = 0;
- while (nread < readBytes.length) {
- ret = in.read(readBytes, nread, readBytes.length - nread);
-
- if (ret == -1) {
- return;
- }
- nread += ret;
- }
- }
- }
- };
-
- reader.start();
-
- writer = new TestThread() {
- Fibonacci fib = new Fibonacci();
-
- @Override
- public void runTest() throws Exception {
- byte writeBytes[] = new byte[1024 * 2];
- for (int i = 0; i < (writeBytes.length - 4); i += 4) {
- int toWrite = fib.next();
- writeBytes[i ] = (byte) (toWrite >> 24);
- writeBytes[i + 1] = (byte) (toWrite >> 16);
- writeBytes[i + 2] = (byte) (toWrite >> 8);
- writeBytes[i + 3] = (byte) (toWrite);
- }
- out.write(writeBytes, 0, writeBytes.length);
- out.close();
- }
- };
-
- writer.start();
-
-
- for (; ;) {
- try {
- reader.join(60 * 1000);
- writer.join(1000);
- break;
- } catch (InterruptedException ex) {
- }
- }
-
- if (reader.exception != null) {
- throw new Exception(reader.exception);
- }
- if (writer.exception != null) {
- throw new Exception(writer.exception);
- }
-
- Fibonacci fib = new Fibonacci();
- for (int i = 0; i < (readBytes.length - 4); i += 4) {
- int readInt = (((int) readBytes[i] & 0xff) << 24)
- | (((int) readBytes[i + 1] & 0xff) << 16)
- | (((int) readBytes[i + 2] & 0xff) << 8)
- | (((int) readBytes[i + 3] & 0xff));
-
- assertEquals("Error at " + i, readInt, fib.next());
- }
- }
-}
diff --git a/tests/CoreTests/android/core/PrintWriterTest.java b/tests/CoreTests/android/core/PrintWriterTest.java
deleted file mode 100644
index 09ee389..0000000
--- a/tests/CoreTests/android/core/PrintWriterTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import android.test.suitebuilder.annotation.SmallTest;
-
-public class PrintWriterTest extends TestCase {
-
- @SmallTest
- public void testPrintWriter() throws Exception {
- String str = "AbCdEfGhIjKlMnOpQrStUvWxYz";
- StringWriter aa = new StringWriter();
- PrintWriter a = new PrintWriter(aa);
-
- try {
- a.write(str, 0, 26);
- a.write('X');
-
- assertEquals("AbCdEfGhIjKlMnOpQrStUvWxYzX", aa.toString());
-
- a.write("alphabravodelta", 5, 5);
- a.append('X');
- assertEquals("AbCdEfGhIjKlMnOpQrStUvWxYzXbravoX", aa.toString());
- a.append("omega");
- assertEquals("AbCdEfGhIjKlMnOpQrStUvWxYzXbravoXomega", aa.toString());
- a.print("ZZZ");
- assertEquals("AbCdEfGhIjKlMnOpQrStUvWxYzXbravoXomegaZZZ", aa.toString());
- } finally {
- a.close();
- }
-
- StringWriter ba = new StringWriter();
- PrintWriter b = new PrintWriter(ba);
- try {
- b.print(true);
- b.print((char) 'A');
- b.print("BCD".toCharArray());
- b.print((double) 1.2);
- b.print((float) 3);
- b.print((int) 4);
- b.print((long) 5);
- assertEquals("trueABCD1.23.045", ba.toString());
- b.println();
- b.println(true);
- b.println((char) 'A');
- b.println("BCD".toCharArray());
- b.println((double) 1.2);
- b.println((float) 3);
- b.println((int) 4);
- b.println((long) 5);
- b.print("THE END");
- assertEquals("trueABCD1.23.045\ntrue\nA\nBCD\n1.2\n3.0\n4\n5\nTHE END", ba.toString());
- } finally {
- b.close();
- }
- }
-}
diff --git a/tests/CoreTests/android/core/PushbackInputStreamTest.java b/tests/CoreTests/android/core/PushbackInputStreamTest.java
deleted file mode 100644
index 44cfd8a..0000000
--- a/tests/CoreTests/android/core/PushbackInputStreamTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.ByteArrayInputStream;
-import java.io.PushbackInputStream;
-import android.test.suitebuilder.annotation.SmallTest;
-
-public class PushbackInputStreamTest extends TestCase {
-
- @SmallTest
- public void testPushbackInputStream() throws Exception {
- String str = "AbCdEfGhIjKlM\nOpQrStUvWxYz";
- ByteArrayInputStream aa = new ByteArrayInputStream(str.getBytes());
- ByteArrayInputStream ba = new ByteArrayInputStream(str.getBytes());
- ByteArrayInputStream ca = new ByteArrayInputStream(str.getBytes());
-
- PushbackInputStream a = new PushbackInputStream(aa, 7);
- try {
- a.unread("push".getBytes());
- assertEquals("pushAbCdEfGhIjKlM\nOpQrStUvWxYz", IOUtil.read(a));
- } finally {
- a.close();
- }
-
- PushbackInputStream b = new PushbackInputStream(ba, 9);
- try {
- b.unread('X');
- assertEquals("XAbCdEfGhI", IOUtil.read(b, 10));
- } finally {
- b.close();
- }
-
- PushbackInputStream c = new PushbackInputStream(ca);
- try {
- assertEquals("bdfhjl\nprtvxz", IOUtil.skipRead(c));
- } finally {
- c.close();
- }
- }
-}
diff --git a/tests/CoreTests/android/core/PushbackReaderTest.java b/tests/CoreTests/android/core/PushbackReaderTest.java
deleted file mode 100644
index ef62c28..0000000
--- a/tests/CoreTests/android/core/PushbackReaderTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.PushbackReader;
-import java.io.StringReader;
-import android.test.suitebuilder.annotation.SmallTest;
-
-public class PushbackReaderTest extends TestCase {
-
- @SmallTest
- public void testPushbackReader() throws Exception {
- String str = "AbCdEfGhIjKlMnOpQrStUvWxYz";
- StringReader aa = new StringReader(str);
- StringReader ba = new StringReader(str);
- StringReader ca = new StringReader(str);
-
- PushbackReader a = new PushbackReader(aa, 5);
- try {
- a.unread("PUSH".toCharArray());
- assertEquals("PUSHAbCdEfGhIjKlMnOpQrStUvWxYz", IOUtil.read(a));
- } finally {
- a.close();
- }
-
- PushbackReader b = new PushbackReader(ba, 15);
- try {
- b.unread('X');
- assertEquals("XAbCdEfGhI", IOUtil.read(b, 10));
- } finally {
- b.close();
- }
-
- PushbackReader c = new PushbackReader(ca);
- try {
- assertEquals("bdfhjlnprtvxz", IOUtil.skipRead(c));
- } finally {
- c.close();
- }
- }
-}
diff --git a/tests/CoreTests/android/core/ReflectArrayTest.java b/tests/CoreTests/android/core/ReflectArrayTest.java
deleted file mode 100644
index 20ee8a4..0000000
--- a/tests/CoreTests/android/core/ReflectArrayTest.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.lang.reflect.Array;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Test java.lang.reflect.Array methods.
- */
-public class ReflectArrayTest extends TestCase {
-
- @SmallTest
- public void testSingleInt() throws Exception {
- Object intArray = Array.newInstance(Integer.TYPE, 2);
-
- int[] array = (int[]) intArray;
- array[0] = 5;
- Array.setInt(intArray, 1, 6);
-
- assertEquals(5, Array.getInt(intArray, 0));
- assertEquals(6, array[1]);
-
- try {
- array[2] = 27;
- fail("store should have failed");
- } catch (ArrayIndexOutOfBoundsException abe) {
- // expected
- }
-
- assertEquals(2, array.length);
- assertEquals(Array.getLength(intArray), array.length);
-
- try {
- int[][] wrongArray = (int[][]) intArray;
- fail("cast should have failed");
- } catch (ClassCastException cce) {
- // expected
- }
-
- intArray = Array.newInstance(Integer.TYPE, 0);
- assertEquals(0, Array.getLength(intArray));
- }
-
- @SmallTest
- public void testSingle() throws Exception {
- Object strArray = Array.newInstance(String.class, 2);
-
- String[] array = (String[]) strArray;
- array[0] = "entry zero";
- Array.set(strArray, 1, "entry one");
-
- //System.out.println("array: " + array);
-
- assertEquals("entry zero", Array.get(strArray, 0));
- assertEquals("entry one", array[1]);
-
- assertEquals(2, array.length);
- assertEquals(Array.getLength(strArray), array.length);
- }
-
- @SmallTest
- public void testMultiInt() throws Exception {
- int[] dimensions = {3, 2, 1};
- Object intIntIntArray = Array.newInstance(Integer.TYPE, dimensions);
- int[][][] array3 = (int[][][]) intIntIntArray;
-
- array3[0][0][0] = 123;
- array3[2][1][0] = 456;
-
- try {
- array3[2][1][1] = 768;
- fail("store should have failed");
- } catch (ArrayIndexOutOfBoundsException abe) {
- // expected
- }
-
- //System.out.println("array3: " + array3);
- }
-
- @SmallTest
- public void testMulti() throws Exception {
- int[] dimensions = {1, 2, 3};
- Object strStrStrArray = Array.newInstance(String.class, dimensions);
- String[][][] array3 = (String[][][]) strStrStrArray;
-
- array3[0][0][0] = "zero zero zero";
- array3[0][1][2] = "zero one two";
-
- try {
- array3[1][0][0] = "bad store";
- fail("store should have failed");
- } catch (ArrayIndexOutOfBoundsException abe) {
- // expected
- }
-
- try {
- String[][] array2 = (String[][]) strStrStrArray;
- fail("expecting bad cast");
- } catch (ClassCastException cce) {
- // expected
- }
- //System.out.println("array3: " + array3);
-
-
- int[] dimensions2 = {1, 2};
- strStrStrArray = Array.newInstance(String[].class, dimensions2);
- array3 = (String[][][]) strStrStrArray;
- array3[0][1] = new String[3];
- array3[0][1][2] = "zero one two";
- try {
- array3[1][0][0] = "bad store";
- fail("store should have failed");
- } catch (ArrayIndexOutOfBoundsException abe) {
- // expected
- }
- //System.out.println("array3: " + array3);
- }
-}
-
diff --git a/tests/CoreTests/android/core/SerializationTest.java b/tests/CoreTests/android/core/SerializationTest.java
deleted file mode 100644
index 9644d03..0000000
--- a/tests/CoreTests/android/core/SerializationTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import android.test.suitebuilder.annotation.SmallTest;
-
-/**
- * Tests serialization of user-level classes.
- */
-public class SerializationTest extends TestCase {
-
- static class MySerializable implements Serializable {}
-
- @SmallTest
- public void testSerialization() throws IOException, ClassNotFoundException {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- ObjectOutputStream oout = new ObjectOutputStream(bout);
- oout.writeObject(new MySerializable());
- oout.close();
-
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- Object o = new ObjectInputStream(bin).readObject();
- assertTrue(o instanceof MySerializable);
- }
-}
diff --git a/tests/CoreTests/android/core/StreamTokenizerTest.java b/tests/CoreTests/android/core/StreamTokenizerTest.java
deleted file mode 100644
index 5013860..0000000
--- a/tests/CoreTests/android/core/StreamTokenizerTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.ByteArrayInputStream;
-import java.io.StreamTokenizer;
-import java.io.StringReader;
-import android.test.suitebuilder.annotation.MediumTest;
-
-/**
- * Tests for the StreamTokenizer
- */
-public class StreamTokenizerTest extends TestCase {
-
- @MediumTest
- public void testStreamTokenizer() throws Exception {
- String str = "Testing 12345 \n alpha \r\n omega";
- String strb = "-3.8 'BLIND mice' \r sEe /* how */ they run";
- StringReader aa = new StringReader(str);
- StringReader ba = new StringReader(strb);
- StreamTokenizer a = new StreamTokenizer(aa);
- StreamTokenizer b = new StreamTokenizer(ba);
-
- assertEquals(1, a.lineno());
- assertEquals(StreamTokenizer.TT_WORD, a.nextToken());
- assertEquals("Token[Testing], line 1", a.toString());
- assertEquals(StreamTokenizer.TT_NUMBER, a.nextToken());
- assertEquals("Token[n=12345.0], line 1", a.toString());
- assertEquals(StreamTokenizer.TT_WORD, a.nextToken());
- assertEquals("Token[alpha], line 2", a.toString());
- assertEquals(StreamTokenizer.TT_WORD, a.nextToken());
- assertEquals("Token[omega], line 3", a.toString());
- assertEquals(StreamTokenizer.TT_EOF, a.nextToken());
- assertEquals("Token[EOF], line 3", a.toString());
-
- b.commentChar('u');
- b.eolIsSignificant(true);
- b.lowerCaseMode(true);
- b.ordinaryChar('y');
- b.slashStarComments(true);
-
- assertEquals(StreamTokenizer.TT_NUMBER, b.nextToken());
- assertEquals(-3.8, b.nval);
- assertEquals("Token[n=-3.8], line 1", b.toString());
- assertEquals(39, b.nextToken()); // '
- assertEquals("Token[BLIND mice], line 1", b.toString());
- assertEquals(10, b.nextToken()); // \n
- assertEquals("Token[EOL], line 2", b.toString());
- assertEquals(StreamTokenizer.TT_WORD, b.nextToken());
- assertEquals("Token[see], line 2", b.toString());
- assertEquals(StreamTokenizer.TT_WORD, b.nextToken());
- assertEquals("Token[the], line 2", b.toString());
- assertEquals(121, b.nextToken()); // y
- assertEquals("Token['y'], line 2", b.toString());
- assertEquals(StreamTokenizer.TT_WORD, b.nextToken());
- assertEquals("Token[r], line 2", b.toString());
- assertEquals(StreamTokenizer.TT_EOF, b.nextToken());
- assertEquals("Token[EOF], line 2", b.toString());
-
- // A harmony regression test
- byte[] data = new byte[]{(byte) '-'};
- StreamTokenizer tokenizer = new StreamTokenizer(new ByteArrayInputStream(data));
- tokenizer.nextToken();
- String result = tokenizer.toString();
- assertEquals("Token['-'], line 1", result);
-
- // another harmony regression test
- byte[] data2 = new byte[]{(byte) '"',
- (byte) 'H',
- (byte) 'e',
- (byte) 'l',
- (byte) 'l',
- (byte) 'o',
- (byte) '"'};
- StreamTokenizer tokenizer2 = new StreamTokenizer(new ByteArrayInputStream(data2));
- tokenizer2.nextToken();
- result = tokenizer2.toString();
- assertEquals("Token[Hello], line 1", result);
- }
-}
diff --git a/tests/CoreTests/android/core/StrictMathTest.java b/tests/CoreTests/android/core/StrictMathTest.java
deleted file mode 100644
index 92e6cb6..0000000
--- a/tests/CoreTests/android/core/StrictMathTest.java
+++ /dev/null
@@ -1,855 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.test.suitebuilder.annotation.MediumTest;
-
-public class StrictMathTest extends TestCase {
-
- private final double HYP = StrictMath.sqrt(2.0);
-
- private final double OPP = 1.0;
-
- private final double ADJ = 1.0;
-
- /* Required to make previous preprocessor flags work - do not remove */
- int unused = 0;
-
- /**
- * @tests java.lang.StrictMath#abs(double)
- */
- @SmallTest
- public void testAbsD() {
- // Test for method double java.lang.StrictMath.abs(double)
-
- assertTrue("Incorrect double abs value",
- (StrictMath.abs(-1908.8976) == 1908.8976));
- assertTrue("Incorrect double abs value",
- (StrictMath.abs(1908.8976) == 1908.8976));
- }
-
- /**
- * @tests java.lang.StrictMath#abs(float)
- */
- @SmallTest
- public void testAbsF() {
- // Test for method float java.lang.StrictMath.abs(float)
- assertTrue("Incorrect float abs value",
- (StrictMath.abs(-1908.8976f) == 1908.8976f));
- assertTrue("Incorrect float abs value",
- (StrictMath.abs(1908.8976f) == 1908.8976f));
- }
-
- /**
- * @tests java.lang.StrictMath#abs(int)
- */
- @SmallTest
- public void testAbsI() {
- // Test for method int java.lang.StrictMath.abs(int)
- assertTrue("Incorrect int abs value",
- (StrictMath.abs(-1908897) == 1908897));
- assertTrue("Incorrect int abs value",
- (StrictMath.abs(1908897) == 1908897));
- }
-
- /**
- * @tests java.lang.StrictMath#abs(long)
- */
- @SmallTest
- public void testAbsJ() {
- // Test for method long java.lang.StrictMath.abs(long)
- assertTrue("Incorrect long abs value", (StrictMath
- .abs(-19088976000089L) == 19088976000089L));
- assertTrue("Incorrect long abs value",
- (StrictMath.abs(19088976000089L) == 19088976000089L));
- }
-
- /**
- * @tests java.lang.StrictMath#acos(double)
- */
- @SmallTest
- public void testAcosD() {
- // Test for method double java.lang.StrictMath.acos(double)
- assertTrue("Returned incorrect arc cosine", StrictMath.cos(StrictMath
- .acos(ADJ / HYP)) == ADJ / HYP);
- }
-
- /**
- * @tests java.lang.StrictMath#asin(double)
- */
- @SmallTest
- public void testAsinD() {
- // Test for method double java.lang.StrictMath.asin(double)
- assertTrue("Returned incorrect arc sine", StrictMath.sin(StrictMath
- .asin(OPP / HYP)) == OPP / HYP);
- }
-
- /**
- * @tests java.lang.StrictMath#atan(double)
- */
- @SmallTest
- public void testAtanD() {
- // Test for method double java.lang.StrictMath.atan(double)
- double answer = StrictMath.tan(StrictMath.atan(1.0));
- assertTrue("Returned incorrect arc tangent: " + answer, answer <= 1.0
- && answer >= 9.9999999999999983E-1);
- }
-
- /**
- * @tests java.lang.StrictMath#atan2(double,double)
- */
- @SmallTest
- public void testAtan2DD() {
- // Test for method double java.lang.StrictMath.atan2(double, double)
- double answer = StrictMath.atan(StrictMath.tan(1.0));
- assertTrue("Returned incorrect arc tangent: " + answer, answer <= 1.0
- && answer >= 9.9999999999999983E-1);
- }
-
- /**
- * @tests java.lang.StrictMath#cbrt(double)
- */
- @SuppressWarnings("boxing")
- @SmallTest
- public void testCbrtD() {
- // Test for special situations
- assertTrue("Should return Double.NaN", Double.isNaN(StrictMath
- .cbrt(Double.NaN)));
- assertEquals("Should return Double.POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath
- .cbrt(Double.POSITIVE_INFINITY));
- assertEquals("Should return Double.NEGATIVE_INFINITY",
- Double.NEGATIVE_INFINITY, StrictMath
- .cbrt(Double.NEGATIVE_INFINITY));
- assertEquals(Double.doubleToLongBits(0.0), Double
- .doubleToLongBits(StrictMath.cbrt(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(StrictMath.cbrt(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(StrictMath.cbrt(-0.0)));
-
- assertEquals("Should return 3.0", 3.0, StrictMath.cbrt(27.0));
- assertEquals("Should return 23.111993172558684", 23.111993172558684,
- StrictMath.cbrt(12345.6));
- assertEquals("Should return 5.643803094122362E102",
- 5.643803094122362E102, StrictMath.cbrt(Double.MAX_VALUE));
- assertEquals("Should return 0.01", 0.01, StrictMath.cbrt(0.000001));
-
- assertEquals("Should return -3.0", -3.0, StrictMath.cbrt(-27.0));
- assertEquals("Should return -23.111993172558684", -23.111993172558684,
- StrictMath.cbrt(-12345.6));
- assertEquals("Should return 1.7031839360032603E-108",
- 1.7031839360032603E-108, StrictMath.cbrt(Double.MIN_VALUE));
- assertEquals("Should return -0.01", -0.01, StrictMath.cbrt(-0.000001));
-
- try {
- StrictMath.cbrt((Double) null);
- fail("Should throw NullPointerException");
- } catch (NullPointerException e) {
- //expected
- }
- }
-
- /**
- * @tests java.lang.StrictMath#ceil(double)
- */
- @SmallTest
- public void testCeilD() {
- // Test for method double java.lang.StrictMath.ceil(double)
- assertEquals("Incorrect ceiling for double",
- 79, StrictMath.ceil(78.89), 0.0);
- assertEquals("Incorrect ceiling for double",
- -78, StrictMath.ceil(-78.89), 0.0);
- }
-
- /**
- * @tests java.lang.StrictMath#cos(double)
- */
- @SmallTest
- public void testCosD() {
- // Test for method double java.lang.StrictMath.cos(double)
-
- assertTrue("Returned incorrect cosine", StrictMath.cos(StrictMath
- .acos(ADJ / HYP)) == ADJ / HYP);
- }
-
- /**
- * @tests java.lang.StrictMath#cosh(double)
- */
- @SuppressWarnings("boxing")
- @SmallTest
- public void testCosh_D() {
- // Test for special situations
- assertTrue("Should return NaN", Double.isNaN(StrictMath
- .cosh(Double.NaN)));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath
- .cosh(Double.POSITIVE_INFINITY));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath
- .cosh(Double.NEGATIVE_INFINITY));
- assertEquals("Should return 1.0", 1.0, StrictMath.cosh(+0.0));
- assertEquals("Should return 1.0", 1.0, StrictMath.cosh(-0.0));
-
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.cosh(1234.56));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.cosh(-1234.56));
- assertEquals("Should return 1.0000000000005", 1.0000000000005,
- StrictMath.cosh(0.000001));
- assertEquals("Should return 1.0000000000005", 1.0000000000005,
- StrictMath.cosh(-0.000001));
- assertEquals("Should return 5.212214351945598", 5.212214351945598,
- StrictMath.cosh(2.33482));
-
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.cosh(Double.MAX_VALUE));
- assertEquals("Should return 1.0", 1.0, StrictMath
- .cosh(Double.MIN_VALUE));
- }
-
- /**
- * @tests java.lang.StrictMath#exp(double)
- */
- @SmallTest
- public void testExpD() {
- // Test for method double java.lang.StrictMath.exp(double)
- assertTrue("Incorrect answer returned for simple power", StrictMath
- .abs(StrictMath.exp(4D) - StrictMath.E * StrictMath.E
- * StrictMath.E * StrictMath.E) < 0.1D);
- assertTrue("Incorrect answer returned for larger power", StrictMath
- .log(StrictMath.abs(StrictMath.exp(5.5D)) - 5.5D) < 10.0D);
- }
-
- /**
- * @tests java.lang.StrictMath#expm1(double)
- */
- @SuppressWarnings("boxing")
- @SmallTest
- public void testExpm1D() {
- //Test for special cases
- assertTrue("Should return NaN", Double.isNaN(StrictMath.expm1(Double.NaN)));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.expm1(Double.POSITIVE_INFINITY));
- assertEquals("Should return -1.0", -1.0, StrictMath
- .expm1(Double.NEGATIVE_INFINITY));
- assertEquals(Double.doubleToLongBits(0.0), Double
- .doubleToLongBits(StrictMath.expm1(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(StrictMath.expm1(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(StrictMath.expm1(-0.0)));
-
- assertEquals("Should return -9.999950000166666E-6",
- -9.999950000166666E-6, StrictMath.expm1(-0.00001));
- assertEquals("Should return 1.0145103074469635E60",
- 1.0145103074469635E60, StrictMath.expm1(138.16951162));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath
- .expm1(123456789123456789123456789.4521584223));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.expm1(Double.MAX_VALUE));
- assertEquals("Should return MIN_VALUE", Double.MIN_VALUE, StrictMath
- .expm1(Double.MIN_VALUE));
-
- }
-
- /**
- * @tests java.lang.StrictMath#floor(double)
- */
- @SmallTest
- public void testFloorD() {
- // Test for method double java.lang.StrictMath.floor(double)
- assertEquals("Incorrect floor for double",
- 78, StrictMath.floor(78.89), 0.0);
- assertEquals("Incorrect floor for double",
- -79, StrictMath.floor(-78.89), 0.0);
- }
-
- /**
- * @tests java.lang.StrictMath#hypot(double,double)
- */
- @SuppressWarnings("boxing")
- @SmallTest
- public void testHypotDD() {
- // Test for special cases
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.hypot(Double.POSITIVE_INFINITY,
- 1.0));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.hypot(Double.NEGATIVE_INFINITY,
- 123.324));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.hypot(-758.2587,
- Double.POSITIVE_INFINITY));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.hypot(5687.21,
- Double.NEGATIVE_INFINITY));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.hypot(Double.POSITIVE_INFINITY,
- Double.NEGATIVE_INFINITY));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.hypot(Double.NEGATIVE_INFINITY,
- Double.POSITIVE_INFINITY));
- assertTrue("Should return NaN", Double.isNaN(StrictMath.hypot(Double.NaN,
- 2342301.89843)));
- assertTrue("Should return NaN", Double.isNaN(StrictMath.hypot(-345.2680,
- Double.NaN)));
-
- assertEquals("Should return 2396424.905416697", 2396424.905416697, StrictMath
- .hypot(12322.12, -2396393.2258));
- assertEquals("Should return 138.16958070558556", 138.16958070558556,
- StrictMath.hypot(-138.16951162, 0.13817035864));
- assertEquals("Should return 1.7976931348623157E308",
- 1.7976931348623157E308, StrictMath.hypot(Double.MAX_VALUE, 211370.35));
- assertEquals("Should return 5413.7185", 5413.7185, StrictMath.hypot(
- -5413.7185, Double.MIN_VALUE));
-
- }
-
- /**
- * @tests java.lang.StrictMath#IEEEremainder(double,double)
- */
- @SmallTest
- public void testIEEEremainderDD() {
- // Test for method double java.lang.StrictMath.IEEEremainder(double,
- // double)
- assertEquals("Incorrect remainder returned", 0.0, StrictMath.IEEEremainder(
- 1.0, 1.0), 0.0);
- assertTrue(
- "Incorrect remainder returned",
- StrictMath.IEEEremainder(1.32, 89.765) >= 1.4705063220631647E-2
- || StrictMath.IEEEremainder(1.32, 89.765) >= 1.4705063220631649E-2);
- }
-
- /**
- * @tests java.lang.StrictMath#log(double)
- */
- @SmallTest
- public void testLogD() {
- // Test for method double java.lang.StrictMath.log(double)
- for (double d = 10; d >= -10; d -= 0.5) {
- double answer = StrictMath.log(StrictMath.exp(d));
- assertTrue("Answer does not equal expected answer for d = " + d
- + " answer = " + answer,
- StrictMath.abs(answer - d) <= StrictMath
- .abs(d * 0.00000001));
- }
- }
-
- /**
- * @tests java.lang.StrictMath#log10(double)
- */
- @SuppressWarnings("boxing")
- @SmallTest
- public void testLog10D() {
- // Test for special cases
- assertTrue("Should return NaN", Double.isNaN(StrictMath
- .log10(Double.NaN)));
- assertTrue("Should return NaN", Double.isNaN(StrictMath
- .log10(-2541.05745687234187532)));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath
- .log10(Double.POSITIVE_INFINITY));
- assertEquals("Should return NEGATIVE_INFINITY",
- Double.NEGATIVE_INFINITY, StrictMath.log10(0.0));
- assertEquals("Should return NEGATIVE_INFINITY",
- Double.NEGATIVE_INFINITY, StrictMath.log10(+0.0));
- assertEquals("Should return NEGATIVE_INFINITY",
- Double.NEGATIVE_INFINITY, StrictMath.log10(-0.0));
- assertEquals("Should return 14.0", 14.0, StrictMath.log10(StrictMath
- .pow(10, 14)));
-
- assertEquals("Should return 3.7389561269540406", 3.7389561269540406,
- StrictMath.log10(5482.2158));
- assertEquals("Should return 14.661551142893833", 14.661551142893833,
- StrictMath.log10(458723662312872.125782332587));
- assertEquals("Should return -0.9083828622192334", -0.9083828622192334,
- StrictMath.log10(0.12348583358871));
- assertEquals("Should return 308.25471555991675", 308.25471555991675,
- StrictMath.log10(Double.MAX_VALUE));
- assertEquals("Should return -323.3062153431158", -323.3062153431158,
- StrictMath.log10(Double.MIN_VALUE));
- }
-
- /**
- * @tests java.lang.StrictMath#log1p(double)
- */
- @SuppressWarnings("boxing")
- @SmallTest
- public void testLog1pD() {
- // Test for special cases
- assertTrue("Should return NaN", Double.isNaN(StrictMath
- .log1p(Double.NaN)));
- assertTrue("Should return NaN", Double.isNaN(StrictMath
- .log1p(-32.0482175)));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath
- .log1p(Double.POSITIVE_INFINITY));
- assertEquals(Double.doubleToLongBits(0.0), Double
- .doubleToLongBits(StrictMath.log1p(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(StrictMath.log1p(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(StrictMath.log1p(-0.0)));
-
- assertEquals("Should return -0.2941782295312541", -0.2941782295312541,
- StrictMath.log1p(-0.254856327));
- assertEquals("Should return 7.368050685564151", 7.368050685564151,
- StrictMath.log1p(1583.542));
- assertEquals("Should return 0.4633708685409921", 0.4633708685409921,
- StrictMath.log1p(0.5894227));
- assertEquals("Should return 709.782712893384", 709.782712893384,
- StrictMath.log1p(Double.MAX_VALUE));
- assertEquals("Should return Double.MIN_VALUE", Double.MIN_VALUE,
- StrictMath.log1p(Double.MIN_VALUE));
- }
-
- /**
- * @tests java.lang.StrictMath#max(double,double)
- */
- @SmallTest
- public void testMaxDD() {
- // Test for method double java.lang.StrictMath.max(double, double)
- assertEquals("Incorrect double max value", 1908897.6000089, StrictMath.max(
- -1908897.6000089, 1908897.6000089), 0D);
- assertEquals("Incorrect double max value", 1908897.6000089, StrictMath.max(2.0,
- 1908897.6000089), 0D);
- assertEquals("Incorrect double max value", -2.0, StrictMath.max(-2.0,
- -1908897.6000089), 0D);
-
- }
-
- /**
- * @tests java.lang.StrictMath#max(float,float)
- */
- @SmallTest
- public void testMaxFF() {
- // Test for method float java.lang.StrictMath.max(float, float)
- assertTrue("Incorrect float max value", StrictMath.max(-1908897.600f,
- 1908897.600f) == 1908897.600f);
- assertTrue("Incorrect float max value", StrictMath.max(2.0f,
- 1908897.600f) == 1908897.600f);
- assertTrue("Incorrect float max value", StrictMath.max(-2.0f,
- -1908897.600f) == -2.0f);
- }
-
- /**
- * @tests java.lang.StrictMath#max(int,int)
- */
- @SmallTest
- public void testMaxII() {
- // Test for method int java.lang.StrictMath.max(int, int)
- assertEquals("Incorrect int max value", 19088976, StrictMath.max(-19088976,
- 19088976));
- assertEquals("Incorrect int max value",
- 19088976, StrictMath.max(20, 19088976));
- assertEquals("Incorrect int max value",
- -20, StrictMath.max(-20, -19088976));
- }
-
- /**
- * @tests java.lang.StrictMath#max(long,long)
- */
- @SmallTest
- public void testMaxJJ() {
- // Test for method long java.lang.StrictMath.max(long, long)
- assertEquals("Incorrect long max value", 19088976000089L, StrictMath.max(-19088976000089L,
- 19088976000089L));
- assertEquals("Incorrect long max value", 19088976000089L, StrictMath.max(20,
- 19088976000089L));
- assertEquals("Incorrect long max value", -20, StrictMath.max(-20,
- -19088976000089L));
- }
-
- /**
- * @tests java.lang.StrictMath#min(double,double)
- */
- @SmallTest
- public void testMinDD() {
- // Test for method double java.lang.StrictMath.min(double, double)
- assertEquals("Incorrect double min value", -1908897.6000089, StrictMath.min(
- -1908897.6000089, 1908897.6000089), 0D);
- assertEquals("Incorrect double min value", 2.0, StrictMath.min(2.0,
- 1908897.6000089), 0D);
- assertEquals("Incorrect double min value", -1908897.6000089, StrictMath.min(-2.0,
- -1908897.6000089), 0D);
- }
-
- /**
- * @tests java.lang.StrictMath#min(float,float)
- */
- @SmallTest
- public void testMinFF() {
- // Test for method float java.lang.StrictMath.min(float, float)
- assertTrue("Incorrect float min value", StrictMath.min(-1908897.600f,
- 1908897.600f) == -1908897.600f);
- assertTrue("Incorrect float min value", StrictMath.min(2.0f,
- 1908897.600f) == 2.0f);
- assertTrue("Incorrect float min value", StrictMath.min(-2.0f,
- -1908897.600f) == -1908897.600f);
- }
-
- /**
- * @tests java.lang.StrictMath#min(int,int)
- */
- @SmallTest
- public void testMinII() {
- // Test for method int java.lang.StrictMath.min(int, int)
- assertEquals("Incorrect int min value", -19088976, StrictMath.min(-19088976,
- 19088976));
- assertEquals("Incorrect int min value",
- 20, StrictMath.min(20, 19088976));
- assertEquals("Incorrect int min value",
- -19088976, StrictMath.min(-20, -19088976));
-
- }
-
- /**
- * @tests java.lang.StrictMath#min(long,long)
- */
- @SmallTest
- public void testMinJJ() {
- // Test for method long java.lang.StrictMath.min(long, long)
- assertEquals("Incorrect long min value", -19088976000089L, StrictMath.min(-19088976000089L,
- 19088976000089L));
- assertEquals("Incorrect long min value", 20, StrictMath.min(20,
- 19088976000089L));
- assertEquals("Incorrect long min value", -19088976000089L, StrictMath.min(-20,
- -19088976000089L));
- }
-
- /**
- * @tests java.lang.StrictMath#pow(double,double)
- */
- @SmallTest
- public void testPowDD() {
- // Test for method double java.lang.StrictMath.pow(double, double)
- assertTrue("pow returned incorrect value",
- (long) StrictMath.pow(2, 8) == 256l);
- assertTrue("pow returned incorrect value",
- StrictMath.pow(2, -8) == 0.00390625d);
- }
-
- /**
- * @tests java.lang.StrictMath#rint(double)
- */
- @SmallTest
- public void testRintD() {
- // Test for method double java.lang.StrictMath.rint(double)
- assertEquals("Failed to round properly - up to odd",
- 3.0, StrictMath.rint(2.9), 0D);
- assertTrue("Failed to round properly - NaN", Double.isNaN(StrictMath
- .rint(Double.NaN)));
- assertEquals("Failed to round properly down to even", 2.0, StrictMath
- .rint(2.1), 0D);
- assertTrue("Failed to round properly " + 2.5 + " to even", StrictMath
- .rint(2.5) == 2.0);
- }
-
- /**
- * @tests java.lang.StrictMath#round(double)
- */
- @SmallTest
- public void testRoundD() {
- // Test for method long java.lang.StrictMath.round(double)
- assertEquals("Incorrect rounding of a float",
- -91, StrictMath.round(-90.89d));
- }
-
- /**
- * @tests java.lang.StrictMath#round(float)
- */
- @SmallTest
- public void testRoundF() {
- // Test for method int java.lang.StrictMath.round(float)
- assertEquals("Incorrect rounding of a float",
- -91, StrictMath.round(-90.89f));
- }
-
- /**
- * @tests java.lang.StrictMath#signum(double)
- */
- @SmallTest
- public void testSignumD() {
- assertTrue(Double.isNaN(StrictMath.signum(Double.NaN)));
- assertEquals(Double.doubleToLongBits(0.0), Double
- .doubleToLongBits(StrictMath.signum(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(StrictMath.signum(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(StrictMath.signum(-0.0)));
-
- assertEquals(1.0, StrictMath.signum(253681.2187962), 0D);
- assertEquals(-1.0, StrictMath.signum(-125874693.56), 0D);
- assertEquals(1.0, StrictMath.signum(1.2587E-308), 0D);
- assertEquals(-1.0, StrictMath.signum(-1.2587E-308), 0D);
-
- assertEquals(1.0, StrictMath.signum(Double.MAX_VALUE), 0D);
- assertEquals(1.0, StrictMath.signum(Double.MIN_VALUE), 0D);
- assertEquals(-1.0, StrictMath.signum(-Double.MAX_VALUE), 0D);
- assertEquals(-1.0, StrictMath.signum(-Double.MIN_VALUE), 0D);
- assertEquals(1.0, StrictMath.signum(Double.POSITIVE_INFINITY), 0D);
- assertEquals(-1.0, StrictMath.signum(Double.NEGATIVE_INFINITY), 0D);
-
- }
-
- /**
- * @tests java.lang.StrictMath#signum(float)
- */
- @SmallTest
- public void testSignumF() {
- assertTrue(Float.isNaN(StrictMath.signum(Float.NaN)));
- assertEquals(Float.floatToIntBits(0.0f), Float
- .floatToIntBits(StrictMath.signum(0.0f)));
- assertEquals(Float.floatToIntBits(+0.0f), Float
- .floatToIntBits(StrictMath.signum(+0.0f)));
- assertEquals(Float.floatToIntBits(-0.0f), Float
- .floatToIntBits(StrictMath.signum(-0.0f)));
-
- assertEquals(1.0f, StrictMath.signum(253681.2187962f), 0f);
- assertEquals(-1.0f, StrictMath.signum(-125874693.56f), 0f);
- assertEquals(1.0f, StrictMath.signum(1.2587E-11f), 0f);
- assertEquals(-1.0f, StrictMath.signum(-1.2587E-11f), 0f);
-
- assertEquals(1.0f, StrictMath.signum(Float.MAX_VALUE), 0f);
- assertEquals(1.0f, StrictMath.signum(Float.MIN_VALUE), 0f);
- assertEquals(-1.0f, StrictMath.signum(-Float.MAX_VALUE), 0f);
- assertEquals(-1.0f, StrictMath.signum(-Float.MIN_VALUE), 0f);
- assertEquals(1.0f, StrictMath.signum(Float.POSITIVE_INFINITY), 0f);
- assertEquals(-1.0f, StrictMath.signum(Float.NEGATIVE_INFINITY), 0f);
- }
-
- /**
- * @tests java.lang.StrictMath#sin(double)
- */
- @SmallTest
- public void testSinD() {
- // Test for method double java.lang.StrictMath.sin(double)
- assertTrue("Returned incorrect sine", StrictMath.sin(StrictMath
- .asin(OPP / HYP)) == OPP / HYP);
- }
-
- /**
- * @tests java.lang.StrictMath#sinh(double)
- */
- @SmallTest
- public void testSinhD() {
- // Test for special situations
- assertTrue(Double.isNaN(StrictMath.sinh(Double.NaN)));
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath
- .sinh(Double.POSITIVE_INFINITY), 0D);
- assertEquals("Should return NEGATIVE_INFINITY",
- Double.NEGATIVE_INFINITY, StrictMath
- .sinh(Double.NEGATIVE_INFINITY), 0D);
- assertEquals(Double.doubleToLongBits(0.0), Double
- .doubleToLongBits(StrictMath.sinh(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(StrictMath.sinh(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(StrictMath.sinh(-0.0)));
-
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.sinh(1234.56), 0D);
- assertEquals("Should return NEGATIVE_INFINITY",
- Double.NEGATIVE_INFINITY, StrictMath.sinh(-1234.56), 0D);
- assertEquals("Should return 1.0000000000001666E-6",
- 1.0000000000001666E-6, StrictMath.sinh(0.000001), 0D);
- assertEquals("Should return -1.0000000000001666E-6",
- -1.0000000000001666E-6, StrictMath.sinh(-0.000001), 0D);
- assertEquals("Should return 5.115386441963859", 5.115386441963859,
- StrictMath.sinh(2.33482), 0D);
- assertEquals("Should return POSITIVE_INFINITY",
- Double.POSITIVE_INFINITY, StrictMath.sinh(Double.MAX_VALUE), 0D);
- assertEquals("Should return 4.9E-324", 4.9E-324, StrictMath
- .sinh(Double.MIN_VALUE), 0D);
- }
-
- /**
- * @tests java.lang.StrictMath#sqrt(double)
- */
- @SmallTest
- public void testSqrtD() {
- // Test for method double java.lang.StrictMath.sqrt(double)
- assertEquals("Incorrect root returned1",
- 2, StrictMath.sqrt(StrictMath.pow(StrictMath.sqrt(2), 4)), 0.0);
- assertEquals("Incorrect root returned2", 7, StrictMath.sqrt(49), 0.0);
- }
-
- /**
- * @tests java.lang.StrictMath#tan(double)
- */
- @SmallTest
- public void testTanD() {
- // Test for method double java.lang.StrictMath.tan(double)
- assertTrue(
- "Returned incorrect tangent: ",
- StrictMath.tan(StrictMath.atan(1.0)) <= 1.0
- || StrictMath.tan(StrictMath.atan(1.0)) >= 9.9999999999999983E-1);
- }
-
- /**
- * @tests java.lang.StrictMath#tanh(double)
- */
- @SmallTest
- public void testTanhD() {
- // Test for special situations
- assertTrue(Double.isNaN(StrictMath.tanh(Double.NaN)));
- assertEquals("Should return +1.0", +1.0, StrictMath
- .tanh(Double.POSITIVE_INFINITY), 0D);
- assertEquals("Should return -1.0", -1.0, StrictMath
- .tanh(Double.NEGATIVE_INFINITY), 0D);
- assertEquals(Double.doubleToLongBits(0.0), Double
- .doubleToLongBits(StrictMath.tanh(0.0)));
- assertEquals(Double.doubleToLongBits(+0.0), Double
- .doubleToLongBits(StrictMath.tanh(+0.0)));
- assertEquals(Double.doubleToLongBits(-0.0), Double
- .doubleToLongBits(StrictMath.tanh(-0.0)));
-
- assertEquals("Should return 1.0", 1.0, StrictMath.tanh(1234.56), 0D);
- assertEquals("Should return -1.0", -1.0, StrictMath.tanh(-1234.56), 0D);
- assertEquals("Should return 9.999999999996666E-7",
- 9.999999999996666E-7, StrictMath.tanh(0.000001), 0D);
- assertEquals("Should return 0.981422884124941", 0.981422884124941,
- StrictMath.tanh(2.33482), 0D);
- assertEquals("Should return 1.0", 1.0, StrictMath
- .tanh(Double.MAX_VALUE), 0D);
- assertEquals("Should return 4.9E-324", 4.9E-324, StrictMath
- .tanh(Double.MIN_VALUE), 0D);
- }
-
- /**
- * @tests java.lang.StrictMath#random()
- */
- @MediumTest
- public void testRandom() {
- // There isn't a place for these tests so just stick them here
- assertEquals("Wrong value E",
- 4613303445314885481L, Double.doubleToLongBits(StrictMath.E));
- assertEquals("Wrong value PI",
- 4614256656552045848L, Double.doubleToLongBits(StrictMath.PI));
-
- for (int i = 500; i >= 0; i--) {
- double d = StrictMath.random();
- assertTrue("Generated number is out of range: " + d, d >= 0.0
- && d < 1.0);
- }
- }
-
- /**
- * @tests java.lang.StrictMath#toRadians(double)
- */
- @MediumTest
- public void testToRadiansD() {
- for (double d = 500; d >= 0; d -= 1.0) {
- double converted = StrictMath.toDegrees(StrictMath.toRadians(d));
- assertTrue("Converted number not equal to original. d = " + d,
- converted >= d * 0.99999999 && converted <= d * 1.00000001);
- }
- }
-
- /**
- * @tests java.lang.StrictMath#toDegrees(double)
- */
- @MediumTest
- public void testToDegreesD() {
- for (double d = 500; d >= 0; d -= 1.0) {
- double converted = StrictMath.toRadians(StrictMath.toDegrees(d));
- assertTrue("Converted number not equal to original. d = " + d,
- converted >= d * 0.99999999 && converted <= d * 1.00000001);
- }
- }
-
- /**
- * @tests java.lang.StrictMath#ulp(double)
- */
- @SuppressWarnings("boxing")
- @SmallTest
- public void testUlp_D() {
- // Test for special cases
- assertTrue("Should return NaN", Double
- .isNaN(StrictMath.ulp(Double.NaN)));
- assertEquals("Returned incorrect value", Double.POSITIVE_INFINITY,
- StrictMath.ulp(Double.POSITIVE_INFINITY), 0D);
- assertEquals("Returned incorrect value", Double.POSITIVE_INFINITY,
- StrictMath.ulp(Double.NEGATIVE_INFINITY), 0D);
- assertEquals("Returned incorrect value", Double.MIN_VALUE, StrictMath
- .ulp(0.0), 0D);
- assertEquals("Returned incorrect value", Double.MIN_VALUE, StrictMath
- .ulp(+0.0), 0D);
- assertEquals("Returned incorrect value", Double.MIN_VALUE, StrictMath
- .ulp(-0.0), 0D);
- assertEquals("Returned incorrect value", StrictMath.pow(2, 971),
- StrictMath.ulp(Double.MAX_VALUE), 0D);
- assertEquals("Returned incorrect value", StrictMath.pow(2, 971),
- StrictMath.ulp(-Double.MAX_VALUE), 0D);
-
- assertEquals("Returned incorrect value", Double.MIN_VALUE, StrictMath
- .ulp(Double.MIN_VALUE), 0D);
- assertEquals("Returned incorrect value", Double.MIN_VALUE, StrictMath
- .ulp(-Double.MIN_VALUE), 0D);
-
- assertEquals("Returned incorrect value", 2.220446049250313E-16,
- StrictMath.ulp(1.0), 0D);
- assertEquals("Returned incorrect value", 2.220446049250313E-16,
- StrictMath.ulp(-1.0), 0D);
- assertEquals("Returned incorrect value", 2.2737367544323206E-13,
- StrictMath.ulp(1153.0), 0D);
- }
-
- /**
- * @tests java.lang.StrictMath#ulp(float)
- */
- @SuppressWarnings("boxing")
- @SmallTest
- public void testUlpF() {
- // Test for special cases
- assertTrue("Should return NaN", Float.isNaN(StrictMath.ulp(Float.NaN)));
- assertEquals("Returned incorrect value", Float.POSITIVE_INFINITY,
- StrictMath.ulp(Float.POSITIVE_INFINITY), 0f);
- assertEquals("Returned incorrect value", Float.POSITIVE_INFINITY,
- StrictMath.ulp(Float.NEGATIVE_INFINITY), 0f);
- assertEquals("Returned incorrect value", Float.MIN_VALUE, StrictMath
- .ulp(0.0f), 0f);
- assertEquals("Returned incorrect value", Float.MIN_VALUE, StrictMath
- .ulp(+0.0f), 0f);
- assertEquals("Returned incorrect value", Float.MIN_VALUE, StrictMath
- .ulp(-0.0f), 0f);
- assertEquals("Returned incorrect value", 2.028241E31f, StrictMath
- .ulp(Float.MAX_VALUE), 0f);
- assertEquals("Returned incorrect value", 2.028241E31f, StrictMath
- .ulp(-Float.MAX_VALUE), 0f);
-
- assertEquals("Returned incorrect value", 1.4E-45f, StrictMath
- .ulp(Float.MIN_VALUE), 0f);
- assertEquals("Returned incorrect value", 1.4E-45f, StrictMath
- .ulp(-Float.MIN_VALUE), 0f);
-
- assertEquals("Returned incorrect value", 1.1920929E-7f, StrictMath
- .ulp(1.0f), 0f);
- assertEquals("Returned incorrect value", 1.1920929E-7f, StrictMath
- .ulp(-1.0f), 0f);
- assertEquals("Returned incorrect value", 1.2207031E-4f, StrictMath
- .ulp(1153.0f), 0f);
- assertEquals("Returned incorrect value", 5.6E-45f, Math
- .ulp(9.403954E-38f), 0f);
- }
-}
diff --git a/tests/CoreTests/android/core/StringReaderTest.java b/tests/CoreTests/android/core/StringReaderTest.java
deleted file mode 100644
index 66b3e81..0000000
--- a/tests/CoreTests/android/core/StringReaderTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.StringReader;
-import android.test.suitebuilder.annotation.SmallTest;
-
-public class StringReaderTest extends TestCase {
-
- @SmallTest
- public void testStringReader() throws Exception {
- String str = "AbCdEfGhIjKlMnOpQrStUvWxYz";
-
- StringReader a = new StringReader(str);
- StringReader b = new StringReader(str);
- StringReader c = new StringReader(str);
- StringReader d = new StringReader(str);
-
- assertEquals(str, IOUtil.read(a));
- assertEquals("AbCdEfGhIj", IOUtil.read(b, 10));
- assertEquals("bdfhjlnprtvxz", IOUtil.skipRead(c));
- assertEquals("AbCdEfGdEfGhIjKlMnOpQrStUvWxYz", IOUtil.markRead(d, 3, 4));
- }
-}
diff --git a/tests/CoreTests/android/core/StringWriterTest.java b/tests/CoreTests/android/core/StringWriterTest.java
deleted file mode 100644
index fed2221..0000000
--- a/tests/CoreTests/android/core/StringWriterTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.StringWriter;
-import android.test.suitebuilder.annotation.SmallTest;
-
-public class StringWriterTest extends TestCase {
-
- @SmallTest
- public void testStringWriter() throws Exception {
- String str = "AbCdEfGhIjKlMnOpQrStUvWxYz";
- StringWriter a = new StringWriter(10);
-
- a.write(str, 0, 26);
- a.write('X');
-
- assertEquals("AbCdEfGhIjKlMnOpQrStUvWxYzX", a.toString());
-
- a.write("alphabravodelta", 5, 5);
- a.append('X');
- assertEquals("AbCdEfGhIjKlMnOpQrStUvWxYzXbravoX", a.toString());
- a.append("omega");
- assertEquals("AbCdEfGhIjKlMnOpQrStUvWxYzXbravoXomega", a.toString());
- }
-}
diff --git a/tests/CoreTests/android/core/TreeMapTest.java b/tests/CoreTests/android/core/TreeMapTest.java
deleted file mode 100644
index 229d86d..0000000
--- a/tests/CoreTests/android/core/TreeMapTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.util.HashMap;
-import java.util.Random;
-import java.util.TreeMap;
-import android.test.suitebuilder.annotation.LargeTest;
-
-/**
- * Tests for basic functinality of TreeMaps
- */
-public class TreeMapTest extends TestCase {
-
- private Random mRandom = new Random(1);
-
- private static final boolean SPEW = false;
-
- @LargeTest
- public void testTreeMap() {
- for (int i = 0; i < 10; i++) {
- if (SPEW) System.out.println("Running doTest cycle #" + (i + 1));
- doTest();
- }
- }
-
- private void doTest() {
- TreeMap<Integer, String> tm = new TreeMap<Integer, String>();
- HashMap<Integer, String> hm = new HashMap<Integer, String>();
-
- int minVal = Integer.MAX_VALUE;
- int maxVal = Integer.MIN_VALUE;
-
- for (int i = 0; i < 100; i++) {
- int val = mRandom.nextInt(1000);
- if (SPEW) System.out.println("Adding val = " + val);
- if (val < minVal) {
- minVal = val;
- }
- if (val > maxVal) {
- maxVal = val;
- }
- tm.put(new Integer(val), "V:" + val);
- hm.put(new Integer(val), "V:" + val);
-
- if (SPEW) System.out.println("tm = " + tm);
-
- if (SPEW) System.out.println("tm.size() = " + tm.size());
- if (SPEW) System.out.println("hm.size() = " + hm.size());
- assertEquals(tm.size(), hm.size());
-
- if (SPEW) System.out.println("tm.firstKey() = " + tm.firstKey());
- if (SPEW) System.out.println("minVal = " + minVal);
- if (SPEW) System.out.println("tm.lastKey() = " + tm.lastKey());
- if (SPEW) System.out.println("maxVal = " + maxVal);
- assertEquals(minVal, tm.firstKey().intValue());
- assertEquals(maxVal, tm.lastKey().intValue());
- }
-
- // Check for equality
- for (int val = 0; val < 1000; val++) {
- Integer vv = new Integer(val);
- String tms = tm.get(vv);
- String hms = hm.get(vv);
- assertEquals(tms, hms);
- }
-
- for (int i = 0; i < 1000; i++) {
- int val = mRandom.nextInt(1000);
- if (SPEW) System.out.println("Removing val = " + val);
-
- String tms = tm.remove(new Integer(val));
- String hms = hm.remove(new Integer(val));
-
- if (SPEW) System.out.println("tm = " + tm);
-
- assertEquals(tm.size(), hm.size());
- assertEquals(tms, hms);
- }
-
- // Check for equality
- for (int val = 0; val < 1000; val++) {
- Integer vv = new Integer(val);
- String tms = tm.get(vv);
- String hms = hm.get(vv);
- assertEquals(tms, hms);
- }
- }
-}
diff --git a/tests/CoreTests/android/core/URITest.java b/tests/CoreTests/android/core/URITest.java
deleted file mode 100644
index 3b821d8..0000000
--- a/tests/CoreTests/android/core/URITest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import android.test.suitebuilder.annotation.SmallTest;
-
-public class URITest extends TestCase {
-
- @SmallTest
- public void testConstruct() throws Exception {
- construct("http://www.google.com/this/is-the/path?query#fragment",
- "www.google.com", "/this/is-the/path", true);
- }
-
- private static void construct(String str, String host, String path, boolean absolute)
- throws URISyntaxException {
- URI uri = new URI(str);
- assertEquals(host, uri.getHost());
- assertEquals(path, uri.getPath());
- assertEquals(absolute, uri.isAbsolute());
- }
-
- @SmallTest
- public void testResolve() throws Exception {
- resolve("http://www.google.com/your",
- "mom",
- "http://www.google.com/mom");
- }
-
- private static void resolve(String base, String uri, String expected) {
- URI b = URI.create(base);
- URI resolved = b.resolve(uri);
-// System.out.println("base=" + base + " uri=" + uri
-// + " resolved=" + resolved);
- assertEquals(expected, resolved.toString());
- }
-}
diff --git a/tests/CoreTests/android/core/ZipFileTest.java b/tests/CoreTests/android/core/ZipFileTest.java
deleted file mode 100644
index 04b476b..0000000
--- a/tests/CoreTests/android/core/ZipFileTest.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Enumeration;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipOutputStream;
-import android.test.suitebuilder.annotation.MediumTest;
-
-
-/**
- * Basic tests for ZipFile.
- */
-public class ZipFileTest extends TestCase {
- private static final int SAMPLE_SIZE = 128 * 1024;
-
- @MediumTest
- public void testZipFile() throws Exception {
-
- File file = File.createTempFile("ZipFileTest", ".zip");
- try {
- // create a test file; assume it's not going to collide w/anything
- FileOutputStream outStream = new FileOutputStream(file);
- createCompressedZip(outStream);
-// System.out.println("CREATED " + file);
-
- scanZip(file.getPath());
- read2(file.getPath());
- } finally {
- file.delete();
- }
- }
-
- /*
- * stepStep == 0 --> >99% compression
- * stepStep == 1 --> ~30% compression
- * stepStep == 2 --> no compression
- */
- static byte[] makeSampleFile(int stepStep) throws IOException {
- byte[] sample = new byte[SAMPLE_SIZE];
- byte val, step;
- int i, j, offset;
-
- val = 0;
- step = 1;
- offset = 0;
- for (i = 0; i < SAMPLE_SIZE / 256; i++) {
- for (j = 0; j < 256; j++) {
- sample[offset++] = val;
- val += step;
- }
-
- step += stepStep;
- }
-
- return sample;
- }
-
- static void createCompressedZip(OutputStream bytesOut) throws IOException {
- ZipOutputStream out = new ZipOutputStream(bytesOut);
- try {
- int i;
-
- for (i = 0; i < 3; i++) {
- byte[] input = makeSampleFile(i);
- ZipEntry newEntry = new ZipEntry("file-" + i);
-
- if (i != 1) {
- newEntry.setComment("this is file " + i);
- }
- out.putNextEntry(newEntry);
- out.write(input, 0, input.length);
- out.closeEntry();
- }
-
- out.setComment("This is a lovely compressed archive!");
- } finally {
- out.close();
- }
- }
-
- static void scanZip(String fileName) throws IOException {
- ZipFile zipFile = new ZipFile(fileName);
- Enumeration fileList;
- int idx = 0;
-
-// System.out.println("Contents of " + zipFile + ":");
- for (fileList = zipFile.entries(); fileList.hasMoreElements();) {
- ZipEntry entry = (ZipEntry) fileList.nextElement();
-// System.out.println(" " + entry.getName());
- assertEquals(entry.getName(), "file-" + idx);
- idx++;
- }
-
- zipFile.close();
- }
-
- /*
- * Read compressed data from two different entries at the same time,
- * to verify that the streams aren't getting confused. If we do
- * something wrong, the inflater will choke and throw a ZipException.
- *
- * This doesn't test synchronization in multi-threaded use.
- */
- static void read2(String fileName) throws IOException {
- ZipFile zipFile;
- ZipEntry entry1, entry2;
- byte buf[] = new byte[16384];
- InputStream stream1, stream2;
- int len, totalLen1, totalLen2;
-
- /* use file-1 and file-2 because the compressed data is large */
- zipFile = new ZipFile(fileName);
- entry1 = zipFile.getEntry("file-1");
- entry2 = zipFile.getEntry("file-2");
-
- /* make sure we got the right thing */
- assertEquals("file-1", entry1.getName());
- assertEquals("file-2", entry2.getName());
-
- /* create streams */
- stream1 = zipFile.getInputStream(entry1);
- stream2 = zipFile.getInputStream(entry2);
-
- /*
- * Read a piece of file #1.
- */
- totalLen1 = stream1.read(buf);
- assertTrue("initial read failed on #1", totalLen1 >= 0);
-
- /*
- * Read a piece of file #2.
- */
- totalLen2 = stream2.read(buf);
- assertTrue("initial read failed on #2", totalLen2 >= 0);
-
- /*
- * Read the rest of file #1, and close the stream.
- *
- * If our streams are crossed up, we'll fail here.
- */
- while ((len = stream1.read(buf)) > 0) {
- totalLen1 += len;
- }
- assertEquals(SAMPLE_SIZE, totalLen1);
- stream1.close();
-
- /*
- * Read the rest of file #2, and close the stream.
- */
- while ((len = stream2.read(buf)) > 0) {
- totalLen2 += len;
- }
- assertEquals(SAMPLE_SIZE, totalLen2);
- stream2.close();
-
- /*
- * Open a new one.
- */
- stream1 = zipFile.getInputStream(zipFile.getEntry("file-0"));
-
- /*
- * Close the ZipFile. According to the RI, none if its InputStreams can
- * be read after this point.
- */
- zipFile.close();
-
- Exception error = null;
- try {
- stream1.read(buf);
- } catch (Exception ex) {
- error = ex;
- }
-
- assertNotNull("ZipFile shouldn't allow reading of closed files.", error);
- }
-}
-
diff --git a/tests/CoreTests/android/core/ZipStreamTest.java b/tests/CoreTests/android/core/ZipStreamTest.java
deleted file mode 100644
index 74cfe82..0000000
--- a/tests/CoreTests/android/core/ZipStreamTest.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.core;
-
-import junit.framework.TestCase;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-import java.util.zip.ZipOutputStream;
-import android.test.suitebuilder.annotation.LargeTest;
-
-/**
- * Basic tests for ZipStream
- */
-public class ZipStreamTest extends TestCase {
-
- @LargeTest
- public void testZipStream() throws Exception {
- ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
- createCompressedZip(bytesOut);
-
- byte[] zipData = bytesOut.toByteArray();
-
- /*
- FileOutputStream outFile = new FileOutputStream("/tmp/foo.zip");
- outFile.write(zipData, 0, zipData.length);
- outFile.close();
- */
-
- /*
- FileInputStream inFile = new FileInputStream("/tmp/foo.zip");
- int inputLength = inFile.available();
- zipData = new byte[inputLength];
- if (inFile.read(zipData) != inputLength)
- throw new RuntimeException();
- inFile.close();
- */
-
- ByteArrayInputStream bytesIn = new ByteArrayInputStream(zipData);
- scanZip(bytesIn);
-
- bytesOut = new ByteArrayOutputStream();
- createUncompressedZip(bytesOut);
-
- zipData = bytesOut.toByteArray();
-
- bytesIn = new ByteArrayInputStream(zipData);
- scanZip(bytesIn);
- }
-
- /*
- * stepStep == 0 --> >99% compression
- * stepStep == 1 --> ~30% compression
- * stepStep == 2 --> no compression
- */
- private static byte[] makeSampleFile(int stepStep) throws IOException {
- byte[] sample = new byte[128 * 1024];
- byte val, step;
- int i, j, offset;
-
- val = 0;
- step = 1;
- offset = 0;
- for (i = 0; i < (128 * 1024) / 256; i++) {
- for (j = 0; j < 256; j++) {
- sample[offset++] = val;
- val += step;
- }
-
- step += stepStep;
- }
-
- return sample;
- }
-
- private static void createCompressedZip(ByteArrayOutputStream bytesOut) throws IOException {
- ZipOutputStream out = new ZipOutputStream(bytesOut);
- try {
- int i;
-
- for (i = 0; i < 3; i++) {
- byte[] input = makeSampleFile(i);
- ZipEntry newEntry = new ZipEntry("file-" + i);
-
- if (i != 1)
- newEntry.setComment("this is file " + i);
- out.putNextEntry(newEntry);
- out.write(input, 0, input.length);
- out.closeEntry();
- }
-
- out.setComment("This is a lovely compressed archive!");
- } finally {
- out.close();
- }
- }
-
- private static void createUncompressedZip(ByteArrayOutputStream bytesOut) throws IOException {
- ZipOutputStream out = new ZipOutputStream(bytesOut);
- try {
- long[] crcs = {0x205fbff3, 0x906fae57L, 0x2c235131};
- int i;
-
- for (i = 0; i < 3; i++) {
- byte[] input = makeSampleFile(i);
- ZipEntry newEntry = new ZipEntry("file-" + i);
-
- if (i != 1)
- newEntry.setComment("this is file " + i);
- newEntry.setMethod(ZipEntry.STORED);
- newEntry.setSize(128 * 1024);
- newEntry.setCrc(crcs[i]);
- out.putNextEntry(newEntry);
- out.write(input, 0, input.length);
- out.closeEntry();
- }
-
- out.setComment("This is a lovely, but uncompressed, archive!");
- } finally {
- out.close();
- }
- }
-
- private static void scanZip(ByteArrayInputStream bytesIn) throws IOException {
- ZipInputStream in = new ZipInputStream(bytesIn);
- try {
- int i;
-
- for (i = 0; i < 3; i++) {
- ZipEntry entry = in.getNextEntry();
- ByteArrayOutputStream contents = new ByteArrayOutputStream();
- byte[] buf = new byte[4096];
- int len, totalLen = 0;
-
- while ((len = in.read(buf)) > 0) {
- contents.write(buf, 0, len);
- totalLen += len;
- }
-
- assertEquals(128 * 1024, totalLen);
-
-// System.out.println("ZipStreamTest: name='" + entry.getName()
-// + "', zero=" + contents.toByteArray()[0]
-// + ", tfs=" + contents.toByteArray()[257]
-// + ", crc=" + Long.toHexString(entry.getCrc()));
- }
-
- assertNull("should only be three entries", in.getNextEntry());
- } finally {
- in.close();
- }
- }
-}
-