forked from OSchip/llvm-project
Split the portion of the data-formatter-objc test case that deals with NSString into its own separate test case
llvm-svn: 242552
This commit is contained in:
parent
244a6773c7
commit
4cb0ba311a
|
@ -45,20 +45,6 @@ class ObjCDataFormatterTestCase(TestBase):
|
|||
"""Test formatters for NSNumber."""
|
||||
self.appkit_tester_impl(self.buildDwarf,self.nsnumber_data_formatter_commands)
|
||||
|
||||
|
||||
@skipUnlessDarwin
|
||||
@dsym_test
|
||||
def test_nsstring_with_dsym_and_run_command(self):
|
||||
"""Test formatters for NSString."""
|
||||
self.appkit_tester_impl(self.buildDsym,self.nsstring_data_formatter_commands)
|
||||
|
||||
@skipUnlessDarwin
|
||||
@dwarf_test
|
||||
def test_nsstring_with_dwarf_and_run_command(self):
|
||||
"""Test formatters for NSString."""
|
||||
self.appkit_tester_impl(self.buildDwarf,self.nsstring_data_formatter_commands)
|
||||
|
||||
|
||||
@skipUnlessDarwin
|
||||
@dsym_test
|
||||
def test_nscontainers_with_dsym_and_run_command(self):
|
||||
|
@ -191,20 +177,6 @@ class ObjCDataFormatterTestCase(TestBase):
|
|||
self.buildDwarf()
|
||||
self.kvo_data_formatter_commands()
|
||||
|
||||
@skipUnlessDarwin
|
||||
@dsym_test
|
||||
def test_rdar11106605_with_dsym_and_run_command(self):
|
||||
"""Check that Unicode characters come out of CFString summary correctly."""
|
||||
self.buildDsym()
|
||||
self.rdar11106605_commands()
|
||||
|
||||
@skipUnlessDarwin
|
||||
@dwarf_test
|
||||
def test_rdar11106605_with_dwarf_and_run_command(self):
|
||||
"""Check that Unicode characters come out of CFString summary correctly."""
|
||||
self.buildDwarf()
|
||||
self.rdar11106605_commands()
|
||||
|
||||
@skipUnlessDarwin
|
||||
@dsym_test
|
||||
def test_expr_with_dsym_and_run_command(self):
|
||||
|
@ -225,37 +197,6 @@ class ObjCDataFormatterTestCase(TestBase):
|
|||
# Find the line number to break at.
|
||||
self.line = line_number('main.m', '// Set break point at this line.')
|
||||
|
||||
def rdar11106605_commands(self):
|
||||
"""Check that Unicode characters come out of CFString summary correctly."""
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# The stop reason of the thread should be breakpoint.
|
||||
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ['stopped',
|
||||
'stop reason = breakpoint'])
|
||||
|
||||
# This is the function to remove the custom formats in order to have a
|
||||
# clean slate for the next test case.
|
||||
def cleanup():
|
||||
self.runCmd('type format clear', check=False)
|
||||
self.runCmd('type summary clear', check=False)
|
||||
self.runCmd('type synth clear', check=False)
|
||||
|
||||
|
||||
# Execute the cleanup function during test case tear down.
|
||||
self.addTearDownHook(cleanup)
|
||||
|
||||
self.expect('frame variable italian', substrs = ['L\'Italia è una Repubblica democratica, fondata sul lavoro. La sovranità appartiene al popolo, che la esercita nelle forme e nei limiti della Costituzione.'])
|
||||
self.expect('frame variable french', substrs = ['Que veut cette horde d\'esclaves, De traîtres, de rois conjurés?'])
|
||||
self.expect('frame variable german', substrs = ['Über-Ich und aus den Ansprüchen der sozialen Umwelt'])
|
||||
self.expect('frame variable japanese', substrs = ['色は匂へど散りぬるを'])
|
||||
self.expect('frame variable hebrew', substrs = ['לילה טוב'])
|
||||
|
||||
|
||||
def plain_data_formatter_commands(self):
|
||||
"""Test basic ObjC formatting behavior."""
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
@ -367,32 +308,6 @@ class ObjCDataFormatterTestCase(TestBase):
|
|||
'(NSNumber *) num_at3 = ',' (double)12.5',
|
||||
'(NSNumber *) num_at4 = ',' (double)-12.5'])
|
||||
|
||||
def nsstring_data_formatter_commands(self):
|
||||
self.expect('frame variable str0 str1 str2 str3 str4 str5 str6 str8 str9 str10 str11 label1 label2 processName str12',
|
||||
substrs = ['(NSString *) str1 = ',' @"A rather short ASCII NSString object is here"',
|
||||
# '(NSString *) str0 = ',' @"255"',
|
||||
'(NSString *) str1 = ',' @"A rather short ASCII NSString object is here"',
|
||||
'(NSString *) str2 = ',' @"A rather short UTF8 NSString object is here"',
|
||||
'(NSString *) str3 = ',' @"A string made with the at sign is here"',
|
||||
'(NSString *) str4 = ',' @"This is string number 4 right here"',
|
||||
'(NSString *) str5 = ',' @"{{1, 1}, {5, 5}}"',
|
||||
'(NSString *) str6 = ',' @"1ST"',
|
||||
'(NSString *) str8 = ',' @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime',
|
||||
'(NSString *) str9 = ',' @"a very much boring task to write a string this way!!',
|
||||
'(NSString *) str10 = ',' @"This is a Unicode string σ number 4 right here"',
|
||||
'(NSString *) str11 = ',' @"__NSCFString"',
|
||||
'(NSString *) label1 = ',' @"Process Name: "',
|
||||
'(NSString *) label2 = ',' @"Process Id: "',
|
||||
'(NSString *) str12 = ',' @"Process Name: a.out Process Id:'])
|
||||
self.expect('frame variable attrString mutableAttrString mutableGetConst',
|
||||
substrs = ['(NSAttributedString *) attrString = ',' @"hello world from foo"',
|
||||
'(NSAttributedString *) mutableAttrString = ',' @"hello world from foo"',
|
||||
'(NSString *) mutableGetConst = ',' @"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 foo"'])
|
||||
|
||||
self.expect('expr -d run-target -- path',substrs = ['usr/blah/stuff'])
|
||||
self.expect('frame variable path',substrs = ['usr/blah/stuff'])
|
||||
|
||||
|
||||
def nscontainers_data_formatter_commands(self):
|
||||
self.expect('frame variable newArray newDictionary newMutableDictionary cfdict_ref mutable_dict_ref cfarray_ref mutable_array_ref',
|
||||
substrs = ['(NSArray *) newArray = ','@"50 objects"',
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
LEVEL = ../../../../make
|
||||
|
||||
OBJC_SOURCES := main.m
|
||||
|
||||
CFLAGS_EXTRAS += -w
|
||||
|
||||
include $(LEVEL)/Makefile.rules
|
||||
|
||||
LDFLAGS += -framework Foundation
|
|
@ -0,0 +1,109 @@
|
|||
# encoding: utf-8
|
||||
"""
|
||||
Test lldb data formatter subsystem.
|
||||
"""
|
||||
|
||||
import os, time
|
||||
import unittest2
|
||||
import lldb
|
||||
from lldbtest import *
|
||||
import datetime
|
||||
import lldbutil
|
||||
|
||||
class NSStringDataFormatterTestCase(TestBase):
|
||||
|
||||
mydir = TestBase.compute_mydir(__file__)
|
||||
|
||||
def appkit_tester_impl(self,builder,commands):
|
||||
builder()
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# The stop reason of the thread should be breakpoint.
|
||||
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ['stopped',
|
||||
'stop reason = breakpoint'])
|
||||
|
||||
# This is the function to remove the custom formats in order to have a
|
||||
# clean slate for the next test case.
|
||||
def cleanup():
|
||||
self.runCmd('type format clear', check=False)
|
||||
self.runCmd('type summary clear', check=False)
|
||||
self.runCmd('type synth clear', check=False)
|
||||
|
||||
|
||||
# Execute the cleanup function during test case tear down.
|
||||
self.addTearDownHook(cleanup)
|
||||
commands()
|
||||
|
||||
@skipUnlessDarwin
|
||||
@dsym_test
|
||||
def test_nsstring_with_dsym_and_run_command(self):
|
||||
"""Test formatters for NSString."""
|
||||
self.appkit_tester_impl(self.buildDsym,self.nsstring_data_formatter_commands)
|
||||
|
||||
@skipUnlessDarwin
|
||||
@dwarf_test
|
||||
def test_nsstring_with_dwarf_and_run_command(self):
|
||||
"""Test formatters for NSString."""
|
||||
self.appkit_tester_impl(self.buildDwarf,self.nsstring_data_formatter_commands)
|
||||
|
||||
@skipUnlessDarwin
|
||||
@dsym_test
|
||||
def test_rdar11106605_with_dsym_and_run_command(self):
|
||||
"""Check that Unicode characters come out of CFString summary correctly."""
|
||||
self.appkit_tester_impl(self.buildDsym,self.rdar11106605_commands)
|
||||
|
||||
@skipUnlessDarwin
|
||||
@dwarf_test
|
||||
def test_rdar11106605_with_dwarf_and_run_command(self):
|
||||
"""Check that Unicode characters come out of CFString summary correctly."""
|
||||
self.appkit_tester_impl(self.buildDwarf,self.rdar11106605_commands)
|
||||
|
||||
def setUp(self):
|
||||
# Call super's setUp().
|
||||
TestBase.setUp(self)
|
||||
# Find the line number to break at.
|
||||
self.line = line_number('main.m', '// break here')
|
||||
|
||||
def rdar11106605_commands(self):
|
||||
"""Check that Unicode characters come out of CFString summary correctly."""
|
||||
self.expect('frame variable italian', substrs = ['L\'Italia è una Repubblica democratica, fondata sul lavoro. La sovranità appartiene al popolo, che la esercita nelle forme e nei limiti della Costituzione.'])
|
||||
self.expect('frame variable french', substrs = ['Que veut cette horde d\'esclaves, De traîtres, de rois conjurés?'])
|
||||
self.expect('frame variable german', substrs = ['Über-Ich und aus den Ansprüchen der sozialen Umwelt'])
|
||||
self.expect('frame variable japanese', substrs = ['色は匂へど散りぬるを'])
|
||||
self.expect('frame variable hebrew', substrs = ['לילה טוב'])
|
||||
|
||||
def nsstring_data_formatter_commands(self):
|
||||
self.expect('frame variable str0 str1 str2 str3 str4 str5 str6 str8 str9 str10 str11 label1 label2 processName str12',
|
||||
substrs = ['(NSString *) str1 = ',' @"A rather short ASCII NSString object is here"',
|
||||
# '(NSString *) str0 = ',' @"255"',
|
||||
'(NSString *) str1 = ',' @"A rather short ASCII NSString object is here"',
|
||||
'(NSString *) str2 = ',' @"A rather short UTF8 NSString object is here"',
|
||||
'(NSString *) str3 = ',' @"A string made with the at sign is here"',
|
||||
'(NSString *) str4 = ',' @"This is string number 4 right here"',
|
||||
'(NSString *) str5 = ',' @"{{1, 1}, {5, 5}}"',
|
||||
'(NSString *) str6 = ',' @"1ST"',
|
||||
'(NSString *) str8 = ',' @"hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime',
|
||||
'(NSString *) str9 = ',' @"a very much boring task to write a string this way!!',
|
||||
'(NSString *) str10 = ',' @"This is a Unicode string σ number 4 right here"',
|
||||
'(NSString *) str11 = ',' @"__NSCFString"',
|
||||
'(NSString *) label1 = ',' @"Process Name: "',
|
||||
'(NSString *) label2 = ',' @"Process Id: "',
|
||||
'(NSString *) str12 = ',' @"Process Name: a.out Process Id:'])
|
||||
self.expect('frame variable attrString mutableAttrString mutableGetConst',
|
||||
substrs = ['(NSAttributedString *) attrString = ',' @"hello world from foo"',
|
||||
'(NSAttributedString *) mutableAttrString = ',' @"hello world from foo"',
|
||||
'(NSString *) mutableGetConst = ',' @"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 foo"'])
|
||||
|
||||
self.expect('expr -d run-target -- path',substrs = ['usr/blah/stuff'])
|
||||
self.expect('frame variable path',substrs = ['usr/blah/stuff'])
|
||||
|
||||
if __name__ == '__main__':
|
||||
import atexit
|
||||
lldb.SBDebugger.Initialize()
|
||||
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
||||
unittest2.main()
|
|
@ -0,0 +1,85 @@
|
|||
//===-- main.m ------------------------------------------------*- ObjC -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
|
||||
#define IOS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(IOS)
|
||||
#import <Foundation/NSGeometry.h>
|
||||
#else
|
||||
#import <Carbon/Carbon.h>
|
||||
#endif
|
||||
|
||||
int main (int argc, const char * argv[])
|
||||
{
|
||||
|
||||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
NSString *str0 = [[NSNumber numberWithUnsignedLongLong:0xFF] stringValue];
|
||||
NSString *str1 = [NSString stringWithCString:"A rather short ASCII NSString object is here" encoding:NSASCIIStringEncoding];
|
||||
NSString *str2 = [NSString stringWithUTF8String:"A rather short UTF8 NSString object is here"];
|
||||
NSString *str3 = @"A string made with the at sign is here";
|
||||
NSString *str4 = [NSString stringWithFormat:@"This is string number %ld right here", (long)4];
|
||||
NSRect ns_rect_4str = {{1,1},{5,5}};
|
||||
NSString* str5 = NSStringFromRect(ns_rect_4str);
|
||||
NSString* str6 = [@"/usr/doc/README.1ST" pathExtension];
|
||||
const unichar myCharacters[] = {0x03C3,'x','x'};
|
||||
NSString *str7 = [NSString stringWithCharacters: myCharacters
|
||||
length: sizeof myCharacters / sizeof *myCharacters];
|
||||
NSString* str8 = [@"/usr/doc/file.hasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTimehasVeryLongExtensionThisTime" pathExtension];
|
||||
const unichar myOtherCharacters[] = {'a',' ', 'v','e','r','y',' ',
|
||||
'm','u','c','h',' ','b','o','r','i','n','g',' ','t','a','s','k',
|
||||
' ','t','o',' ','w','r','i','t','e', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ',
|
||||
't','h','i','s',' ','w','a','y','!','!',0x03C3, 0};
|
||||
NSString *str9 = [NSString stringWithCharacters: myOtherCharacters
|
||||
length: sizeof myOtherCharacters / sizeof *myOtherCharacters];
|
||||
const unichar myNextCharacters[] = {0x03C3, 0x0000};
|
||||
NSString *str10 = [NSString stringWithFormat:@"This is a Unicode string %S number %ld right here", myNextCharacters, (long)4];
|
||||
NSString *str11 = NSStringFromClass([str10 class]);
|
||||
NSString *label1 = @"Process Name: ";
|
||||
NSString *label2 = @"Process Id: ";
|
||||
NSString *processName = [[NSProcessInfo processInfo] processName];
|
||||
NSString *processID = [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]];
|
||||
NSString *str12 = [NSString stringWithFormat:@"%@ %@ %@ %@", label1, processName, label2, processID];
|
||||
NSString *eAcute = [NSString stringWithFormat: @"%C", 0x00E9];
|
||||
NSString *randomHaziChar = [NSString stringWithFormat: @"%C", 0x9DC5];
|
||||
NSString *japanese = @"色は匂へど散りぬるを";
|
||||
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.";
|
||||
NSString* french = @"Que veut cette horde d'esclaves, De traîtres, de rois conjurés?";
|
||||
NSString* german = @"Über-Ich und aus den Ansprüchen der sozialen Umwelt";
|
||||
void* data_set[3] = {str1,str2,str3};
|
||||
NSString *hebrew = [NSString stringWithString:@"לילה טוב"];
|
||||
|
||||
NSAttributedString* attrString = [[NSAttributedString alloc] initWithString:@"hello world from foo" attributes:[NSDictionary new]];
|
||||
[attrString isEqual:nil];
|
||||
NSAttributedString* mutableAttrString = [[NSMutableAttributedString alloc] initWithString:@"hello world from foo" attributes:[NSDictionary new]];
|
||||
[mutableAttrString isEqual:nil];
|
||||
|
||||
NSString* mutableString = [[NSMutableString alloc] initWithString:@"foo"];
|
||||
[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];
|
||||
|
||||
NSString* mutableGetConst = [NSString stringWithCString:[mutableString cString]];
|
||||
|
||||
[mutableGetConst length];
|
||||
CFMutableStringRef mutable_string_ref = CFStringCreateMutable(NULL,100);
|
||||
CFStringAppend(mutable_string_ref, CFSTR("Wish ya knew"));
|
||||
CFStringRef cfstring_ref = CFSTR("HELLO WORLD");
|
||||
|
||||
NSArray *components = @[@"usr", @"blah", @"stuff"];
|
||||
NSString *path = [NSString pathWithComponents: components];
|
||||
|
||||
[pool drain]; // break here
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue