public void TestWhenFormatSpecifierIsEmpty() { bool validFormat = RemoteValueFormatProvider.IsValidFormat(""); IRemoteValueFormat format = RemoteValueFormatProvider.Get(""); Assert.That(validFormat, Is.False); Assert.That(format, Is.Not.Null); }
void CheckPointerFormat(string formatSpecifier, int valueInt, string expectedValue) { var remoteValue = RemoteValueFakeUtil.CreatePointer("int*", "int", valueInt.ToString()); IRemoteValueFormat format = RemoteValueFormatProvider.Get(formatSpecifier); Assert.AreEqual(format.FormatValueAsAddress(remoteValue), expectedValue); Assert.IsTrue(format.ShouldInheritFormatSpecifier()); }
public void TestFallBackOnDefaultFormatWithRawSpecifier() { bool validFormat = RemoteValueFormatProvider.IsValidFormat("!unsupportedSpecifier"); IRemoteValueFormat format = RemoteValueFormatProvider.Get("!unsupportedSpecifier"); Assert.That(validFormat, Is.False); Assert.That(format, Is.Not.Null); }
void CheckFormat(string formatSpecifier, ValueFormat expectedFormat, int valueInt, string expectedValue) { var remoteValue = RemoteValueFakeUtil.CreateSimpleInt("test", valueInt); IRemoteValueFormat format = RemoteValueFormatProvider.Get(formatSpecifier); Assert.AreEqual(format.FormatValue(remoteValue, ValueFormat.Default), expectedValue); Assert.AreEqual(remoteValue.GetFormat(), expectedFormat); Assert.IsTrue(format.ShouldInheritFormatSpecifier()); }
public void TestGetWithRawFormatSpecifier( [Values(FormatSpecifierUtil.RawFormatSpecifier + SPECIFIER_1, FormatSpecifierUtil.InheritableRawFormatSpecifier + SPECIFIER_2)] string specifier) { bool validFormat = RemoteValueFormatProvider.IsValidFormat(specifier); IRemoteValueFormat format = RemoteValueFormatProvider.Get(specifier); Assert.That(validFormat, Is.True); }
public void TestGetStandaloneRawFormatSpecifiers( [Values(FormatSpecifierUtil.RawFormatSpecifier, FormatSpecifierUtil.InheritableRawFormatSpecifier)] string specifier) { bool validFormat = RemoteValueFormatProvider.IsValidFormat(specifier); ISingleValueFormat format = RemoteValueFormatProvider.Get(specifier); Assert.That(validFormat, Is.True); Assert.That(format is RemoteValueFormat); }
public void SupportsAllStringTypes() { Assert.NotNull(RemoteValueFormatProvider.Get("s")); Assert.NotNull(RemoteValueFormatProvider.Get("sb")); Assert.NotNull(RemoteValueFormatProvider.Get("s8")); Assert.NotNull(RemoteValueFormatProvider.Get("s8b")); Assert.NotNull(RemoteValueFormatProvider.Get("su")); Assert.NotNull(RemoteValueFormatProvider.Get("sub")); Assert.NotNull(RemoteValueFormatProvider.Get("s32")); Assert.NotNull(RemoteValueFormatProvider.Get("s32b")); }
public void ShouldInheritFormatSpecifier() { string[] formats = { "B", "b", "y", "Y", "c", "C", "F", "s", "d", "i", "E", "en", "x", "h", "X", "H", "f", "o", "O", "U", "U32", "u", "p", "I", "a" }; foreach (string formatSpecifier in formats) { IRemoteValueFormat format = RemoteValueFormatProvider.Get(formatSpecifier); Assert.That(format, Is.Not.Null); Assert.That(format.ShouldInheritFormatSpecifier(), Is.True); } }
public void SizeIsNotProvidedForValidExpression() { LogSpy traceLogSpy = new LogSpy(); traceLogSpy.Attach(); Assert.That(RemoteValueFormatProvider.TryParseSizeFormat("[anyExpression]", null), Is.Null); Assert.That(traceLogSpy.GetOutput(), Does.Contain("ERROR: Evaluated size specifier isn't provided")); }
public void ConstantSpecifierWithSizeProvided() { LogSpy traceLogSpy = new LogSpy(); traceLogSpy.Attach(); Assert.That(RemoteValueFormatProvider.TryParseSizeFormat("8", 5), Is.EqualTo(8)); string log = traceLogSpy.GetOutput(); Assert.That(log, Does.Contain("WARNING:")); Assert.That(log, Does.Contain("evaluated size will be ignored")); }
public async Task InheritableFormatSpecifiersAreInheritedAsync() { IRemoteValueFormat lldbFormat = RemoteValueFormatProvider.Get("x"); Assert.That(lldbFormat, Is.Not.Null); Assert.That(lldbFormat.ShouldInheritFormatSpecifier(), Is.True); var childAdapter = new RemoteValueChildAdapter.Factory().Create( remoteValue, lldbFormat, varInfoBuilder, formatSpecifier: "x"); CollectionAssert.AreEqual(new[] { "x", "x", "x", "x" }, await GetAllChildFormatSpecifiersAsync(childAdapter)); }
public void EncodesUTF16Strings() { var remoteValue = RemoteValueFor(_value, Encoding.Unicode, charSize: 2); IRemoteValueFormat format; format = RemoteValueFormatProvider.Get("su"); Assert.AreEqual(_quotedEscapedValueUTF16, format.FormatValue(remoteValue, _fallback)); Assert.AreEqual(_stringView, format.FormatStringView(remoteValue, _fallback)); format = RemoteValueFormatProvider.Get("sub"); Assert.AreEqual(_escapedValue, format.FormatValue(remoteValue, _fallback)); Assert.AreEqual(_stringView, format.FormatStringView(remoteValue, _fallback)); }
public void UTF16StringWithSize() { var remoteValue = RemoteValueFor("text", Encoding.Unicode, charSize: 2); IRemoteValueFormat format; format = RemoteValueFormatProvider.Get("2su"); Assert.AreEqual("u\"te\"", format.FormatValue(remoteValue, _fallback)); Assert.AreEqual("te", format.FormatStringView(remoteValue, _fallback)); format = RemoteValueFormatProvider.Get("2sub"); Assert.AreEqual("te", format.FormatValue(remoteValue, _fallback)); Assert.AreEqual("te", format.FormatStringView(remoteValue, _fallback)); }
public void UTF32StringWithSize() { var remoteValue = RemoteValueFor("text", Encoding.UTF32, charSize: 4); IRemoteValueFormat format; format = RemoteValueFormatProvider.Get("2s32"); Assert.AreEqual("U\"te\"", format.FormatValue(remoteValue, _fallback)); Assert.AreEqual("te", format.FormatStringView(remoteValue, _fallback)); format = RemoteValueFormatProvider.Get("2s32b"); Assert.AreEqual("te", format.FormatValue(remoteValue, _fallback)); Assert.AreEqual("te", format.FormatStringView(remoteValue, _fallback)); }
public void EncodesCStringsStrings() { var remoteValue = RemoteValueFor(_value, Encoding.UTF8, charSize: 1); IRemoteValueFormat format; format = RemoteValueFormatProvider.Get("s"); Assert.AreEqual(_quotedEscapedValueAscii, format.FormatValue(remoteValue, _fallback)); Assert.AreEqual(_stringViewAscii, format.FormatStringView(remoteValue, _fallback)); format = RemoteValueFormatProvider.Get("sb"); Assert.AreEqual(_escapedValueAscii, format.FormatValue(remoteValue, _fallback)); Assert.AreEqual(_stringViewAscii, format.FormatStringView(remoteValue, _fallback)); }
public virtual IVariableInformation Create( RemoteValue remoteValue, string displayName = null, FormatSpecifier formatSpecifier = null, CustomVisualizer customVisualizer = CustomVisualizer .None) => new RemoteValueVariableInformation(_varInfoBuilder, formatSpecifier != null ? formatSpecifier.Expression : string.Empty, RemoteValueFormatProvider.Get( formatSpecifier?.Expression, formatSpecifier?.Size), ValueFormat.Default, remoteValue, displayName ?? remoteValue.GetName(), customVisualizer, _childAdapterFactory);
public void ShouldInheritFormatSpecifier() { Assert.That(RemoteValueFormatProvider.Get("s").ShouldInheritFormatSpecifier(), Is.True); Assert.That(RemoteValueFormatProvider.Get("sb").ShouldInheritFormatSpecifier(), Is.True); Assert.That(RemoteValueFormatProvider.Get("s8").ShouldInheritFormatSpecifier(), Is.True); Assert.That(RemoteValueFormatProvider.Get("s8b").ShouldInheritFormatSpecifier(), Is.True); Assert.That(RemoteValueFormatProvider.Get("su").ShouldInheritFormatSpecifier(), Is.True); Assert.That(RemoteValueFormatProvider.Get("sub").ShouldInheritFormatSpecifier(), Is.True); Assert.That(RemoteValueFormatProvider.Get("s32").ShouldInheritFormatSpecifier(), Is.True); Assert.That(RemoteValueFormatProvider.Get("s32b").ShouldInheritFormatSpecifier(), Is.True); }
public void ReturnsError() { const string errorStr = "error"; string error = null; var remoteValue = Substitute.For <RemoteValue>(); remoteValue.GetPointeeAsByteString(1, Arg.Any <uint>(), out error) .Returns(x => { x[2] = errorStr; return(null); }); IRemoteValueFormat format = RemoteValueFormatProvider.Get("s"); Assert.AreEqual(errorStr, format.FormatValue(remoteValue, _fallback)); Assert.IsNull(format.FormatStringView(remoteValue, _fallback)); }
public async Task GetNumChildrenReturnsValueFromFormatterAsync() { var remoteValue = Substitute.For <RemoteValue>(); remoteValue.GetTypeName().Returns("CustomType"); remoteValue.GetNumChildren().Returns(42u); var format = Substitute.For <IRemoteValueFormat>(); format.GetNumChildren(remoteValue).Returns(5u); var varInfo = new RemoteValueVariableInformation( varInfoBuilder, "5", RemoteValueFormatProvider.Get("5"), ValueFormat.Default, remoteValue, "displayName", CustomVisualizer.None, childAdapterFactory); Assert.That(await varInfo.GetChildAdapter().CountChildrenAsync(), Is.EqualTo(5u)); Assert.That(logSpy.GetOutput(), Does.Not.Contain("WARNING")); Assert.That(logSpy.GetOutput(), Does.Not.Contain("ERROR")); }
public void SizeSpecifierIsZero() { Assert.That(RemoteValueFormatProvider.TryParseSizeFormat("0", null), Is.Null); }
public void TestSizeExpressionIsValidFormat() { Assert.That(RemoteValueFormatProvider.IsValidFormat("[anyExpression]!sub")); }
public void TestRawIsValidFormat() { Assert.That(RemoteValueFormatProvider.IsValidFormat("!")); }
public void TestExpandIsValidFormat() { Assert.That(RemoteValueFormatProvider.IsValidFormat("expand(2)")); }
public void SizeSpecifierIsUnsignedHexadecimal() { Assert.That(RemoteValueFormatProvider.TryParseSizeFormat("0xffffffff", null), Is.EqualTo(4294967295)); }
public void WhenSizeSpecifierIsNotInteger() { Assert.That(RemoteValueFormatProvider.TryParseSizeFormat("mySpecifier", null), Is.Null); }
public void SizeSpecifierIsPositiveHexadecimal() { Assert.That(RemoteValueFormatProvider.TryParseSizeFormat("0x12", null), Is.EqualTo(18)); }
public void SizeSpecifierIsNotFormattedCorrectly( [Values("myExpression]", "[myExpression")] string expression) { Assert.That(RemoteValueFormatProvider.TryParseSizeFormat(expression, null), Is.Null); }
public void SizeIsProvidedAsArgument() { Assert.That(RemoteValueFormatProvider.TryParseSizeFormat("[anyExpression]", 5), Is.EqualTo(5)); }
public void TestViewIsValidFormat() { Assert.That(RemoteValueFormatProvider.IsValidFormat("view(simple)")); }
public void SizeSpecifierIsNegativeDecimal() { uint?size = RemoteValueFormatProvider.TryParseSizeFormat("-99", null); Assert.That(size, Is.Null); }