Skip to content

Commit 89b99ce

Browse files
author
svorenova
committed
Extending test for generic functions
1 parent 3e6cf35 commit 89b99ce

File tree

3 files changed

+1301
-40
lines changed

3 files changed

+1301
-40
lines changed
Binary file not shown.
Lines changed: 104 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,126 @@
11
public class GenericFunctions
22
{
3-
public static <T> void processSimpleGeneric(Generic<T> x)
3+
4+
//Methods with generic inputs
5+
public static <T> void processSimple(Generic<T> x)
46
{
57

68
}
79

8-
// Test a wildcard generic bound by an interface
9-
public static <T extends Interface> void processUpperBoundInterfaceGeneric(Generic<T> x)
10+
public static <T extends Interface> void processUpperBoundInterface(Generic<T> x)
1011
{
1112

1213
}
1314

14-
// Test a wild card generic bound by a class
15-
public static <T extends Interface_Implementation> void processUpperBoundClassGeneric(Generic<T> x)
15+
public static <T extends Interface_Implementation> void processUpperBoundClass(Generic<T> x)
1616
{
1717

1818
}
1919

20-
// Test a wild card generic bound by a class and an interface
21-
public static <T extends Interface_Implementation & Interface> void processDoubleUpperBoundClassGeneric(Generic<T> x)
20+
public static <T extends Interface_Implementation & Interface> void processDoubleUpperBoundClass(Generic<T> x)
2221
{
2322

2423
}
2524

26-
// Test a wild card generic bound by two interfaces
27-
public static <T extends Interface & Interface_Copy> void processDoubleUpperBoundInterfaceGeneric(Generic<T> x)
25+
public static <T extends Interface & Interface_Copy> void processDoubleUpperBoundInterface(Generic<T> x)
2826
{
2927

3028
}
29+
30+
public static <T,U> void processMultipleSimple(Generic<T> t, Generic<U> u)
31+
{
32+
33+
}
34+
35+
public static <T extends Interface,U extends Interface_Implementation & Interface> void processMultipleUpperBound(Generic<T> t, Generic<U> u)
36+
{
37+
38+
}
39+
40+
//Methods with generic output
41+
public static <T> Generic<T> returnSimple()
42+
{
43+
Generic<T> x=new Generic<T>();
44+
return x;
45+
}
46+
47+
public static <T> T returnSimpleField()
48+
{
49+
Generic<T> x=new Generic<T>();
50+
return x.t;
51+
}
52+
53+
public static <T extends Interface> Generic<T> returnUpperBoundInterface()
54+
{
55+
Generic<T> x=new Generic<T>();
56+
return x;
57+
}
58+
59+
public static <T extends Interface_Implementation> Generic<T> returnUpperBoundClass()
60+
{
61+
Generic<T> x=new Generic<T>();
62+
return x;
63+
}
64+
65+
public static <T extends Interface_Implementation & Interface> Generic<T> returnDoubleUpperBoundClass()
66+
{
67+
Generic<T> x=new Generic<T>();
68+
return x;
69+
}
70+
71+
public static <T extends Interface & Interface_Copy> Generic<T> returnDoubleUpperBoundInterface()
72+
{
73+
Generic<T> x=new Generic<T>();
74+
return x;
75+
}
76+
77+
//Methods with generic input and output
78+
public static <T> Generic<T> processReturnSimpleSame(Generic<T> x)
79+
{
80+
return x;
81+
}
82+
83+
public static <T extends Interface> Generic<T> processReturnUpperBoundInterfaceSame(Generic<T> x)
84+
{
85+
return x;
86+
}
87+
88+
public static <T extends Interface_Implementation> Generic<T> processReturnUpperBoundClassSame(Generic<T> x)
89+
{
90+
return x;
91+
}
92+
93+
public static <T extends Interface_Implementation & Interface> Generic<T> processReturnDoubleUpperBoundClassSame(Generic<T> x)
94+
{
95+
return x;
96+
}
97+
98+
public static <T extends Interface & Interface_Copy> Generic<T> processReturnDoubleUpperBoundInterfaceSame(Generic<T> x)
99+
{
100+
return x;
101+
}
102+
103+
public static <T,U> Generic<T> processReturnSimpleDifferent(Generic<U> u)
104+
{
105+
Generic<T> t=new Generic<T>();
106+
return t;
107+
}
108+
109+
public static <T extends Interface,U extends Interface_Implementation & Interface> Generic<T> processReturnUpperBoundDifferent(Generic<U> u)
110+
{
111+
Generic<T> t=new Generic<T>();
112+
return t;
113+
}
114+
115+
public static <T,U,V> Generic<T> processReturnMultipleSimpleDifferent(Generic<U> u, Generic<V> v)
116+
{
117+
Generic<T> t=new Generic<T>();
118+
return t;
119+
}
120+
121+
public static <T extends Interface,U extends Interface_Implementation & Interface, V extends Interface_Copy> Generic<T> processReturnMultipleUpperBoundDifferent(Generic<U> u, Generic<V> v)
122+
{
123+
Generic<T> t=new Generic<T>();
124+
return t;
125+
}
31126
}

0 commit comments

Comments
 (0)