|
1 | 1 | using System;
|
2 | 2 | using System.IO;
|
3 | 3 | using System.Reflection;
|
4 |
| -using System.Text.RegularExpressions; |
5 | 4 | using CppSharp.AST;
|
6 | 5 | using CppSharp.Generators;
|
7 |
| -using NUnit.Framework; |
8 | 6 |
|
9 | 7 | namespace CppSharp.Utils
|
10 | 8 | {
|
@@ -107,84 +105,4 @@ static string GetOutputDirectory()
|
107 | 105 | }
|
108 | 106 | #endregion
|
109 | 107 | }
|
110 |
| - |
111 |
| - /// <summary> |
112 |
| - /// The main NUnit fixture base class for a generator-based tests project. |
113 |
| - /// Provides support for a text-based test system that looks for lines |
114 |
| - /// in the native test declarations that match a certain pattern, which |
115 |
| - /// are used for certain kinds of tests that cannot be done with just |
116 |
| - /// C# code and using the generated wrappers. |
117 |
| - /// </summary> |
118 |
| - [TestFixture] |
119 |
| - public abstract class GeneratorTestFixture |
120 |
| - { |
121 |
| - readonly string assemblyName; |
122 |
| - |
123 |
| - protected GeneratorTestFixture() |
124 |
| - { |
125 |
| - var location = Assembly.GetCallingAssembly().Location; |
126 |
| - assemblyName = Path.GetFileNameWithoutExtension(location); |
127 |
| - } |
128 |
| - |
129 |
| - static bool GetGeneratorKindFromLang(string lang, out GeneratorKind kind) |
130 |
| - { |
131 |
| - kind = GeneratorKind.CSharp; |
132 |
| - |
133 |
| - switch(lang) |
134 |
| - { |
135 |
| - case "CSharp": |
136 |
| - case "C#": |
137 |
| - kind = GeneratorKind.CSharp; |
138 |
| - return true; |
139 |
| - case "CLI": |
140 |
| - kind = GeneratorKind.CLI; |
141 |
| - return true; |
142 |
| - } |
143 |
| - |
144 |
| - return false; |
145 |
| - } |
146 |
| - |
147 |
| - [Test] |
148 |
| - public void CheckDirectives() |
149 |
| - { |
150 |
| - var name = assemblyName.Substring(0, assemblyName.IndexOf('.')); |
151 |
| - var kind = assemblyName.Substring(assemblyName.LastIndexOf('.') + 1); |
152 |
| - GeneratorKind testKind; |
153 |
| - if (!GetGeneratorKindFromLang(kind, out testKind)) |
154 |
| - throw new NotSupportedException("Unknown language generator"); |
155 |
| - |
156 |
| - var path = Path.GetFullPath(GeneratorTest.GetTestsDirectory(name)); |
157 |
| - |
158 |
| - foreach (var header in Directory.EnumerateFiles(path, "*.h")) |
159 |
| - { |
160 |
| - var headerText = File.ReadAllText(header); |
161 |
| - |
162 |
| - // Parse the header looking for suitable lines to test. |
163 |
| - foreach (var line in File.ReadAllLines(header)) |
164 |
| - { |
165 |
| - var match = Regex.Match(line, @"^\s*///*\s*(\S+)\s*:\s*(.*)"); |
166 |
| - if (!match.Success) |
167 |
| - continue; |
168 |
| - |
169 |
| - var matchLang = match.Groups[1].Value; |
170 |
| - GeneratorKind matchKind; |
171 |
| - if (!GetGeneratorKindFromLang(matchLang.ToUpper(), out matchKind)) |
172 |
| - continue; |
173 |
| - |
174 |
| - if (matchKind != testKind) |
175 |
| - continue; |
176 |
| - |
177 |
| - var matchText = match.Groups[2].Value; |
178 |
| - if (string.IsNullOrWhiteSpace(matchText)) |
179 |
| - continue; |
180 |
| - |
181 |
| - var matchIndex = headerText.IndexOf(matchText, StringComparison.Ordinal); |
182 |
| - Assert.IsTrue(matchIndex != -1, |
183 |
| - string.Format("Could not match '{0}' in file '{1}'", |
184 |
| - matchText, header)); |
185 |
| - } |
186 |
| - } |
187 |
| - |
188 |
| - } |
189 |
| - } |
190 | 108 | }
|
0 commit comments