1# encoding: utf-8
2"""
3Test lldb data formatter subsystem.
4"""
5
6
7import lldb
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10from lldbsuite.test import lldbutil
11
12from ObjCDataFormatterTestCase import ObjCDataFormatterTestCase
13
14
15class ObjCDataFormatterNSContainer(ObjCDataFormatterTestCase):
16
17    @skipUnlessDarwin
18    def test_nscontainers_with_run_command(self):
19        """Test formatters for  NS container classes."""
20        self.appkit_tester_impl(self.nscontainers_data_formatter_commands)
21
22    def nscontainers_data_formatter_commands(self):
23        self.expect(
24            'frame variable newArray nsDictionary newDictionary nscfDictionary cfDictionaryRef newMutableDictionary cfarray_ref mutable_array_ref',
25            substrs=[
26                '(NSArray *) newArray = ',
27                ' @"50 elements"',
28                '(NSDictionary *) nsDictionary = ',
29                ' 2 key/value pairs',
30                '(NSDictionary *) newDictionary = ',
31                ' 12 key/value pairs',
32                '(CFDictionaryRef) cfDictionaryRef = ',
33                ' 3 key/value pairs',
34                '(NSDictionary *) newMutableDictionary = ',
35                ' 21 key/value pairs',
36                '(CFArrayRef) cfarray_ref = ',
37                ' @"3 elements"',
38                '(CFMutableArrayRef) mutable_array_ref = ',
39                ' @"11 elements"',
40            ])
41
42        self.expect(
43            'frame variable iset1 iset2 imset',
44            substrs=['4 indexes', '512 indexes', '10 indexes'])
45
46        self.expect(
47            'frame variable binheap_ref',
48            substrs=['(CFBinaryHeapRef) binheap_ref = ', '@"21 items"'])
49
50        self.expect(
51            'expression -d run -- (NSArray*)[NSArray new]',
52            substrs=['@"0 elements"'])
53