File: general.m

package info (click to toggle)
gnustep-corebase 0.1.1%2B20230710-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,608 kB
  • sloc: ansic: 25,359; objc: 4,347; cpp: 75; xml: 49; makefile: 24; sh: 7
file content (31 lines) | stat: -rw-r--r-- 960 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "CoreFoundation/CFString.h"
#include "../CFTesting.h"

int main (void)
{
  CFStringRef str;
  CFArrayRef array;
  CFRange found;
  
  /* This is used by CFURL. */
  array = CFStringCreateArrayBySeparatingStrings (NULL,
    CFSTR("/usr/local/share/GNUstep/"), CFSTR("/"));
  PASS_CF(CFArrayGetCount(array) == 6, "There are 6 strings on separated string.");
  str = CFArrayGetValueAtIndex (array, 1);
  PASS_CFEQ(str, CFSTR("usr"), "Value at index 1 is 'usr'");
  
  str = CFStringCreateByCombiningStrings (NULL, array, CFSTR("\\"));
  PASS_CFEQ(str, CFSTR("\\usr\\local\\share\\GNUstep\\"),
    "Combined string is \\usr\\local\\share\\GNUstep\\");
  
  CFRelease (array);
  
  PASS_CF(CFStringFindWithOptions(str, CFSTR("\\"), CFRangeMake(5, 12), 0, &found),
    "'\\' was found.");
  PASS_CF(found.location == 10 && found.length == 1, "String has range (%d, %d)",
       (int)found.location, (int)found.length);
  
  CFRelease (str);
  
  return 0;
}