Public Function IsGoodReplicate() As Boolean
' verify correct Replicate returns, rev 20020612
' returns True if all tests are passed
  Dim fFailed As Boolean
  
  ' replace ".Replicate13" with the name of your function to test
  
  With New CReplicationPaul
  
  If .Replicate13(3, "a") <> "aaa" Then Stop: fFailed = True
  If .Replicate13(1000, "a") <> String$(1000, "a") Then Stop: fFailed = True
  If .Replicate13(500, "aa") <> String$(1000, "a") Then Stop: fFailed = True
  If .Replicate13(3, "ab") <> "ababab" Then Stop: fFailed = True
  If .Replicate13(2, "ab") <> "abab" Then Stop: fFailed = True
  If .Replicate13(1, "ab") <> "ab" Then Stop: fFailed = True
  If .Replicate13(0, "ab") <> "" Then Stop: fFailed = True
  If .Replicate13(-1, "ab") <> "" Then Stop: fFailed = True
  If .Replicate13(3, "") <> "" Then Stop: fFailed = True
  
  If .Replicate13(2, "ab" & vbNullChar) <> "ab" & vbNullChar & "ab" & vbNullChar Then Stop: fFailed = True

  ' one-character unicode string (ChrW$(8364) below is the EURO-sign)
  If .Replicate13(1, ChrW$(8364)) <> ChrW$(8364) Then Stop: fFailed = True
  
  End With
  
  ' well done
  IsGoodReplicate = Not fFailed
  
End Function

Back to Replicate