forked from dotnet/ClangSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCXCursor.cs
More file actions
61 lines (50 loc) · 1.89 KB
/
Copy pathCXCursor.cs
File metadata and controls
61 lines (50 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
namespace ClangSharp.UnitTests;
public class CXCursorTest : TranslationUnitTest
{
[Test]
public void AttrKindSpelling()
{
var inputContents =
$$"""
int theUniverseAndEverything ();
int main () { return 0; }
""";
using var translationUnit = CreateTranslationUnit(inputContents);
var functionDecls = translationUnit.TranslationUnitDecl.Decls.OfType<FunctionDecl>().ToList ();
Assert.That (functionDecls.Count, Is.GreaterThan (0), "Function");
foreach (var functionDecl in functionDecls) {
Assert.That (functionDecl.Handle.AttrKindSpelling, Is.Not.Null.Or.Empty, "AttrKindSpelling");
}
}
[Test]
public void IsExternC()
{
var inputContents =
$$"""
extern "C" {
int theUniverseAndEverything = 0;
int hitchhike ();
}
""";
using var translationUnit = CreateTranslationUnit(inputContents);
var allDecls = new List<Decl>();
allDecls.AddRange(translationUnit.TranslationUnitDecl.Decls);
allDecls.AddRange(allDecls.OfType<LinkageSpecDecl>().SelectMany(v => v.Decls).ToList());
var functionDecls = allDecls.OfType<FunctionDecl>().ToList();
Assert.That(functionDecls.Count, Is.GreaterThan(0), "Function");
foreach (var decl in functionDecls)
{
Assert.That(decl.IsExternC, Is.True, "IsExternC function");
}
var varDecls = allDecls.OfType<VarDecl>().ToList();
Assert.That(varDecls.Count, Is.GreaterThan(0), "Var");
foreach (var decl in varDecls)
{
Assert.That(decl.IsExternC, Is.True, "IsExternC var");
}
}
}