1 43 44 package org.jfree.util.junit; 45 46 import junit.framework.Test; 47 import junit.framework.TestCase; 48 import junit.framework.TestSuite; 49 50 import org.jfree.util.ArrayUtilities; 51 52 55 public class ArrayUtilitiesTests extends TestCase { 56 57 62 public static Test suite() { 63 return new TestSuite(ArrayUtilitiesTests.class); 64 } 65 66 71 public ArrayUtilitiesTests(String name) { 72 super(name); 73 } 74 75 78 public void testHasDuplicateItems() { 79 Object [] a1 = new Object [] {"1", "2", "3"}; 80 Object [] a2 = new Object [] {"1", "1", "3"}; 81 Object [] a3 = new Object [] {null, "2", null}; 82 assertFalse(ArrayUtilities.hasDuplicateItems(a1)); 83 assertTrue(ArrayUtilities.hasDuplicateItems(a2)); 84 assertFalse(ArrayUtilities.hasDuplicateItems(a3)); 85 } 86 87 90 public void testEqualReferencesInArrays() { 91 Object [] a1 = new Object [] {}; 92 Object [] a2 = new Object [] {}; 93 Object [] a3 = new Object [] {null}; 94 Object [] a4 = new Object [] {null}; 95 Object [] a5 = new Object [] {"A"}; 96 Object [] a6 = new Object [] {"A"}; 97 Object [] a7 = new Object [] {"A", "B"}; 98 Object [] a8 = new Object [] {"A", "B"}; 99 Object [] a9 = new Object [] {"A", null}; 100 Object [] a10 = new Object [] {"A", null}; 101 102 assertTrue(ArrayUtilities.equalReferencesInArrays(a1, a2)); 103 assertFalse(ArrayUtilities.equalReferencesInArrays(a1, a3)); 104 assertTrue(ArrayUtilities.equalReferencesInArrays(a3, a4)); 105 assertFalse(ArrayUtilities.equalReferencesInArrays(a3, a5)); 106 assertTrue(ArrayUtilities.equalReferencesInArrays(a5, a6)); 107 assertFalse(ArrayUtilities.equalReferencesInArrays(a5, a7)); 108 assertTrue(ArrayUtilities.equalReferencesInArrays(a7, a8)); 109 assertFalse(ArrayUtilities.equalReferencesInArrays(a7, a9)); 110 assertTrue(ArrayUtilities.equalReferencesInArrays(a9, a10)); 111 } 112 } 113 | Popular Tags |