1 module parse.sourcerange;
2 
3 
4 import test.infra;
5 import clang;
6 
7 
8 @("path")
9 @safe unittest {
10     import clang.c.index: CXType_Pointer;
11     with(NewTranslationUnit("foo.cpp",
12                             q{
13                                 const char* newString();
14                             }))
15     {
16         const cursor = translUnit.cursor;
17         const function_ = cursor.children[0];
18         function_.sourceRange.path.should == inSandboxPath("foo.cpp");
19     }
20 }
21 
22 
23 @("start")
24 @safe unittest {
25     import clang.c.index: CXType_Pointer;
26     with(NewTranslationUnit("foo.cpp",
27                             q{
28                                 const char* newString();
29                             }))
30     {
31         const cursor = translUnit.cursor;
32         const function_ = cursor.children[0];
33 
34         function_.sourceRange.start.path.should == inSandboxPath("foo.cpp");
35         function_.sourceRange.start.line.should == 2;
36         function_.sourceRange.start.column.should == 33;
37         version(Windows)
38             function_.sourceRange.start.offset.should == 34;
39         else
40             function_.sourceRange.start.offset.should == 33;
41     }
42 }
43 
44 
45 @("end")
46 @safe unittest {
47     import clang.c.index: CXType_Pointer;
48     with(NewTranslationUnit("foo.cpp",
49                             q{
50                                 const char* newString();
51                             }))
52     {
53         const cursor = translUnit.cursor;
54         const function_ = cursor.children[0];
55 
56         function_.sourceRange.end.path.should == inSandboxPath("foo.cpp");
57         function_.sourceRange.end.line.should == 2;
58         function_.sourceRange.end.column.should == 56;
59         version(Windows)
60             function_.sourceRange.end.offset.should == 57;
61         else
62             function_.sourceRange.end.offset.should == 56;
63     }
64 }