home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1994 June / NEBULA_SE.ISO / SourceCode / MiscKit / Examples / MiscString / StringTestReplacing.m < prev    next >
Encoding:
Text File  |  1994-02-08  |  3.0 KB  |  76 lines

  1. //
  2. // StringTestReplacing.m -- test out the String class' Replacing category
  3. //        Written by Don Yacktman (c) 1994 by Don Yacktman.
  4. //                Version 1.0.  All rights reserved.
  5. //
  6. //        This notice may not be removed from this source code.
  7. //
  8. //    This program is included in the MiscKit by permission from the author
  9. //    and its use is governed by the MiscKit license, found in the file
  10. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  11. //    for a list of all applicable permissions and restrictions.
  12. //    
  13.  
  14. #define NUMREPLSTRINGS 4
  15. void testMiscStringReplacing()
  16. {
  17.     id string[NUMREPLSTRINGS]; int i;
  18.  
  19.     printf("***** Testing MiscStringReplacing category\n");
  20.  
  21. // Test MiscStringReplacing.m methods:
  22.     // The following are covers for other methods and aren't tested here,
  23.     // though for completeness they probably ought to be:
  24.     //
  25.     // - replaceFrom:(int)start length:(int)len with:(const char *)aString
  26.     // - replaceFrom:(int)start to:(int)end with:(const char *)aString
  27.     // - replaceFrom:(int)start length:(int)len withString:(id)sender
  28.     // - replaceFrom:(int)start to:(int)end withString:(id)sender
  29.     // - replace:(const char *)subString withString:(id)sender
  30.     // - replaceFrom:(int)start length:(int)len withChar:(char)aChar
  31.     // - replaceFrom:(int)start to:(int)end withChar:(char)aChar
  32.     // - replaceEveryOccurrenceOfChars:(const char *)aString
  33.     //            with:(const char *)replaceString
  34.     // - replaceEveryOccurrenceOfChars:(const char *)aString
  35.     //            withChar:(char)replaceChar
  36.     // - replaceEveryOccurrenceOfChars:(const char *)aString
  37.     //            withString:(id)sender
  38.     // - replaceEveryOccurrenceOfChars:(const char *)aString
  39.     //            withString:(id)sender caseSensitive:(BOOL)sense
  40.     // - replaceEveryOccurrenceOfChar:(char)aChar with:(const char *)aString
  41.     // - replaceEveryOccurrenceOfChar:(char)aChar withString:(id)sender
  42.     // - replaceEveryOccurrenceOfChar:(char)aChar
  43.     //            withString:(id)sender caseSensitive:(BOOL)sense
  44.     // - replaceEveryOccurrenceOfChar:(char)aChar withChar:(char)replaceChar
  45.  
  46.     string[0] = [MiscString new];
  47.     string[1] = [MiscString newWithString:"This is a non-null test string."];
  48.     string[2] = [MiscString newWithString:"This is a test, a test it is."];
  49.     string[3] = [MiscString newWithString:"Q"];
  50.     
  51.     printf("The strings for these tests are:\n", i, string[i]);
  52.     for (i=0; i<NUMREPLSTRINGS; i++) {
  53.         printf("String #%d:  \"%d\"\n", i, string[i]);
  54.     }
  55. // Test - replaceCharAt:(int)index withChar:(char)aChar
  56.  
  57. // Test - replace:(const char *)subString with:(const char *)newString
  58.  
  59. // Test - replaceEveryOccurrenceOfChars:(const char *)aString
  60. //                with:(const char *)replaceString caseSensitive:(BOOL)sense
  61.  
  62. // Test - replaceEveryOccurrenceOfChars:(const char *)aString
  63. //                withChar:(char)replaceChar caseSensitive:(BOOL)sense
  64.  
  65. // Test - replaceEveryOccurrenceOfChar:(char)aChar with:(const char *)aString
  66. //                caseSensitive:(BOOL)sense
  67.  
  68. // Test - replaceEveryOccurrenceOfChar:(char)aChar withChar:(char)replaceChar
  69. //                caseSensitive:(BOOL)sense
  70.  
  71.     for (i=0; i<NUMREPLSTRINGS; i++) {
  72.         [string[i] free]
  73.     }
  74. }
  75.  
  76.