diff options
author | jeffhao <jeffhao@google.com> | 2011-09-29 17:41:15 -0700 |
---|---|---|
committer | jeffhao <jeffhao@google.com> | 2011-09-29 17:41:15 -0700 |
commit | 5d1ac920fdaef5d4ec8f66bb734488cd9660b024 (patch) | |
tree | dd372f306ab70f4c86759869b1f74eca62ff6f2b /test/015-switch | |
parent | c31664f3d82e6cd68275a529a8a73f067a52e8be (diff) | |
download | art-5d1ac920fdaef5d4ec8f66bb734488cd9660b024.tar.gz art-5d1ac920fdaef5d4ec8f66bb734488cd9660b024.tar.bz2 art-5d1ac920fdaef5d4ec8f66bb734488cd9660b024.zip |
Adding old unit tests to test suite.
These tests are copied straight over. They'll still run, but they're
using the old system.
Change-Id: If494519e52ddf858a9febfc55bdae830468cb3c8
Diffstat (limited to 'test/015-switch')
-rw-r--r-- | test/015-switch/expected.txt | 10 | ||||
-rw-r--r-- | test/015-switch/info.txt | 6 | ||||
-rw-r--r-- | test/015-switch/src/Main.java | 105 |
3 files changed, 121 insertions, 0 deletions
diff --git a/test/015-switch/expected.txt b/test/015-switch/expected.txt new file mode 100644 index 0000000000..ca3b518f03 --- /dev/null +++ b/test/015-switch/expected.txt @@ -0,0 +1,10 @@ +CORRECT (one) +CORRECT (not found) +CORRECT (large) +CORRECT (large2) +CORRECT (large3) +CORRECT (not found) +CORRECT (not found) +CORRECT (default only) +CORRECT big sparse / first +CORRECT big sparse / last diff --git a/test/015-switch/info.txt b/test/015-switch/info.txt new file mode 100644 index 0000000000..08127da231 --- /dev/null +++ b/test/015-switch/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/test/015-switch/src/Main.java b/test/015-switch/src/Main.java new file mode 100644 index 0000000000..7198e2b7b9 --- /dev/null +++ b/test/015-switch/src/Main.java @@ -0,0 +1,105 @@ +/* + * 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. + */ + +/** + * Test switch() blocks + */ +public class Main { + public static void main(String args[]) { + int a = 1; + + switch (a) { + case -1: System.out.print("neg one\n"); break; + case 0: System.out.print("zero\n"); break; + case 1: System.out.print("CORRECT (one)\n"); break; + case 2: System.out.print("two\n"); break; + case 3: System.out.print("three\n"); break; + case 4: System.out.print("four\n"); break; + default: System.out.print("???\n"); break; + } + switch (a) { + case 3: System.out.print("three\n"); break; + case 4: System.out.print("four\n"); break; + default: System.out.print("CORRECT (not found)\n"); break; + } + + a = 0x12345678; + + switch (a) { + case 0x12345678: System.out.print("CORRECT (large)\n"); break; + case 0x12345679: System.out.print("large+1\n"); break; + default: System.out.print("nuts\n"); break; + } + switch (a) { + case 0x12345678: System.out.print("CORRECT (large2)\n"); break; + case 0x12345700: System.out.print("large+many\n"); break; + default: System.out.print("nuts\n"); break; + } + switch (a) { + case 57: System.out.print("fifty-seven!\n"); break; + case -6: System.out.print("neg six!\n"); break; + case 0x12345678: System.out.print("CORRECT (large3)\n"); break; + case 22: System.out.print("twenty-two!\n"); break; + case 3: System.out.print("three!\n"); break; + default: System.out.print("huh?\n"); break; + } + switch (a) { + case -6: System.out.print("neg six!\n"); break; + case 3: System.out.print("three!\n"); break; + default: System.out.print("CORRECT (not found)\n"); break; + } + + a = -5; + switch (a) { + case 12: System.out.print("twelve\n"); break; + case -5: System.out.print("CORRECT (not found)\n"); break; + case 0: System.out.print("zero\n"); break; + default: System.out.print("wah?\n"); break; + } + + switch (a) { + default: System.out.print("CORRECT (default only)\n"); break; + } + + a = -10; + switch (a) { + case -10: System.out.print("CORRECT big sparse / first\n"); break; + case -5: System.out.print("neg five\n"); break; + case 0: System.out.print("zero\n"); break; + case 5: System.out.print("five\n"); break; + case 10: System.out.print("ten\n"); break; + case 15: System.out.print("fifteen\n"); break; + case 20: System.out.print("twenty\n"); break; + case 50: System.out.print("fifty\n"); break; + case 100: System.out.print("hundred\n"); break; + default: System.out.print("blah!\n"); break; + } + + a = 100; + switch (a) { + case -10: System.out.print("neg ten\n"); break; + case -5: System.out.print("neg five\n"); break; + case 0: System.out.print("zero\n"); break; + case 5: System.out.print("five\n"); break; + case 10: System.out.print("ten\n"); break; + case 15: System.out.print("fifteen\n"); break; + case 20: System.out.print("twenty\n"); break; + case 50: System.out.print("fifty\n"); break; + case 100: System.out.print("CORRECT big sparse / last\n"); break; + default: System.out.print("blah!\n"); break; + } + } +} |