home *** CD-ROM | disk | FTP | other *** search
/ AMIGA PD 1 / AMIGA-PD-1.iso / Programme_zum_Heft / Programmieren / Kurztests / PascalPCQ / Examples / StringTest.p < prev    next >
Text File  |  1990-07-20  |  4KB  |  84 lines

  1. program StringTest;
  2.  
  3. {
  4.     This program excersises the revised StringLib a bit.  It's not
  5. a complete suite of tests, but does test the most obvious stuff.
  6. }
  7.  
  8. {$I "Include:Utils/StringLib.i"}
  9.  
  10. var
  11.     str : String;
  12.  
  13. begin
  14.     writeln("isupper('a') = ", isupper('a'));
  15.     writeln("isupper('A') = ", isupper('A'));
  16.     writeln("islower('r') = ", islower('r'));
  17.     writeln("islower('E') = ", islower('E'));
  18.     writeln("isalpha('E') = ", isalpha('E'));
  19.     writeln("isalpha('t') = ", isalpha('t'));
  20.     writeln("isalpha('4') = ", isalpha('4'));
  21.     writeln("isdigit('4') = ", isdigit('4'));
  22.     writeln("isdigit('r') = ", isdigit('r'));
  23.     writeln("isdigit(' ') = ", isdigit(' '));
  24.     writeln("isalnum('2') = ", isalnum('2'));
  25.     writeln("isalnum('e') = ", isalnum('e'));
  26.     writeln("isalnum('R') = ", isalnum('R'));
  27.     writeln("isalnum('%') = ", isalnum('%'));
  28.     writeln("isspace(#10) = ", isspace(Chr(10)));
  29.     writeln("isspace('r') = ", isspace('r'));
  30.     writeln("toupper('r') = ", toupper('r'));
  31.     writeln("toupper('R') = ", toupper('R'));
  32.     writeln("toupper('#') = ", toupper('#'));
  33.     writeln("tolower('r') = ", tolower('r'));
  34.     writeln("tolower('R') = ", tolower('R'));
  35.     writeln("tolower('#') = ", tolower('#'));
  36.     writeln('streq("The string", "The string") = ', streq("The string", "The string"));
  37.     writeln('streq("The String", "The string") = ', streq("The String", "The string"));
  38.     writeln('streq("The strings", "The string") = ', streq("The strings", "The string"));
  39.     writeln('strieq("The string", "The string") = ', strieq("The string", "The string"));
  40.     writeln('strieq("The String", "The string") = ', strieq("The StrinG", "The string"));
  41.     writeln('strieq("The Strings", "The string") = ', strieq("The Strings", "The string"));
  42.     writeln('strnieq("The string string", "The String",10) = ', strnieq("The string string", "The String", 10));
  43.     writeln('strnieq("The string", "The string",50) = ', strnieq("The string", "The string",50));
  44.     writeln('strnieq("The String", "THE string", 4) = ', strnieq("The string", "THE string",4));
  45.     writeln('strcmp("abcde", "abcde") = ', strcmp("abcde", "abcde"));
  46.     writeln('strcmp("abcde", "abcdef") = ', strcmp("abcde", "abcdef"));
  47.     writeln('strcmp("abcde", "abcd") = ', strcmp("abcde", "abcd"));
  48.     writeln('strcmp("abcde", "aacde") = ', strcmp("abcde", "aacde"));
  49.     writeln('strcmp("abcde", "accde") = ', strcmp("abcde", "accde"));
  50.     writeln('stricmp("AbCde", "aBcdE") = ', stricmp("AbCde", "aBcdE"));
  51.     writeln('stricmp("AbCde", "AacdE") = ', stricmp("AbCde", "AacdE"));
  52.     writeln('stricmp("AbCde", "aCCDe") = ', stricmp("AbCde", "aCCDe"));
  53.     writeln('strlen("The string") = ', strlen("The string"));
  54.     writeln('strlen("") = ', strlen(""));
  55.  
  56.     str := AllocString(80);
  57.     strcpy(str, "The string in question");
  58.     writeln('strcpy created ', str);
  59.     strcpy(str, "The string");
  60.     writeln('strcpy created ', str);
  61.     strncpy(str, "The string in", 40);
  62.     writeln('strncpy created ', str);
  63.     strncpy(str, "The string in", 5);
  64.     writeln('strncpy created ', str);
  65.  
  66.     strcat(str, " question");
  67.     writeln('strcat created ', str);
  68.     strcat(str, "");
  69.     writeln('strcat created ', str);
  70.     strncat(str, " is a goose.", 40);
  71.     writeln('strncat created ', str);
  72.     strncat(str, " More! More!", 5);
  73.     writeln('strncat created ', str);
  74.  
  75.     writeln('strpos("The string", e) = ', strpos("The string" ,'e'));
  76.     writeln('strpos("The string", T) = ', strpos("The string", 'T'));
  77.     writeln('strpos("The string", g) = ', strpos("The string", 'g'));
  78.     writeln('strpos("The string", x) = ', strpos("The string", 'x'));
  79.     writeln('strrpos("The string", e) = ', strrpos("The string", 'e'));
  80.     writeln('strrpos("The string", T) = ', strrpos("The string", 'T'));
  81.     writeln('Strrpos("The string", g) = ', strrpos("The string", 'g'));
  82.     writeln('strrpos("The string", x) = ', strrpos("The string", 'x'));
  83. end.
  84.