Public Function IsGoodCompress(Optional fLigaturesToo As Boolean) As Boolean
' verify correct Compress returns, 20021005
' returns True if all tests are passed
  Dim fFailed As Boolean
  
  ' replace "Compress08" with the name of your function to test
  
  If Compress08("aaaaaaa", "a") <> "a" Then Stop: fFailed = True
  If Compress08("a...a", ".") <> "a.a" Then Stop: fFailed = True
  If Compress08("..a...a..", ".") <> ".a.a." Then Stop: fFailed = True
  If Compress08("a...a", "..") <> "a...a" Then Stop: fFailed = True
  If Compress08("a....a", "..") <> "a..a" Then Stop: fFailed = True
  If Compress08("abbbbcba", "b") <> "abcba" Then Stop: fFailed = True
  If Compress08("blablabla", "bla") <> "bla" Then Stop: fFailed = True
  
  If Compress08("aBBa", "b") <> "aBBa" Then Stop: fFailed = True
  ' some versions return "aBa", others "aba": both is OK
  If LCase$(Compress08("aBBa", "b", vbTextCompare)) <> "aba" Then Stop: fFailed = True
  If LCase$(Compress08("aa", "A", vbTextCompare)) <> "a" Then Stop: fFailed = True
  
  ' passing empty strings
  If Compress08("a...a", "") <> "a...a" Then Stop: fFailed = True
  If Compress08("", ".") <> "" Then Stop: fFailed = True
  
  ' unicode
  If Compress08("€€€", "€") <> "€" Then Stop: fFailed = True
  If Compress08("[a][a]{a}", "[A]", vbTextCompare) <> "[a]{a}" And _
      Compress08("[a][a]{a}", "[A]", vbTextCompare) <> "[A]{a}" Then Stop: fFailed = True
  
  If Compress08("[[[[{{{{", "[", vbTextCompare) <> "[{{{{" Then Stop: fFailed = True
  
  ' the 4 stooges: š/Š, œ/Œ, ž/Ž, ÿ/Ÿ (154/138, 156/140, 158/142, 255/159)
  If LCase$(Compress08("šušu", "Šu", vbTextCompare)) <> "šu" Then Stop: fFailed = True
  ' ligatures  textcompare (VBspeed entries do NOT have to pass this test)
  If fLigaturesToo Then
    ' ligatures, a digraphemic fun house: ss/ß, ae/æ, oe/œ, th/þ
    If LCase$(Compress08("Kußkuß", "kuss", vbTextCompare)) <> "kuß" And _
        LCase$(Compress08("Kußkuß", "kuss", vbTextCompare)) <> "kuss" Then Stop: fFailed = True
  End If
  
  ' well done
  IsGoodCompress = Not fFailed
  
End Function

Back to Compress