public void NullTermAsciiToStrings_WorksOnExpectedData(params string[] testStrings) { List <byte> testData = new List <byte>(); foreach (var str in testStrings) { testData.AddRange(System.Text.Encoding.ASCII.GetBytes(str.ToCharArray())); testData.Add(0); } string[] output = ELFUtility.NullTermAsciiToStrings(testData.ToArray()); output.Should().BeEquivalentTo(testStrings); }
public ELFBinary(Uri uri) : base(uri) { try { this.ELF = ELFReader.Load(Path.GetFullPath(uri.LocalPath)); this.Compilers = ELFUtility.GetELFCompilers(this.ELF); this.Valid = true; } // At some point, we may want to better enumerate expected vs. unexpected exceptions. // For now, though, we'll generically catch any of them--ELFSharp can throw a number of different exceptions // if given an invalid ELF file. catch (Exception e) { this.LoadException = e; this.Valid = false; } }
public void NullTermAsciiToStrings_ThrowsArgumentNullException() { Assert.Throws <ArgumentNullException>(() => ELFUtility.NullTermAsciiToStrings(null)); }
public void NullTermAsciiToStrings_ThrowsArgumentExceptionForInvalidData(byte[] data) { Assert.Throws <ArgumentException>(() => ELFUtility.NullTermAsciiToStrings(data)); }