<-- Previous || Up || Next -->

Replace String Recursively Verify Sub
String Replacements Class

Private Sub ReplaceStringRecursivelyVerify()
    'Test the ReplaceStringRecursively function.
    
    Debug.Assert IsNull(ReplaceStringRecursively(Null, "bc", "-")) ' Behavior #1

    Debug.Assert IsNull(ReplaceStringRecursively("AbcAbcAbc", Null, "-")) ' Behavior #2

    Debug.Assert ReplaceStringRecursively("AbcAbcAbc", "", "-") = "AbcAbcAbc" ' Behavior #3

    Debug.Assert ReplaceStringRecursively("AbcAbcAbc", "bc") = "AAA" ' Behavior #4
    Debug.Assert ReplaceStringRecursively("AbcAbcAbc", "bc", Null) = "AAA"

    Debug.Assert ReplaceStringRecursively("AbcAbcAbc", "bc", "") = "AAA" ' Behavior #5

    Debug.Assert ReplaceStringRecursively("AbcAbcAbc", "cA", "-", vbBinaryCompare) = "Ab-b-bc" ' Behavior #6
    Debug.Assert ReplaceStringRecursively("AbcAbcAbc", "ca", "-", vbBinaryCompare) = "AbcAbcAbc"
    Debug.Assert ReplaceStringRecursively("AbcAbcAbc", "cA", "-", vbTextCompare) = "Ab-b-bc"
    Debug.Assert ReplaceStringRecursively("AbcAbcAbc", "ca", "-", vbTextCompare) = "Ab-b-bc"

    Debug.Assert ReplaceStringRecursively("AbcAbcAbc", "cA", "-") = "Ab-b-bc" ' Behavior #7
    Debug.Assert ReplaceStringRecursively("AbcAbcAbc", "ca", "-") = "AbcAbcAbc"
    Debug.Assert ReplaceStringRecursively("AbcAbcAbc", "ca", "-", Null) = "AbcAbcAbc"
    Debug.Assert ReplaceStringRecursively("AbcAbcAbc", "ca", "-", "Joe") = "AbcAbcAbc"

    Debug.Assert ReplaceStringRecursively("AbcAbcAbc", "A", "AA") = "" ' Behavior #8
    Debug.Assert ReplaceStringRecursively("AbcAbcAbc", "Ab", "AbAb") = ""

    Debug.Assert ReplaceStringRecursively("This    is a   test.", "  ", " ") = "This is a test." ' Behavior #9

End Sub

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.