| The Android Open Source Project | 2ad60cf | 2008-10-21 07:00:00 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | public class Blort |
| 18 | { |
| 19 | // Empty switch statement. (Note: This is the same as a default-only |
| 20 | // switch statement, since under the covers every switch statement |
| 21 | // has a default of some sort.) |
| 22 | public int test1(int x) { |
| 23 | switch (x) { |
| 24 | // This space intentionally left blank. |
| 25 | } |
| 26 | |
| 27 | return 0; |
| 28 | } |
| 29 | |
| 30 | // Single element. |
| 31 | public int test2(int x) { |
| 32 | switch (x) { |
| 33 | case 0: return 0; |
| 34 | } |
| 35 | |
| 36 | return 1; |
| 37 | } |
| 38 | |
| 39 | // Single element: Integer.MIN_VALUE. |
| 40 | public int test3(int x) { |
| 41 | switch (x) { |
| 42 | case Integer.MIN_VALUE: return 0; |
| 43 | } |
| 44 | |
| 45 | return 1; |
| 46 | } |
| 47 | |
| 48 | // Single element: Integer.MAX_VALUE. |
| 49 | public int test4(int x) { |
| 50 | switch (x) { |
| 51 | case Integer.MAX_VALUE: return 0; |
| 52 | } |
| 53 | |
| 54 | return 1; |
| 55 | } |
| 56 | |
| 57 | // Two elements: 0 and Integer.MIN_VALUE. |
| 58 | public int test5(int x) { |
| 59 | switch (x) { |
| 60 | case 0: return 0; |
| 61 | case Integer.MIN_VALUE: return 1; |
| 62 | } |
| 63 | |
| 64 | return 2; |
| 65 | } |
| 66 | |
| 67 | // Two elements: 0 and Integer.MAX_VALUE. |
| 68 | public int test6(int x) { |
| 69 | switch (x) { |
| 70 | case 0: return 0; |
| 71 | case Integer.MAX_VALUE: return 1; |
| 72 | } |
| 73 | |
| 74 | return 2; |
| 75 | } |
| 76 | |
| 77 | // Two elements: Integer.MIN_VALUE and Integer.MAX_VALUE. |
| 78 | public int test7(int x) { |
| 79 | switch (x) { |
| 80 | case Integer.MIN_VALUE: return 0; |
| 81 | case Integer.MAX_VALUE: return 1; |
| 82 | } |
| 83 | |
| 84 | return 2; |
| 85 | } |
| 86 | |
| 87 | // Two elements: Large enough to be packed but such that 32 bit |
| 88 | // threshold calculations could overflow. |
| 89 | public int test8(int x) { |
| 90 | switch (x) { |
| 91 | case 0: return 0; |
| 92 | case 0x4cccccc8: return 1; |
| 93 | } |
| 94 | |
| 95 | return 2; |
| 96 | } |
| 97 | } |