diff options
| author | The Android Open Source Project <initial-contribution@android.com> | 2008-10-21 07:00:00 -0700 |
|---|---|---|
| committer | The Android Open Source Project <initial-contribution@android.com> | 2008-10-21 07:00:00 -0700 |
| commit | 2ad60cfc28e14ee8f0bb038720836a4696c478ad (patch) | |
| tree | 19f1bb30ab7ff96f1e3e59a60b61dcd2aeddda93 /tests/011-array-copy | |
| download | android_dalvik-2ad60cfc28e14ee8f0bb038720836a4696c478ad.tar.gz android_dalvik-2ad60cfc28e14ee8f0bb038720836a4696c478ad.tar.bz2 android_dalvik-2ad60cfc28e14ee8f0bb038720836a4696c478ad.zip | |
Initial Contribution
Diffstat (limited to 'tests/011-array-copy')
| -rw-r--r-- | tests/011-array-copy/expected.txt | 4 | ||||
| -rw-r--r-- | tests/011-array-copy/info.txt | 6 | ||||
| -rw-r--r-- | tests/011-array-copy/src/Iface1.java | 14 | ||||
| -rw-r--r-- | tests/011-array-copy/src/Iface2.java | 10 | ||||
| -rw-r--r-- | tests/011-array-copy/src/ImplA.java | 15 | ||||
| -rw-r--r-- | tests/011-array-copy/src/Main.java | 41 |
6 files changed, 90 insertions, 0 deletions
diff --git a/tests/011-array-copy/expected.txt b/tests/011-array-copy/expected.txt new file mode 100644 index 000000000..0ef202995 --- /dev/null +++ b/tests/011-array-copy/expected.txt @@ -0,0 +1,4 @@ +string -> object +object -> string +object -> string (modified) +caught ArrayStoreException (expected) diff --git a/tests/011-array-copy/info.txt b/tests/011-array-copy/info.txt new file mode 100644 index 000000000..08127da23 --- /dev/null +++ b/tests/011-array-copy/info.txt @@ -0,0 +1,6 @@ +This is a miscellaneous test that was imported into the new-at-the-time +runtime test framework. The test is intended to exercise basic features, +and as such cannot be build on top of junit, since failure of such basic +features might disrupt junit. + +TODO: Real description goes here. diff --git a/tests/011-array-copy/src/Iface1.java b/tests/011-array-copy/src/Iface1.java new file mode 100644 index 000000000..12dcfe78b --- /dev/null +++ b/tests/011-array-copy/src/Iface1.java @@ -0,0 +1,14 @@ +// Copyright 2005 The Android Open Source Project + +/** + * Test stuff. + */ +public interface Iface1 { + + public int iFunc1(int ii); + + public float mFloaty = 5.0f; + + public String mWahoo = new String("wahoo"); +} + diff --git a/tests/011-array-copy/src/Iface2.java b/tests/011-array-copy/src/Iface2.java new file mode 100644 index 000000000..6f8c2622b --- /dev/null +++ b/tests/011-array-copy/src/Iface2.java @@ -0,0 +1,10 @@ +// Copyright 2006 The Android Open Source Project + +/** + * Another interface. + */ +public interface Iface2 { + + public int iFunc2(int ii); +} + diff --git a/tests/011-array-copy/src/ImplA.java b/tests/011-array-copy/src/ImplA.java new file mode 100644 index 000000000..9949d010f --- /dev/null +++ b/tests/011-array-copy/src/ImplA.java @@ -0,0 +1,15 @@ +// Copyright 2006 The Android Open Source Project + +/** + * Blah. + */ +public class ImplA implements Iface1, Iface2 { + + public int iFunc1(int ii) { + return ii+1; + } + public int iFunc2(int ii) { + return ii+2; + } +} + diff --git a/tests/011-array-copy/src/Main.java b/tests/011-array-copy/src/Main.java new file mode 100644 index 000000000..9cb8238fe --- /dev/null +++ b/tests/011-array-copy/src/Main.java @@ -0,0 +1,41 @@ +/* + * 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. + */ + +/** + * System.arraycopy cases + */ +public class Main { + public static void main(String args[]) { + String[] stringArray = new String[8]; + Object[] objectArray = new Object[8]; + + for (int i = 0; i < stringArray.length; i++) + stringArray[i] = new String(Integer.toString(i)); + + System.out.println("string -> object"); + System.arraycopy(stringArray, 0, objectArray, 0, stringArray.length); + System.out.println("object -> string"); + System.arraycopy(objectArray, 0, stringArray, 0, stringArray.length); + System.out.println("object -> string (modified)"); + objectArray[4] = new ImplA(); + try { + System.arraycopy(objectArray, 0, stringArray, 0,stringArray.length); + } + catch (ArrayStoreException ase) { + System.out.println("caught ArrayStoreException (expected)"); + } + } +} |
