| 958 | } |
| 959 | |
| 960 | public void testToArray() { |
| 961 | final int allocated[] = { 0 }; |
| 962 | PublicTestStructure.allocations = 0; |
| 963 | PublicTestStructure s = new PublicTestStructure(); |
| 964 | PublicTestStructure[] array = (PublicTestStructure[])s.toArray(1); |
| 965 | assertEquals("Array should consist of a single element", |
| 966 | 1, array.length); |
| 967 | assertEquals("First element should be original", s, array[0]); |
| 968 | |
| 969 | array = (PublicTestStructure[])s.toArray(2); |
| 970 | assertEquals("Structure memory should be expanded", 2, array.length); |
| 971 | assertEquals("No memory should be allocated for new element", 1, PublicTestStructure.allocations); |
| 972 | assertEquals("Structure.read called on New element", 0, array[1].x); |
| 973 | } |
| 974 | |
| 975 | public void testByReferenceArraySync() { |
| 976 | PublicTestStructure.ByReference s = new PublicTestStructure.ByReference(); |