Skip to content

Commit 0d7b49c

Browse files
committed
changed test programs for support of GenericArrayType
1 parent 3c684db commit 0d7b49c

5 files changed

Lines changed: 435 additions & 7 deletions

File tree

src/test/java/org/msgpack/template/builder/TestSet.java

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,19 @@ public void testListTypeFieldsClass() throws Exception {
145145
v.f5.add(ByteBuffer.wrap("e1".getBytes()));
146146
v.f5.add(ByteBuffer.wrap("e2".getBytes()));
147147
v.f5.add(ByteBuffer.wrap("e3".getBytes()));
148+
v.f6 = new ArrayList<int[]>();
149+
v.f6.add(new int[] { 1, 2, 3 });
150+
v.f6.add(new int[] { 3, 3, 3 });
151+
v.f7 = new ArrayList<String[]>();
152+
v.f7.add(new String[] { "muga", "nishizawa", "fryusuki" });
153+
v.f8 = new ArrayList<ListTypeFieldsClass.NestedClass[]>();
154+
ListTypeFieldsClass.NestedClass nested01 = new ListTypeFieldsClass.NestedClass();
155+
nested01.f0 = new byte[] { 0x01, 0x02 };
156+
nested01.f1 = "muga";
157+
ListTypeFieldsClass.NestedClass nested02 = new ListTypeFieldsClass.NestedClass();
158+
nested02.f0 = new byte[] { 0x01, 0x02 };
159+
nested02.f1 = "muga";
160+
v.f8.add(new ListTypeFieldsClass.NestedClass[] { nested01, nested02 });
148161
testListTypeFieldsClass(v);
149162
}
150163

@@ -180,6 +193,19 @@ public void testListTypeFieldsClassNotNullable() throws Exception {
180193
v.f5.add(ByteBuffer.wrap("e1".getBytes()));
181194
v.f5.add(ByteBuffer.wrap("e2".getBytes()));
182195
v.f5.add(ByteBuffer.wrap("e3".getBytes()));
196+
v.f6 = new ArrayList<int[]>();
197+
v.f6.add(new int[] { 1, 2, 3 });
198+
v.f6.add(new int[] { 3, 3, 3 });
199+
v.f7 = new ArrayList<String[]>();
200+
v.f7.add(new String[] { "muga", "nishizawa", "fryusuki" });
201+
v.f8 = new ArrayList<ListTypeFieldsClassNotNullable.NestedClass[]>();
202+
ListTypeFieldsClassNotNullable.NestedClass nested01 = new ListTypeFieldsClassNotNullable.NestedClass();
203+
nested01.f0 = new byte[] { 0x01, 0x02 };
204+
nested01.f1 = "muga";
205+
ListTypeFieldsClassNotNullable.NestedClass nested02 = new ListTypeFieldsClassNotNullable.NestedClass();
206+
nested02.f0 = new byte[] { 0x01, 0x02 };
207+
nested02.f1 = "muga";
208+
v.f8.add(new ListTypeFieldsClassNotNullable.NestedClass[] { nested01, nested02 });
183209
testListTypeFieldsClassNotNullable(v);
184210
}
185211

@@ -200,9 +226,19 @@ public void testMapTypeFieldsClass() throws Exception {
200226
v.f2.put("k2", 2);
201227
v.f2.put("k3", 3);
202228
v.f3 = new HashMap<String, MapTypeFieldsClass.NestedClass>();
203-
MapTypeFieldsClass.NestedClass nested = new MapTypeFieldsClass.NestedClass();
204-
nested.f0 = "muga";
205-
v.f3.put("muga", nested);
229+
MapTypeFieldsClass.NestedClass nested01 = new MapTypeFieldsClass.NestedClass();
230+
nested01.f0 = "muga";
231+
v.f3.put("muga", nested01);
232+
v.f4 = new HashMap<String, int[]>();
233+
v.f4.put("nishizawa", new int[] { 1, 2, 3 });
234+
v.f4.put("fryusuki", new int[] { 3, 3, 3 });
235+
v.f5 = new HashMap<String, String[]>();
236+
v.f5.put("muga", new String[] { "f1", "f2", "f3" });
237+
v.f5.put("nishizawa", new String[] { "f3", "f2", "f1" });
238+
v.f6 = new HashMap<String, MapTypeFieldsClass.NestedClass[]>();
239+
MapTypeFieldsClass.NestedClass nested02 = new MapTypeFieldsClass.NestedClass();
240+
nested02.f0 = "nishizawa";
241+
v.f6.put("muga", new MapTypeFieldsClass.NestedClass[] { nested02 });
206242
testMapTypeFieldsClass(v);
207243
}
208244

