public void GetSkippedBlocks_IfDefinedBlockWithDefinedMacro_SkippedBlockIncludesIfDefinedBlock() { File.WriteAllText(sourceFilePath, @"#if defined(__GNUC__) # include <avr/io.h> #elif defined(__ICCAVR__) # include <ioavr.h> # include <intrinsics.h> #else # error Unsupported compiler. #endif"); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var preprocessor = adapter.GetPreprocessor(); { var skippedBlocks = preprocessor.GetSkippedBlockLineNumbers(); var skippedBlock = skippedBlocks.First(); Assert.AreEqual(4, skippedBlock.Item1); Assert.AreEqual(5, skippedBlock.Item2); skippedBlock = skippedBlocks.ElementAt(1); Assert.AreEqual(7, skippedBlock.Item1); Assert.AreEqual(7, skippedBlock.Item2); } }
public void GetSkippedBlocks_IfMultipleElifDirectiveWithIfDirectiveFalseAndSecondElifDirectiveTrue_SkippedBlockIncludesSecondElifBlock() { File.WriteAllText(sourceFilePath, @"#define X 0 #define Y 0 #define Z 2 #if X #define foo x*y #elif Y #define foo x/y #elif Z #define foo x-y #endif "); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var preprocessor = adapter.GetPreprocessor(); { var skippedBlocks = preprocessor.GetSkippedBlockLineNumbers(); var skippedBlock = skippedBlocks.First(); Assert.AreEqual(4, skippedBlock.Item1); Assert.AreEqual(8, skippedBlock.Item2); } }
public void GetDiagnostics_CFileInDiskHasPreprocessorCodeAndNoWarningsTextHasOneWarning_OneDiagnosticsReturned() { var sourceInFile = @"#if defined(__GNUC__) int x = 20; #elif defined (__ICCAVR__) int x = 30; int y = 20; #else #error Unsupported compiler #endif "; var sourceInEditor = sourceInFile + @"int func(){ } int main(){} "; File.WriteAllText(sourceFilePath, sourceInFile); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(sourceInFile); var diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count); adapter.Process(sourceInEditor); diags = adapter.GetDiagnostics(); Assert.AreEqual(1, diags.Count); Assert.AreEqual(9, diags.First().StartLine); }
public void GetSkippedBlocks_IfSingleElifDirectiveWithElifDirectiveFalse_SkippedBlockIncludesElifBlock() { File.WriteAllText(sourceFilePath, @"#define X 1 #define Y 0 #define Z 0 #if X #define foo x*y #elif Z + 0 #define foo x+y #elif Y #define foo x/y #elif Z #define foo x-y #endif "); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var preprocessor = adapter.GetPreprocessor(); { var skippedBlocks = preprocessor.GetSkippedBlockLineNumbers(); var skippedBlock = skippedBlocks.First(); Assert.AreEqual(6, skippedBlock.Item1); Assert.AreEqual(12, skippedBlock.Item2); } }
public void GetSkippedBlocks_TwoIfBlocksBothFalse_SkippedBlockIncludesBothBlocks() { File.WriteAllText(sourceFilePath, @"#if 0 #define foo x+y #endif #if 0 #define foo x-y #endif "); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var preprocessor = adapter.GetPreprocessor(); { var skippedBlocks = preprocessor.GetSkippedBlockLineNumbers(); var skippedBlock = skippedBlocks.First(); Assert.AreEqual(1, skippedBlock.Item1); Assert.AreEqual(3, skippedBlock.Item2); skippedBlock = skippedBlocks.ElementAt(1); Assert.AreEqual(4, skippedBlock.Item1); Assert.AreEqual(6, skippedBlock.Item2); } }
public void GetSkippedBlocks_EmptyFile_NoSkippedBlocksReported() { File.WriteAllText(sourceFilePath, @""); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); AssertSkippedBlocksMatch(adapter, new Tuple<int, int>[] { }); }
public void GetDiagnostics_EmptyCFile_NoDiagnosticsReturned() { File.WriteAllText(sourceFilePath, ""); var adapter = new ClangAdapter(sourceFilePath); var diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count); }
public void GetDiagnostics_C99StyleSyntaxUsedWithC99TurnedOn_NoDiagnosticsReturned() { File.WriteAllText(sourceFilePath, @"int main() { for (int i = 0; i < 10; i++){} for (int i = 0; i < 10; i++){} return 0;}"); var adapter = new ClangAdapter(sourceFilePath, new List<string>(), new List<string>(), Language.C99); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count); }
public void GetSkippedBlocks_EmptyFile_NoSkippedBlocksReported() { File.WriteAllText(sourceFilePath, @""); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); AssertSkippedBlocksMatch(adapter, new Tuple <int, int>[] { }); }
public void GetDiagnostics_boolKeyword_NoDiagnosticsReported() { File.WriteAllText(sourceFilePath, @" bool test = true;"); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count()); }
private static ClangAdapter GetClangAdapterForBuffer(ITextBuffer buffer) { ClangAdapter clangAdapter = null; ThreadHelper.Generic.Invoke(new Action(() => { clangAdapter = buffer.Properties.GetOrCreateSingletonProperty <ClangAdapter>(() => CreateClangAdapter(buffer)); })); return(clangAdapter); }
public void GetDiagnostics_InlineKeyword_NoDiagnosticsReported() { File.WriteAllText(sourceFilePath, @"static inline void Foo(){}"); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count()); }
public void GetDiagnostics_MisspelledMemberName_DiagnosticIncludesSuggestedMember() { File.WriteAllText(sourceFilePath, @"struct A { int Foo; }; int main() { struct A a; a.Fo = 2; }"); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var diags = adapter.GetDiagnostics(); StringAssert.Contains(diags.First().Message, "did you mean 'Foo'?"); }
public void GetDiagnostics_AVRGCCSpecificBuiltin_NoDiagnosticsReported() { File.WriteAllText(sourceFilePath, @"void fun() { __builtin_csrf(1); }"); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count()); }
public void GetDiagnostics_C99StyleSyntaxUsedWithC99TurnedOn_NoDiagnosticsReturned() { File.WriteAllText(sourceFilePath, @"int main() { for (int i = 0; i < 10; i++){} for (int i = 0; i < 10; i++){} return 0;}"); var adapter = new ClangAdapter(sourceFilePath, new List <string>(), new List <string>(), Language.C99); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count); }
public void GetDiagnostics_EmptyCppFile_NoDiagnosticsReturned() { File.WriteAllText(cppSourceFilePath, ""); var adapter = new ClangAdapter(cppSourceFilePath, new List <string>(), new List <string>(), Language.Cpp); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count); }
public void GetDiagnostics_ClassDeclarationInCpp_NoDiagnosticsReturned() { File.WriteAllText(cppSourceFilePath, @" class C{}; "); var adapter = new ClangAdapter(cppSourceFilePath, new List <string>(), new List <string>(), Language.Cpp); adapter.Process(null); Assert.AreEqual(0, adapter.GetDiagnostics().Count()); }
public void GetDiagnostics_ShortCastToIntPointerForARM_OneDiagnosticsReported() { File.WriteAllText(sourceFilePath, @"volatile short x; int main() { return *(int *)x; }"); var adapter = new ClangAdapter(sourceFilePath, new List <string>(), new List <string>(), Language.C, Arch.ARM); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(1, diags.Count()); }
public void GetDiagnostics_LongLongCastToUInt32ForARM_OneDiagnosticsReported() { File.WriteAllText(sourceFilePath, @"int main() { typedef unsigned int uint32_t __attribute__((__mode__(SI))); uint32_t v = 0xABCDEFABCD; return 1; }"); var adapter = new ClangAdapter(sourceFilePath, new List <string>(), new List <string>(), Language.C, Arch.ARM); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(1, diags.Count()); }
public void GetDiagnostics_LongCastToUInt32ForAVR_NoDiagnosticsReported() { File.WriteAllText(sourceFilePath, @"int main() { typedef unsigned int uint32_t __attribute__((__mode__(SI))); uint32_t v = 0xABCDEFABL; return 1; }"); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count()); }
[TestMethod] public void GetDiagnostics_ShortCastToIntPointerForAVR_NoDiagnosticsReported() { File.WriteAllText(sourceFilePath, @"volatile short x; int main() { return *(int *)x; }"); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count()); }
public void GetDiagnostics_Cpp11StyleSyntaxUsedWithCpp11TurnedOn_NoDiagnosticsReturned() { File.WriteAllText(cppSourceFilePath, @"auto it = 4;"); var adapter = new ClangAdapter(cppSourceFilePath, new List <string>(), new List <string>(), Language.Cpp11); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count); }
public void GetDiagnostics_asmExtension_NoDiagnosticsReported() { File.WriteAllText(sourceFilePath, @" #define barrier() asm volatile("""" ::: ""memory"") int main() { barrier(); }"); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count()); }
public void GetDiagnostics_DestructorDefinedOutsideClassWithCpp11TurnedOn_NoDiagnosticsReturned() { File.WriteAllText(cppSourceFilePath, @"class C { ~C(); }; C::~C() {}"); var adapter = new ClangAdapter(cppSourceFilePath, new List <string>(), new List <string>(), Language.Cpp11); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count); }
public void GetSkippedBlocks_IfDirectiveWithoutDefinition_SkippedBlockIncludesIfBlock() { File.WriteAllText(sourceFilePath, @"#if 2 - 2 #define foo x*y #endif "); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); AssertSkippedBlocksMatch(adapter, new[] { Tuple.Create(1, 3) }); }
void AssertSkippedBlocksMatch(ClangAdapter adapter, IEnumerable <Tuple <int, int> > expected) { var preprocessor = adapter.GetPreprocessor(); var skippedBlockLineNumbers = preprocessor.GetSkippedBlockLineNumbers(); Assert.AreEqual(expected.Count(), skippedBlockLineNumbers.Count()); for (int i = 0; i < expected.Count(); ++i) { Assert.AreEqual(expected.ElementAt(i), skippedBlockLineNumbers.ElementAt(i)); } }
public void ExpandMacro_MacroDefinitionIncludesAnotherMacro_ExpansionExpandsInnerMacro() { File.WriteAllText(sourceFilePath, @" #define x 2 #define foo x*y "); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var preprocessor = adapter.GetPreprocessor(); { Assert.AreEqual("2*y", preprocessor.ExpandMacro("foo")); } }
public void GetDiagnostics_SymbolInSourceCodeProvidedInPredefinedSymbolList_NoDiagnosticsReturned() { File.WriteAllText(sourceFilePath, @"int main() { return FOO; }"); var adapter = new ClangAdapter(sourceFilePath, new List <string>(), new List <string>() { "FOO=2" }); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count); }
public void GetSkippedBlocks_UnmatchedExcludedIf_EverythingAfterIfReportedAsSkippedBlock() { File.WriteAllText(sourceFilePath, @"int nothing = 0; #if 0 #define blah 0 #define blah 2 "); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); AssertSkippedBlocksMatch(adapter, new[] { Tuple.Create(2, 5) }); }
public void GetDiagnostics_CFileInDiskHasOneWarningTextHasNoWarning_OneDiagnosticsReturned() { var sourceInEditor = "int func(){ return 0; }"; var sourceInFile = "int func(){}"; File.WriteAllText(sourceFilePath, sourceInFile); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(sourceInEditor); var diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count); }
public void GetDiagnostics_CFileInDiskWithOneWarning_OneDiagnosticsReturned() { var sourceText = "int func(){}"; File.WriteAllText(sourceFilePath, sourceText); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(1, diags.Count); }
public void GetDiagnostics_SingleLineCommentWithAsterisk_NoDiagnosticsReported() { File.WriteAllText(sourceFilePath, @" //* int main() { return 0; } "); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count()); }
public void GetSkippedBlocks_IfDirectiveWithElseDirectiveEvaluationTrue_SkippedBlockIncludesElseBlock() { File.WriteAllText(sourceFilePath, @"#if 2 #define foo x*y #else #define foo x-y #endif "); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); AssertSkippedBlocksMatch(adapter, new[] { Tuple.Create(3, 5) }); }
public void GetSkippedBlocks_IfBlockWithMultiplePreprocessorDefinitions_SkippedBlockIncludesAllLines() { File.WriteAllText(sourceFilePath, @"#if 0 #define foo x+y #define fat boo #define fal laf #endif "); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var preprocessor = adapter.GetPreprocessor(); { var skippedBlocks = preprocessor.GetSkippedBlockLineNumbers(); var skippedBlock = skippedBlocks.First(); Assert.AreEqual(2, skippedBlock.Item1); Assert.AreEqual(4, skippedBlock.Item2); } }
public void GetSkippedBlocks_IfBlockWithMultiplePreprocessorDefinitionsIsTrue_SkippedBlockIsEmpty() { File.WriteAllText(sourceFilePath, @"#if 1 #define foo x+y #define fat boo #define fal laf #endif int x = 20; #if 1 #define foo x+y #define fat boo #define fal laf #endif "); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var preprocessor = adapter.GetPreprocessor(); { var skippedBlocks = preprocessor.GetSkippedBlockLineNumbers(); Assert.IsFalse(skippedBlocks.Any()); } }
public void GetDiagnostics_ShortCastToIntPointerForAVR_NoDiagnosticsReported() { File.WriteAllText(sourceFilePath, @"volatile short x; int main() { return *(int *)x; }"); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count()); }
public void GetSkippedBlocks_IfMultipleElifDirectiveWithIfDirectiveFalseAndFirstElifDirectiveTrue_SkippedBlockIncludesFirstElifBlock() { File.WriteAllText(sourceFilePath, @"#define X 0 #define Y 1 #define Z 2 #if X #define foo x*y #elif Y #define foo x/y #elif Z #define foo x-y #endif "); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); AssertSkippedBlocksMatch(adapter, new[] { Tuple.Create(5, 5), Tuple.Create(9, 9)}); }
public void GetSkippedBlocks_IfElseBlockWithElseBlockExcludedAndCodeTypedBeforeBlock_SkippedBlockIncludesExcludedCode() { var mainCode = @"#if BLAH #define foo x+y #define bar x-y #else #define fal laf #endif"; File.WriteAllText(sourceFilePath, mainCode); var adapter = new ClangAdapter(sourceFilePath); var preprocessor = adapter.GetPreprocessor(); adapter.Process(mainCode); AssertSkippedBlocksMatch(adapter, new[] { Tuple.Create(3, 4) }); var initialText = "#define BLAH 0" + Environment.NewLine + mainCode; adapter.Process(initialText); AssertSkippedBlocksMatch(adapter, new[] { Tuple.Create(3, 4) }); var laterText = "#define BLAH 2" + Environment.NewLine + mainCode; adapter.Process(laterText); AssertSkippedBlocksMatch(adapter, new[] { Tuple.Create(6, 6) }); adapter.Process(initialText); AssertSkippedBlocksMatch(adapter, new[] { Tuple.Create(3, 4) }); adapter.Process(laterText); AssertSkippedBlocksMatch(adapter, new[] { Tuple.Create(6, 6) }); adapter.Process(initialText); AssertSkippedBlocksMatch(adapter, new[] { Tuple.Create(3, 4) }); }
public void GetSkippedBlocks_IfDirectiveWithElseDirectiveEvaluationTrue_SkippedBlockIncludesElseBlock() { File.WriteAllText(sourceFilePath, @"#if 2 #define foo x*y #else #define foo x-y #endif "); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); AssertSkippedBlocksMatch(adapter, new[] { Tuple.Create(4, 4)}); }
public void GetSkippedBlocks_IfDefinedBlockWithUndefinedMacro_SkippedBlockIncludesIfDefinedBlock() { File.WriteAllText(sourceFilePath, @"#if defined(OOLALALA) # include <avr/io.h> #endif"); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var preprocessor = adapter.GetPreprocessor(); { var skippedBlocks = preprocessor.GetSkippedBlockLineNumbers(); var skippedBlock = skippedBlocks.First(); Assert.AreEqual(2, skippedBlock.Item1); Assert.AreEqual(2, skippedBlock.Item2); } }
public void GetDiagnostics_WarningMadeAndCorrectedInEditor_ZeroDiagnosticsReturned() { var initialSourceInEditor = "int func(){ }"; var currentSourceInEditor = "int func(){ return 0; }"; var sourceInFile = ""; File.WriteAllText(sourceFilePath, sourceInFile); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count); adapter.Process(initialSourceInEditor); diags = adapter.GetDiagnostics(); Assert.AreEqual(1, diags.Count); adapter.Process(currentSourceInEditor); diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count); }
public void GetSkippedBlocks_UnmatchedExcludedIf_EverythingAfterIfReportedAsSkippedBlock() { File.WriteAllText(sourceFilePath, @"int nothing = 0; #if 0 #define blah 0 #define blah 2 "); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); AssertSkippedBlocksMatch(adapter, new[] { Tuple.Create(3, 0) }); }
void AssertSkippedBlocksMatch(ClangAdapter adapter, IEnumerable<Tuple<int, int>> expected) { var preprocessor = adapter.GetPreprocessor(); var skippedBlockLineNumbers = preprocessor.GetSkippedBlockLineNumbers(); Assert.AreEqual(expected.Count(), skippedBlockLineNumbers.Count()); for (int i = 0; i < expected.Count(); ++i) { Assert.AreEqual(expected.ElementAt(i), skippedBlockLineNumbers.ElementAt(i)); } }
public void GetSkippedBlocks_IfNDefDirectiveWithDefinition_SkippedBlockIncludesElseBlock() { File.WriteAllText(sourceFilePath, @"#define HUHU 1 #ifndef HUHU #define foo x*y #else #define foo x-y #endif "); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); AssertSkippedBlocksMatch(adapter, new[] { Tuple.Create(3, 3)}); }
public void GetSkippedBlocks_IfDefDirectiveWithoutDefinition_SkippedBlockIncludesIfdefBlock() { File.WriteAllText(sourceFilePath, @"#ifdef x #define foo x*y #endif "); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); AssertSkippedBlocksMatch(adapter, new[] { Tuple.Create(2,2)}); }
public void GetDiagnostics_UnknownAttribute_WarningReported() { File.WriteAllText(sourceFilePath, @"__attribute__((__interrupt__)) void rtc() {}"); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var diags = adapter.GetDiagnostics().ToList(); Assert.AreEqual(1, diags.Count()); var diag = diags[0]; Assert.AreEqual(DiagnosticLevel.Warning, diag.Level); }
public void GetDiagnostics_SymbolInSourceCodeProvidedInPredefinedSymbolList_NoDiagnosticsReturned() { File.WriteAllText(sourceFilePath, @"int main() { return FOO; }"); var adapter = new ClangAdapter(sourceFilePath, new List<string>(), new List<string>() { "FOO=2" }); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(0, diags.Count); }
public void GetSkippedBlocks_IfSingleElifDirectiveWithElifDirectiveFalse_SkippedBlockIncludesElifBlock() { File.WriteAllText(sourceFilePath, @"#define X 1 #define Y 0 #define Z 0 #if X #define foo x*y #elif Z + 0 #define foo x+y #elif Y #define foo x/y #elif Z #define foo x-y #endif "); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var preprocessor = adapter.GetPreprocessor(); { var skippedBlocks = preprocessor.GetSkippedBlockLineNumbers(); var skippedBlock = skippedBlocks.First(); Assert.AreEqual(7, skippedBlock.Item1); Assert.AreEqual(7, skippedBlock.Item2); skippedBlock = skippedBlocks.ElementAt(1); Assert.AreEqual(9, skippedBlock.Item1); Assert.AreEqual(9, skippedBlock.Item2); skippedBlock = skippedBlocks.ElementAt(2); Assert.AreEqual(11, skippedBlock.Item1); Assert.AreEqual(11, skippedBlock.Item2); } }
public void GetDiagnostics_ShortCastToIntPointerForARM_OneDiagnosticsReported() { File.WriteAllText(sourceFilePath, @"volatile short x; int main() { return *(int *)x; }"); var adapter = new ClangAdapter(sourceFilePath, new List<string>(), new List<string>(), Language.C, Arch.ARM); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(1, diags.Count()); }
public void GetSkippedBlocks_TwoIfBlocksBothFalse_SkippedBlockIncludesBothBlocks() { File.WriteAllText(sourceFilePath, @"#if 0 #define foo x+y #endif #if 0 #define foo x-y #endif "); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); var preprocessor = adapter.GetPreprocessor(); { var skippedBlocks = preprocessor.GetSkippedBlockLineNumbers(); var skippedBlock = skippedBlocks.First(); Assert.AreEqual(2, skippedBlock.Item1); Assert.AreEqual(2, skippedBlock.Item2); skippedBlock = skippedBlocks.ElementAt(1); Assert.AreEqual(5, skippedBlock.Item1); Assert.AreEqual(5, skippedBlock.Item2); } }
public void GetSkippedBlocks_IfSingleElifDirectiveWithIfDirectiveFalse_SkippedBlockIncludesIfBlock() { File.WriteAllText(sourceFilePath, @"#define X 0 #define Y 1 #if X #define foo x*y #elif Y #define foo x/y #endif "); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); AssertSkippedBlocksMatch(adapter, new[] { Tuple.Create(4, 4)}); }
public void GetDiagnostics_LongLongCastToUInt32ForARM_OneDiagnosticsReported() { File.WriteAllText(sourceFilePath, @"int main() { typedef unsigned int uint32_t __attribute__((__mode__(SI))); uint32_t v = 0xABCDEFABCD; return 1; }"); var adapter = new ClangAdapter(sourceFilePath, new List<string>(), new List<string>(), Language.C, Arch.ARM); adapter.Process(null); var diags = adapter.GetDiagnostics(); Assert.AreEqual(1, diags.Count()); }
public void GetSkippedBlocks_NestedIfDefDirectiveWithOuterBlockSkipped_SkippedBlockIncludesEntireOuterBlock() { File.WriteAllText(sourceFilePath, @"#if 0 #if 0 #define foo x*y #elif 0 #define foo x/y #else #define blah x-y #endif #define blah #endif "); var adapter = new ClangAdapter(sourceFilePath); adapter.Process(null); AssertSkippedBlocksMatch(adapter, new[] { Tuple.Create(2, 9)}); }