indextestcode.vb
来自「an lcs algorithm for finding common stri」· VB 代码 · 共 65 行
VB
65 行
#If DEBUG Then
Namespace We.See.Diff
Public Class IndexTestCode
Private Shared Function SplitString(ByVal value As String) As String()
Return value.ToList.ConvertAll(Of String)(Function(x) x).ToArray
End Function
Private Shared Function Join(ByVal value As String()) As String
Return String.Join("", value)
End Function
Private Shared Function Join(ByVal value As Integer()) As String
Return String.Join("", value.ToList.ConvertAll(Of String)(Function(x) x).ToArray)
End Function
Private Shared Sub DumpResult(ByVal result As Index(Of String))
Debug.WriteLine("data1:" & Join(result.List1))
Debug.WriteLine("data2:" & Join(result.List2))
Debug.WriteLine("unique:" & Join(result.UniqueValues))
Debug.WriteLine("startsize:" & result.StartSize)
Debug.WriteLine("endsize:" & result.EndSize)
Debug.WriteLine("block1length:" & result.Block1Length)
Debug.WriteLine("block2length:" & result.Block2Length)
Debug.WriteLine("index1:" & Join(result.Index1))
Debug.WriteLine("index1high:" & result.Index1High)
Debug.WriteLine("index2:" & Join(result.Index2))
Debug.WriteLine("")
End Sub
Public Shared Sub TestIndex()
Dim result As Index(Of String)
result = Index(Of String).Build(SplitString("abcdefgh"), SplitString("abczdeydegh"))
DumpResult(result)
' expected results:
Debug.Assert(Join(result.List1) = "abcdefgh")
Debug.Assert(Join(result.List2) = "abczdeydegh")
Debug.Assert(Join(result.UniqueValues) = "abchgdefzy")
Debug.Assert(result.StartSize = 3)
Debug.Assert(result.EndSize = 2)
Debug.Assert(result.Index1High = 7)
Debug.Assert(Join(result.Index1) = "01256743")
Debug.Assert(Join(result.Index2) = "01285695643")
Debug.Assert(result.Block1Length = 3)
Debug.Assert(result.Block2Length = 6)
DumpResult(Index(Of String).Build(SplitString("abczdeydegh"), SplitString("abcdefgh")))
DumpResult(Index(Of String).Build(SplitString("abcfgh"), SplitString("abcZfgh")))
DumpResult(Index(Of String).Build(SplitString("abcZfgh"), SplitString("abcfgh")))
DumpResult(Index(Of String).Build(SplitString(""), SplitString("abc")))
DumpResult(Index(Of String).Build(SplitString("abc"), SplitString("")))
End Sub
End Class
End Namespace
#End If
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?