@@ -231,6 +267,16 @@ public void testMapTypeFieldsClassNotNullable() throws Exception {
231267
MapTypeFieldsClassNotNullable.NestedClass nested = new MapTypeFieldsClassNotNullable.NestedClass();
232268
nested.f0 = "muga";
233269
v.f3.put("muga", nested);
270+
v.f4 = new HashMap<String, int[]>();
271+
v.f4.put("nishizawa", new int[] { 1, 2, 3 });
272+
v.f4.put("fryusuki", new int[] { 3, 3, 3 });
273+
v.f5 = new HashMap<String, String[]>();
274+
v.f5.put("muga", new String[] { "f1", "f2", "f3" });
275+
v.f5.put("nishizawa", new String[] { "f3", "f2", "f1" });
276+
v.f6 = new HashMap<String, MapTypeFieldsClassNotNullable.NestedClass[]>();
277+
MapTypeFieldsClassNotNullable.NestedClass nested02 = new MapTypeFieldsClassNotNullable.NestedClass();
278+
nested02.f0 = "nishizawa";
279+
v.f6.put("muga", new MapTypeFieldsClassNotNullable.NestedClass[] { nested02 });
234280
testMapTypeFieldsClassNotNullable(v);
235281
}
236282

src/test/java/org/msgpack/testclasses/ListTypeFieldsClass.java

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ public class ListTypeFieldsClass {
2424

2525
public List<ByteBuffer> f5;
2626

27+
public List<int[]> f6;
28+
29+
public List<String[]> f7;
30+
31+
public List<NestedClass[]> f8;
32+
2733
public ListTypeFieldsClass() {
2834
}
2935

@@ -75,6 +81,30 @@ public void setF5(List<ByteBuffer> f5) {
7581
this.f5 = f5;
7682
}
7783

84+
public List<int[]> getF6() {
85+
return f6;
86+
}
87+
88+
public void setF6(List<int[]> f6) {
89+
this.f6 = f6;
90+
}
91+
92+
public List<String[]> getF7() {
93+
return f7;
94+
}
95+
96+
public void setF7(List<String[]> f7) {
97+
this.f7 = f7;
98+
}
99+
100+
public List<NestedClass[]> getF8() {
101+
return f8;
102+
}
103+
104+
public void setF8(List<NestedClass[]> f8) {
105+
this.f8 = f8;
106+
}
107+
78108
@Override
79109
public boolean equals(Object o) {
80110
if (! (o instanceof ListTypeFieldsClass)) {
@@ -205,7 +235,74 @@ public boolean equals(Object o) {
205235
}
206236
}
207237
}
208-
return true;
238+
// f6
239+
if (f6 == null) {
240+
if (that.f6 != null) {
241+
return false;
242+
}
243+
}
244+
if (that.f6 != null) {
245+
if (f6.size() != that.f6.size()) {
246+
return false;
247+
}
248+
Iterator<int[]> this_f6_iter = f6.iterator();
249+
Iterator<int[]> that_f6_iter = that.f6.iterator();
250+
for (; this_f6_iter.hasNext();) {
251+
int[] this_f6_elm = this_f6_iter.next();
252+
int[] that_f6_elm = that_f6_iter.next();
253+
for (int i = 0; i < this_f6_elm.length; i++) {
254+
if (this_f6_elm[i] != that_f6_elm[i]) {
255+
return false;
256+
}
257+
}
258+
}
259+
}
260+
// f7
261+
if (f7 == null) {
262+
if (that.f7 != null) {
263+
return false;
264+
}
265+
}
266+
if (that.f7 != null) {
267+
if (f7.size() != that.f7.size()) {
268+
return false;
269+
}
270+
Iterator<String[]> this_f7_iter = f7.iterator();
271+
Iterator<String[]> that_f7_iter = that.f7.iterator();
272+
for (; this_f7_iter.hasNext();) {
273+
String[] this_f7_elm = this_f7_iter.next();
274+
String[] that_f7_elm = that_f7_iter.next();
275+
for (int i = 0; i < this_f7_elm.length; i++) {
276+
if (!this_f7_elm[i].equals(that_f7_elm[i])) {
277+
return false;
278+
}
279+
}
280+
}
281+
}
282+
// f8
283+
if (f8 == null) {
284+
if (that.f8 != null) {
285+
return false;
286+
}
287+
}
288+
if (that.f8 != null) {
289+
if (f8.size() != that.f8.size()) {
290+
return false;
291+
}
292+
Iterator<NestedClass[]> this_f8_iter = f8.iterator();
293+
Iterator<NestedClass[]> that_f8_iter = that.f8.iterator();
294+
for (; this_f8_iter.hasNext();) {
295+
NestedClass[] this_f8_elm = this_f8_iter.next();
296+
NestedClass[] that_f8_elm = that_f8_iter.next();
297+
for (int i = 0; i < this_f8_elm.length; i++) {
298+
if (!this_f8_elm[i].equals(that_f8_elm[i])) {
299+
return false;
300+
}
301+
}
302+
}
303+
}
304+
305+
return true;
209306
}
210307

