]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/nsstring/main.m
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / data-formatter / data-formatter-objc / nsstring / main.m
1 //===-- main.m ------------------------------------------------*- ObjC -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #import <Foundation/Foundation.h>
11
12 #if defined(__APPLE__)
13 #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
14 #define IOS
15 #endif
16 #endif
17
18 #if defined(IOS)
19 #import <Foundation/NSGeometry.h>
20 #else
21 #import <Carbon/Carbon.h>
22 #endif
23
24 int main (int argc, const char * argv[])
25 {
26     
27     NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
28
29             NSString *str0 = [[NSNumber numberWithUnsignedLongLong:0xFF] stringValue];
30             NSString *str1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding];
31             NSString *str2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"];
32             NSString *str3 = @"A string made with the at sign is here";
33             NSString *str4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4];
34             NSRect ns_rect_4str = {{1,1},{5,5}};
35             NSString* str5 = NSStringFromRect(ns_rect_4str);
36             NSString* str6 = [@"/usr/doc/README.1ST" pathExtension];
37             const unichar myCharacters[] = {0x03C3,'x','x'};
38             NSString *str7 = [NSString stringWithCharacters: myCharacters
39                                                      length: sizeof myCharacters / sizeof *myCharacters];
40             NSString* str8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension];
41             const unichar myOtherCharacters[] = {'a',' ', 'v','e','r','y',' ',
42                 'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k',
43                 ' ','t','o',' ','w','r','i','t','e', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ',
44                 't','h','i','s',' ','w','a','y','!','!',0x03C3, 0};
45             NSString *str9 = [NSString stringWithCharacters: myOtherCharacters
46                                                      length: sizeof myOtherCharacters / sizeof *myOtherCharacters];
47             const unichar myNextCharacters[] = {0x03C3, 0x0000};
48             NSString *str10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4];
49             NSString *str11 = NSStringFromClass([str10 class]);
50             NSString *label1 = @"Process Name: ";
51             NSString *label2 = @"Process Id: ";
52             NSString *processName = [[NSProcessInfo processInfo] processName];
53             NSString *processID = [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]];
54             NSString *str12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
55             NSString *eAcute = [NSString stringWithFormat: @"%C", 0x00E9];
56             NSString *randomHaziChar = [NSString stringWithFormat: @"%C", 0x9DC5];
57             NSString *japanese = @"色は匂へど散りぬるを";
58             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.";
59             NSString* french = @"Que veut cette horde d'esclaves, De traîtres, de rois conjurés?";
60             NSString* german = @"Über-Ich und aus den Ansprüchen der sozialen Umwelt";
61             void* data_set[3] = {str1,str2,str3};
62       NSString *hebrew = [NSString stringWithString:@"לילה טוב"];
63
64             NSAttributedString* attrString = [[NSAttributedString alloc] initWithString:@"hello world from foo" attributes:[NSDictionary new]];
65             [attrString isEqual:nil];
66             NSAttributedString* mutableAttrString = [[NSMutableAttributedString alloc] initWithString:@"hello world from foo" attributes:[NSDictionary new]];
67             [mutableAttrString isEqual:nil];
68
69             NSString* mutableString = [[NSMutableString alloc] initWithString:@"foo"];
70             [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];
71
72             NSString* mutableGetConst = [NSString stringWithCString:[mutableString cString]];
73
74             [mutableGetConst length];
75             CFMutableStringRef mutable_string_ref = CFStringCreateMutable(NULL,100);
76             CFStringAppend(mutable_string_ref, CFSTR("Wish ya knew"));
77             CFStringRef cfstring_ref = CFSTR("HELLO WORLD");
78
79         NSArray *components = @[@"usr", @"blah", @"stuff"];
80         NSString *path = [NSString pathWithComponents: components];
81
82   const unichar someOfTheseAreNUL[] = {'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','!','!', 0x03C3, 0};
86   NSString *strwithNULs = [NSString stringWithCharacters: someOfTheseAreNUL
87                                            length: sizeof someOfTheseAreNUL / sizeof *someOfTheseAreNUL];
88
89   const unichar someOfTheseAreNUL2[] = {'a',' ', 'v','e','r','y',' ',
90       'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k',
91       ' ','t','o',' ','w','r','i','t','e', 0, 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ',
92       't','h','i','s',' ','w','a','y','!','!'};
93   NSString *strwithNULs2 = [NSString stringWithCharacters: someOfTheseAreNUL2
94                                            length: sizeof someOfTheseAreNUL2 / sizeof *someOfTheseAreNUL2];
95
96     [pool drain]; // break here
97     return 0;
98 }
99