001: //--------------------------------------------------------------------------
002: // Copyright (c) 2004, Drew Davidson and Luke Blanshard
003: // All rights reserved.
004: //
005: // Redistribution and use in source and binary forms, with or without
006: // modification, are permitted provided that the following conditions are
007: // met:
008: //
009: // Redistributions of source code must retain the above copyright notice,
010: // this list of conditions and the following disclaimer.
011: // Redistributions in binary form must reproduce the above copyright
012: // notice, this list of conditions and the following disclaimer in the
013: // documentation and/or other materials provided with the distribution.
014: // Neither the name of the Drew Davidson nor the names of its contributors
015: // may be used to endorse or promote products derived from this software
016: // without specific prior written permission.
017: //
018: // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
019: // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
020: // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
021: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
022: // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
023: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
024: // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
025: // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
026: // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
027: // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
028: // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
029: // DAMAGE.
030: //--------------------------------------------------------------------------
031: package org.ognl.test;
032:
033: import junit.framework.TestSuite;
034: import org.ognl.test.objects.Root;
035:
036: public class PrimitiveArrayTest extends OgnlTestCase {
037: private static Root ROOT = new Root();
038:
039: private static Object[][] TESTS = {
040: // Primitive array creation
041: { ROOT, "new boolean[5]", new boolean[5] },
042: { ROOT, "new boolean[] { true, false }",
043: new boolean[] { true, false } },
044: { ROOT, "new boolean[] { 0, 1, 5.5 }",
045: new boolean[] { false, true, true } },
046: { ROOT, "new char[] { 'a', 'b' }", new char[] { 'a', 'b' } },
047: { ROOT, "new char[] { 10, 11 }",
048: new char[] { (char) 10, (char) 11 } },
049: { ROOT, "new byte[] { 1, 2 }", new byte[] { 1, 2 } },
050: { ROOT, "new short[] { 1, 2 }", new short[] { 1, 2 } },
051: { ROOT, "new int[six]", new int[ROOT.six] },
052: { ROOT, "new int[#root.six]", new int[ROOT.six] },
053: { ROOT, "new int[6]", new int[6] },
054: { ROOT, "new int[] { 1, 2 }", new int[] { 1, 2 } },
055: { ROOT, "new long[] { 1, 2 }", new long[] { 1, 2 } },
056: { ROOT, "new float[] { 1, 2 }", new float[] { 1, 2 } },
057: { ROOT, "new double[] { 1, 2 }", new double[] { 1, 2 } }, };
058:
059: /*===================================================================
060: Public static methods
061: ===================================================================*/
062: public static TestSuite suite() {
063: TestSuite result = new TestSuite();
064:
065: for (int i = 0; i < TESTS.length; i++) {
066: if (TESTS[i].length == 3) {
067: result.addTest(new PrimitiveArrayTest(
068: (String) TESTS[i][1], TESTS[i][0],
069: (String) TESTS[i][1], TESTS[i][2]));
070: } else {
071: if (TESTS[i].length == 4) {
072: result.addTest(new PrimitiveArrayTest(
073: (String) TESTS[i][1], TESTS[i][0],
074: (String) TESTS[i][1], TESTS[i][2],
075: TESTS[i][3]));
076: } else {
077: if (TESTS[i].length == 5) {
078: result.addTest(new PrimitiveArrayTest(
079: (String) TESTS[i][1], TESTS[i][0],
080: (String) TESTS[i][1], TESTS[i][2],
081: TESTS[i][3], TESTS[i][4]));
082: } else {
083: throw new RuntimeException(
084: "don't understand TEST format");
085: }
086: }
087: }
088: }
089: return result;
090: }
091:
092: /*===================================================================
093: Constructors
094: ===================================================================*/
095: public PrimitiveArrayTest() {
096: super ();
097: }
098:
099: public PrimitiveArrayTest(String name) {
100: super (name);
101: }
102:
103: public PrimitiveArrayTest(String name, Object root,
104: String expressionString, Object expectedResult,
105: Object setValue, Object expectedAfterSetResult) {
106: super (name, root, expressionString, expectedResult, setValue,
107: expectedAfterSetResult);
108: }
109:
110: public PrimitiveArrayTest(String name, Object root,
111: String expressionString, Object expectedResult,
112: Object setValue) {
113: super (name, root, expressionString, expectedResult, setValue);
114: }
115:
116: public PrimitiveArrayTest(String name, Object root,
117: String expressionString, Object expectedResult) {
118: super(name, root, expressionString, expectedResult);
119: }
120: }
|