Last change
on this file since 689 was 656, checked in by イグトランス (egtra), 16 years ago |
文字列比較のテストを3引数版UnitTestの呼出に変更
|
File size:
1.0 KB
|
Line | |
---|
1 | Namespace GenericsTest
|
---|
2 |
|
---|
3 | Class Foo<T>
|
---|
4 | Public
|
---|
5 | Function GetTypeName( t As T ) As String
|
---|
6 | Return t.GetType().Name
|
---|
7 | End Function
|
---|
8 | End Class
|
---|
9 | Class Bar<T>
|
---|
10 | Inherits Foo<String>
|
---|
11 | End Class
|
---|
12 |
|
---|
13 | Sub TestMain()
|
---|
14 | ' クラス型の型パラメータ
|
---|
15 | Dim a = New System.Collections.Generic.List<String>
|
---|
16 | a.Add( "test" )
|
---|
17 | a.Add( "123" )
|
---|
18 | UnitTest( "Generic ... type parameter is class", a[0] = "test" and a[1] = "123" )
|
---|
19 |
|
---|
20 | ' 値型の型パラメータ
|
---|
21 | Dim b = New System.Collections.Generic.List<Byte>
|
---|
22 | b.Add( 123 )
|
---|
23 | b.Add( 234 )
|
---|
24 | UnitTest( "Generic ... type parameter is value(byte)", b[0] = 123 and b[1] = 234 )
|
---|
25 | Dim c = New System.Collections.Generic.List<Double>
|
---|
26 | c.Add( 123.456 )
|
---|
27 | c.Add( 456.789 )
|
---|
28 | UnitTest( "Generic ... type parameter is value(double)", c[0] = 123.456 and c[1] = 456.789 )
|
---|
29 |
|
---|
30 | ' 型パラメータがクロスした場合
|
---|
31 | ' TODO: より多くのパターンで試す必要あり
|
---|
32 | Dim bar = New Bar<Long>
|
---|
33 | UnitTest( "Generic ... complex", bar.GetTypeName( New String() ), "String" )
|
---|
34 | End Sub
|
---|
35 |
|
---|
36 | End Namespace
|
---|
37 |
|
---|
38 | GenericsTest.TestMain()
|
---|
Note:
See
TracBrowser
for help on using the repository browser.