1#import <Foundation/Foundation.h>
2
3#if defined(__APPLE__)
4#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
5#define IOS
6#endif
7#endif
8
9#if defined(IOS)
10#import <Foundation/NSGeometry.h>
11#else
12#import <Carbon/Carbon.h>
13#endif
14
15int main (int argc, const char * argv[])
16{
17
18 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
19
20 NSString *empty = @"";
21 NSString *str0 = [[NSNumber numberWithUnsignedLongLong:0xFF] stringValue];
22 NSString *str1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding];
23 NSString *str2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"];
24 NSString *str3 = @"A string made with the at sign is here";
25 NSString *str4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4];
26 NSRect ns_rect_4str = {{1,1},{5,5}};
27 NSString* str5 = NSStringFromRect(ns_rect_4str);
28 NSString* str6 = [@"/usr/doc/README.1ST" pathExtension];
29 const unichar myCharacters[] = {0x03C3,'x','x'};
30 NSString *str7 = [NSString stringWithCharacters: myCharacters
31 length: sizeof myCharacters / sizeof *myCharacters];
32 NSString* str8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension];
33 const unichar myOtherCharacters[] = {'a',' ', 'v','e','r','y',' ',
34 'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k',
35 ' ','t','o',' ','w','r','i','t','e', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ',
36 't','h','i','s',' ','w','a','y','!','!',0x03C3, 0};
37 NSString *str9 = [NSString stringWithCharacters: myOtherCharacters
38 length: sizeof myOtherCharacters / sizeof *myOtherCharacters];
39 const unichar myNextCharacters[] = {0x03C3, 0x0000};
40 NSString *str10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4];
41 NSString *str11 = NSStringFromClass([str10 class]);
42 NSString *label1 = @"Process Name: ";
43 NSString *label2 = @"Process Id: ";
44 NSString *processName = [[NSProcessInfo processInfo] processName];
45 NSString *processID = [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]];
46 NSString *str12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
47 NSString *eAcute = [NSString stringWithFormat: @"%C", 0x00E9];
48 NSString *randomHaziChar = [NSString stringWithFormat: @"%C", 0x9DC5];
49 NSString *japanese = @"色は匂へど散りぬるを";
50 NSString *italian = @"L'Italia è una Repubblica democratica, fondata sul lavoro. La sovranità appartiene al popolo, che la esercita nelle forme e nei limiti della Costituzione.";
51 NSString* french = @"Que veut cette horde d'esclaves, De traîtres, de rois conjurés?";
52 NSString* german = @"Über-Ich und aus den Ansprüchen der sozialen Umwelt";
53 void* data_set[3] = {str1,str2,str3};
54 NSString *hebrew = [NSString stringWithString:@"לילה טוב"];
55
56 NSAttributedString* attrString = [[NSAttributedString alloc] initWithString:@"hello world from foo" attributes:[NSDictionary new]];
57 [attrString isEqual:nil];
58 NSAttributedString* mutableAttrString = [[NSMutableAttributedString alloc] initWithString:@"hello world from foo" attributes:[NSDictionary new]];
59 [mutableAttrString isEqual:nil];
60
61 NSString* mutableString = [[NSMutableString alloc] initWithString:@"foo"];
62 [mutableString insertString:@"foo said this string needs to be very long so much longer than whatever other string has been seen ever before by anyone of the mankind that of course this is still not long enough given what foo our friend foo our lovely dearly friend foo desired of us so i am adding more stuff here for the sake of it and for the joy of our friend who is named guess what just foo. hence, dear friend foo, stay safe, your string is now long enough to accommodate your testing need and I will make sure that if not we extend it with even more fuzzy random meaningless words pasted one after the other from a long tiresome friday evening spent working in my office. my office mate went home but I am still randomly typing just for the fun of seeing what happens of the length of a Mutable String in Cocoa if it goes beyond one byte.. so be it, dear " atIndex:0];
63
64 NSString* mutableGetConst = [NSString stringWithCString:[mutableString cString]];
65
66 [mutableGetConst length];
67 CFMutableStringRef mutable_string_ref = CFStringCreateMutable(NULL,100);
68 CFStringAppend(mutable_string_ref, CFSTR("Wish ya knew"));
69 CFStringRef cfstring_ref = CFSTR("HELLO WORLD");
70
71 NSArray *components = @[@"usr", @"blah", @"stuff"];
72 NSString *path = [NSString pathWithComponents: components];
73 NSString *empty_path = [empty stringByDeletingPathExtension];
74
75 const unichar someOfTheseAreNUL[] = {'a',' ', 'v','e','r','y',' ',
76 'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k',
77 ' ','t','o',' ','w','r','i','t','e', 0, 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ',
78 't','h','i','s',' ','w','a','y','!','!', 0x03C3, 0};
79 NSString *strwithNULs = [NSString stringWithCharacters: someOfTheseAreNUL
80 length: sizeof someOfTheseAreNUL / sizeof *someOfTheseAreNUL];
81
82 const unichar someOfTheseAreNUL2[] = {'a',' ', 'v','e','r','y',' ',
83 'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k',
84 ' ','t','o',' ','w','r','i','t','e', 0, 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ',
85 't','h','i','s',' ','w','a','y','!','!'};
86 NSString *strwithNULs2 = [NSString stringWithCharacters: someOfTheseAreNUL2
87 length: sizeof someOfTheseAreNUL2 / sizeof *someOfTheseAreNUL2];
88
89 [pool drain]; // break here
90 return 0;
91}
92
93

source code of lldb/test/API/functionalities/data-formatter/data-formatter-objc/nsstring/main.m