private static ImmutableArray <CppCheckLocation> ParseLocationsSubtree(XmlReader reader, CppCheckStrings strings) { ImmutableArray <CppCheckLocation> .Builder locationBuilder = ImmutableArray.CreateBuilder <CppCheckLocation>(); if (!reader.IsEmptyElement) { int startingDepth = reader.Depth; reader.Read(); while (reader.Depth > startingDepth) { Debug.Assert(reader.Depth == startingDepth + 1); if (reader.NodeType == XmlNodeType.Whitespace) { reader.Read(); } else { locationBuilder.Add(CppCheckLocation.Parse(reader, strings)); } } } ImmutableArray <CppCheckLocation> locations = locationBuilder.ToImmutable(); return(locations); }
public void CppCheckLocation_CanBeDebugPrinted() { string result = new CppCheckLocation("cute_fluffy_kittens.c", 1234).ToString(); result.Should().Contain("cute_fluffy_kittens.c"); result.Should().Contain("1234"); }
private static ImmutableArray <CppCheckLocation> ParseLocationsSubtree(XmlReader reader, CppCheckStrings strings) { ImmutableArray <CppCheckLocation> .Builder locationBuilder = ImmutableArray.CreateBuilder <CppCheckLocation>(); if (!reader.IsEmptyElement) { int startingDepth = reader.Depth; reader.Read(); while (reader.Depth > startingDepth) { if (reader.NodeType == XmlNodeType.Whitespace) { reader.Read(); } else { if (!reader.LocalName.Equals("location", StringComparison.OrdinalIgnoreCase)) { reader.Read(); continue; } locationBuilder.Add(CppCheckLocation.Parse(reader, strings)); } } } return(locationBuilder.ToImmutable()); }
public void CppCheckLocation_CanBeConstructedFromFileAndLine() { var uut = new CppCheckLocation("1234", 42); Assert.AreEqual("1234", uut.File); Assert.AreEqual(42, uut.Line); }
public void CppCheckLocation_CanBeConvertedToSarifIssue() { PhysicalLocation result = new CppCheckLocation("foo.cpp", 42).ToSarifPhysicalLocation(); Assert.AreEqual(new PhysicalLocation { Uri = new Uri("foo.cpp", UriKind.RelativeOrAbsolute), Region = new Region { StartLine = 42 } }, result); }
public void CppCheckLocation_CanBeConvertedToSarifIssue() { List <PhysicalLocationComponent> result = new CppCheckLocation("foo.cpp", 42).ToSarifPhysicalLocation(); Assert.AreEqual(new PhysicalLocationComponent { Uri = new Uri("foo.cpp", UriKind.RelativeOrAbsolute), MimeType = "text/x-cpp", Region = new Region { StartLine = 42 } }, result[0]); }
public void CppCheckLocation_CanBeConvertedToSarifIssue() { PhysicalLocation result = new CppCheckLocation(ExampleFileName, 42).ToSarifPhysicalLocation(); Assert.True( result.ValueEquals( new PhysicalLocation { ArtifactLocation = new ArtifactLocation { Uri = new Uri(ExampleFileName, UriKind.RelativeOrAbsolute) }, Region = new Region { StartLine = 42 } })); }
public void CppCheckLocation_CanBeConvertedToSarifIssue() { PhysicalLocation result = new CppCheckLocation("foo.cpp", 42).ToSarifPhysicalLocation(); Assert.True( result.ValueEquals( new PhysicalLocation { FileLocation = new FileLocation { Uri = new Uri("foo.cpp", UriKind.RelativeOrAbsolute) }, Region = new Region { StartLine = 42 } })); }
public void CppCheckLocation_SatisfiesEqualityInvariants() { var a = new CppCheckLocation("a.cpp", 1); var b = new CppCheckLocation("a.cpp", 2); var c = new CppCheckLocation("b.cpp", 1); Assert.AreNotEqual(a, b); Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode()); Assert.AreNotEqual(a, c); Assert.AreNotEqual(a.GetHashCode(), c.GetHashCode()); Assert.AreNotEqual(b, c); Assert.AreNotEqual(b.GetHashCode(), c.GetHashCode()); var anotherA = new CppCheckLocation("a.cpp", 1); Assert.AreEqual(a, anotherA); Assert.AreEqual(a.GetHashCode(), anotherA.GetHashCode()); Assert.IsTrue(a == anotherA); Assert.IsFalse(a != anotherA); Assert.IsFalse(a.Equals(null)); Assert.IsFalse(a.Equals("a string value")); }
private static CppCheckLocation Parse(XmlReader xml) { return(CppCheckLocation.Parse(xml, new CppCheckStrings(xml.NameTable))); }
private static CppCheckLocation AssertLocationIsTestLocation(CppCheckLocation result) { Assert.AreEqual("foo.cpp", result.File); Assert.AreEqual(1234, result.Line); return(result); }
private static CppCheckLocation AssertLocationIsTestLocation(CppCheckLocation result) { Assert.Equal(ExampleFileName, result.File); Assert.Equal(1234, result.Line); return(result); }