211308
@Ignore @Message @Beans

src/test/java/org/msgpack/testclasses/ListTypeFieldsClassNotNullable.java

Lines changed: 107 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ public class ListTypeFieldsClassNotNullable {
3131
@NotNullable
3232
public List<ByteBuffer> f5;
3333

34+
@NotNullable
35+
public List<int[]> f6;
36+
37+
@NotNullable
38+
public List<String[]> f7;
39+
40+
@NotNullable
41+
public List<NestedClass[]> f8;
42+
3443
public ListTypeFieldsClassNotNullable() {
3544
}
3645

@@ -94,6 +103,36 @@ public void setF5(List<ByteBuffer> f5) {
94103
this.f5 = f5;
95104
}
96105

106+
@NotNullable
107+
public List<int[]> getF6() {
108+
return f6;
109+
}
110+
111+
@NotNullable
112+
public void setF6(List<int[]> f6) {
113+
this.f6 = f6;
114+
}
115+
116+
@NotNullable
117+
public List<String[]> getF7() {
118+
return f7;
119+
}
120+
121+
@NotNullable
122+
public void setF7(List<String[]> f7) {
123+
this.f7 = f7;
124+
}
125+
126+
@NotNullable
127+
public List<NestedClass[]> getF8() {
128+
return f8;
129+
}
130+
131+
@NotNullable
132+
public void setF8(List<NestedClass[]> f8) {
133+
this.f8 = f8;
134+
}
135+
97136
@Override
98137
public boolean equals(Object o) {
99138
if (! (o instanceof ListTypeFieldsClassNotNullable)) {
@@ -224,7 +263,74 @@ public boolean equals(Object o) {
224263
}
225264
}
226265
}
227-
return true;
266+
// f6
267+
if (f6 == null) {
268+
if (that.f6 != null) {
269+
return false;
270+
}
271+
}
272+
if (that.f6 != null) {
273+
if (f6.size() != that.f6.size()) {
274+
return false;
275+
}
276+
Iterator<int[]> this_f6_iter = f6.iterator();
277+
Iterator<int[]> that_f6_iter = that.f6.iterator();
278+
for (; this_f6_iter.hasNext();) {
279+
int[] this_f6_elm = this_f6_iter.next();
280+
int[] that_f6_elm = that_f6_iter.next();
281+
for (int i = 0; i < this_f6_elm.length; i++) {
282+
if (this_f6_elm[i] != that_f6_elm[i]) {
283+
return false;
284+
}
285+
}
286+
}
287+
}
288+
// f7
289+
if (f7 == null) {
290+
if (that.f7 != null) {
291+
return false;
292+
}
293+
}
294+
if (that.f7 != null) {
295+
if (f7.size() != that.f7.size()) {
296+
return false;
297+
}
298+
Iterator<String[]> this_f7_iter = f7.iterator();
299+
Iterator<String[]> that_f7_iter = that.f7.iterator();
300+
for (; this_f7_iter.hasNext();) {
301+
String[] this_f7_elm = this_f7_iter.next();
302+
String[] that_f7_elm = that_f7_iter.next();
303+
for (int i = 0; i < this_f7_elm.length; i++) {
304+
if (!this_f7_elm[i].equals(that_f7_elm[i])) {
305+
return false;
306+
}
307+
}
308+
}
309+
}
310+
// f8
311+
if (f8 == null) {
312+
if (that.f8 != null) {
313+
return false;
314+
}
315+
}
316+
if (that.f8 != null) {
317+
if (f8.size() != that.f8.size()) {
318+
return false;
319+
}
320+
Iterator<NestedClass[]> this_f8_iter = f8.iterator();
321+
Iterator<NestedClass[]> that_f8_iter = that.f8.iterator();
322+
for (; this_f8_iter.hasNext();) {
323+
NestedClass[] this_f8_elm = this_f8_iter.next();
324+
NestedClass[] that_f8_elm = that_f8_iter.next();
325+
for (int i = 0; i < this_f8_elm.length; i++) {
326+
if (!this_f8_elm[i].equals(that_f8_elm[i])) {
327+
return false;
328+
}
329+
}
330+
}
331+
}
332+
333+
return true;
228334
}
229335

230336
@Ignore @Message @Beans

0 commit comments

Comments
 (0)