aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/ProtocolBuffers.Test/TextFormatTest.cs
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/src/ProtocolBuffers.Test/TextFormatTest.cs')
-rw-r--r--csharp/src/ProtocolBuffers.Test/TextFormatTest.cs180
1 files changed, 90 insertions, 90 deletions
diff --git a/csharp/src/ProtocolBuffers.Test/TextFormatTest.cs b/csharp/src/ProtocolBuffers.Test/TextFormatTest.cs
index 1e083c6b..5af71787 100644
--- a/csharp/src/ProtocolBuffers.Test/TextFormatTest.cs
+++ b/csharp/src/ProtocolBuffers.Test/TextFormatTest.cs
@@ -37,7 +37,7 @@
using System;
using System.IO;
using Google.ProtocolBuffers.TestProtos;
-using Xunit;
+using NUnit.Framework;
namespace Google.ProtocolBuffers
{
@@ -84,13 +84,13 @@ namespace Google.ProtocolBuffers
/// <summary>
/// Print TestAllTypes and compare with golden file.
/// </summary>
- [Fact]
+ [Test]
public void PrintMessage()
{
TestUtil.TestInMultipleCultures(() =>
{
string text = TextFormat.PrintToString(TestUtil.GetAllSet());
- Assert.Equal(AllFieldsSetText.Replace("\r\n", "\n").Trim(),
+ Assert.AreEqual(AllFieldsSetText.Replace("\r\n", "\n").Trim(),
text.Replace("\r\n", "\n").Trim());
});
}
@@ -98,32 +98,32 @@ namespace Google.ProtocolBuffers
/// <summary>
/// Tests that a builder prints the same way as a message.
/// </summary>
- [Fact]
+ [Test]
public void PrintBuilder()
{
TestUtil.TestInMultipleCultures(() =>
{
string messageText = TextFormat.PrintToString(TestUtil.GetAllSet());
string builderText = TextFormat.PrintToString(TestUtil.GetAllSet().ToBuilder());
- Assert.Equal(messageText, builderText);
+ Assert.AreEqual(messageText, builderText);
});
}
/// <summary>
/// Print TestAllExtensions and compare with golden file.
/// </summary>
- [Fact]
+ [Test]
public void PrintExtensions()
{
string text = TextFormat.PrintToString(TestUtil.GetAllExtensionsSet());
- Assert.Equal(AllExtensionsSetText.Replace("\r\n", "\n").Trim(), text.Replace("\r\n", "\n").Trim());
+ Assert.AreEqual(AllExtensionsSetText.Replace("\r\n", "\n").Trim(), text.Replace("\r\n", "\n").Trim());
}
/// <summary>
/// Test printing of unknown fields in a message.
/// </summary>
- [Fact]
+ [Test]
public void PrintUnknownFields()
{
TestEmptyMessage message =
@@ -159,7 +159,7 @@ namespace Google.ProtocolBuffers
.Build())
.Build();
- Assert.Equal(
+ Assert.AreEqual(
"5: 1\n" +
"5: 0x00000002\n" +
"5: 0x0000000000000003\n" +
@@ -189,7 +189,7 @@ namespace Google.ProtocolBuffers
return ByteString.CopyFrom(bytes);
}
- [Fact]
+ [Test]
public void PrintExotic()
{
IMessage message = TestAllTypes.CreateBuilder()
@@ -220,10 +220,10 @@ namespace Google.ProtocolBuffers
.AddRepeatedBytes(Bytes("\0\u0001\u0007\b\f\n\r\t\v\\\'\"\u00fe"))
.Build();
- Assert.Equal(ExoticText, message.ToString());
+ Assert.AreEqual(ExoticText, message.ToString());
}
- [Fact]
+ [Test]
public void PrintMessageSet()
{
TestMessageSet messageSet =
@@ -236,12 +236,12 @@ namespace Google.ProtocolBuffers
TestMessageSetExtension2.CreateBuilder().SetStr("foo").Build())
.Build();
- Assert.Equal(MessageSetText, messageSet.ToString());
+ Assert.AreEqual(MessageSetText, messageSet.ToString());
}
// =================================================================
- [Fact]
+ [Test]
public void Parse()
{
TestUtil.TestInMultipleCultures(() =>
@@ -252,7 +252,7 @@ namespace Google.ProtocolBuffers
});
}
- [Fact]
+ [Test]
public void ParseReader()
{
TestAllTypes.Builder builder = TestAllTypes.CreateBuilder();
@@ -260,7 +260,7 @@ namespace Google.ProtocolBuffers
TestUtil.AssertAllFieldsSet(builder.Build());
}
- [Fact]
+ [Test]
public void ParseExtensions()
{
TestAllExtensions.Builder builder = TestAllExtensions.CreateBuilder();
@@ -270,7 +270,7 @@ namespace Google.ProtocolBuffers
TestUtil.AssertAllExtensionsSet(builder.Build());
}
- [Fact]
+ [Test]
public void ParseCompatibility()
{
string original = "repeated_float: inf\n" +
@@ -299,10 +299,10 @@ namespace Google.ProtocolBuffers
"repeated_double: NaN\n";
TestAllTypes.Builder builder = TestAllTypes.CreateBuilder();
TextFormat.Merge(original, builder);
- Assert.Equal(canonical, builder.Build().ToString());
+ Assert.AreEqual(canonical, builder.Build().ToString());
}
- [Fact]
+ [Test]
public void ParseExotic()
{
TestAllTypes.Builder builder = TestAllTypes.CreateBuilder();
@@ -310,10 +310,10 @@ namespace Google.ProtocolBuffers
// Too lazy to check things individually. Don't try to debug this
// if testPrintExotic() is Assert.Failing.
- Assert.Equal(ExoticText, builder.Build().ToString());
+ Assert.AreEqual(ExoticText, builder.Build().ToString());
}
- [Fact]
+ [Test]
public void ParseMessageSet()
{
ExtensionRegistry extensionRegistry = ExtensionRegistry.CreateInstance();
@@ -324,30 +324,30 @@ namespace Google.ProtocolBuffers
TextFormat.Merge(MessageSetText, extensionRegistry, builder);
TestMessageSet messageSet = builder.Build();
- Assert.True(messageSet.HasExtension(TestMessageSetExtension1.MessageSetExtension));
- Assert.Equal(123, messageSet.GetExtension(TestMessageSetExtension1.MessageSetExtension).I);
- Assert.True(messageSet.HasExtension(TestMessageSetExtension2.MessageSetExtension));
- Assert.Equal("foo", messageSet.GetExtension(TestMessageSetExtension2.MessageSetExtension).Str);
+ Assert.IsTrue(messageSet.HasExtension(TestMessageSetExtension1.MessageSetExtension));
+ Assert.AreEqual(123, messageSet.GetExtension(TestMessageSetExtension1.MessageSetExtension).I);
+ Assert.IsTrue(messageSet.HasExtension(TestMessageSetExtension2.MessageSetExtension));
+ Assert.AreEqual("foo", messageSet.GetExtension(TestMessageSetExtension2.MessageSetExtension).Str);
}
- [Fact]
+ [Test]
public void ParseNumericEnum()
{
TestAllTypes.Builder builder = TestAllTypes.CreateBuilder();
TextFormat.Merge("optional_nested_enum: 2", builder);
- Assert.Equal(TestAllTypes.Types.NestedEnum.BAR, builder.OptionalNestedEnum);
+ Assert.AreEqual(TestAllTypes.Types.NestedEnum.BAR, builder.OptionalNestedEnum);
}
- [Fact]
+ [Test]
public void ParseAngleBrackets()
{
TestAllTypes.Builder builder = TestAllTypes.CreateBuilder();
TextFormat.Merge("OptionalGroup: < a: 1 >", builder);
- Assert.True(builder.HasOptionalGroup);
- Assert.Equal(1, builder.OptionalGroup.A);
+ Assert.IsTrue(builder.HasOptionalGroup);
+ Assert.AreEqual(1, builder.OptionalGroup.A);
}
- [Fact]
+ [Test]
public void ParseComment()
{
TestAllTypes.Builder builder = TestAllTypes.CreateBuilder();
@@ -356,8 +356,8 @@ namespace Google.ProtocolBuffers
"optional_int32: 1 # another comment\n" +
"optional_int64: 2\n" +
"# EOF comment", builder);
- Assert.Equal(1, builder.OptionalInt32);
- Assert.Equal(2, builder.OptionalInt64);
+ Assert.AreEqual(1, builder.OptionalInt32);
+ Assert.AreEqual(2, builder.OptionalInt64);
}
@@ -365,10 +365,10 @@ namespace Google.ProtocolBuffers
{
TestAllTypes.Builder builder = TestAllTypes.CreateBuilder();
Exception exception = Assert.Throws<FormatException>(() => TextFormat.Merge(text, TestUtil.CreateExtensionRegistry(), builder));
- Assert.Equal(error, exception.Message);
+ Assert.AreEqual(error, exception.Message);
}
- [Fact]
+ [Test]
public void ParseErrors()
{
AssertParseError(
@@ -443,26 +443,26 @@ namespace Google.ProtocolBuffers
return ByteString.CopyFrom(bytes);
}
- [Fact]
+ [Test]
public void Escape()
{
// Escape sequences.
- Assert.Equal("\\000\\001\\a\\b\\f\\n\\r\\t\\v\\\\\\'\\\"",
+ Assert.AreEqual("\\000\\001\\a\\b\\f\\n\\r\\t\\v\\\\\\'\\\"",
TextFormat.EscapeBytes(Bytes("\0\u0001\u0007\b\f\n\r\t\v\\\'\"")));
- Assert.Equal("\\000\\001\\a\\b\\f\\n\\r\\t\\v\\\\\\'\\\"",
+ Assert.AreEqual("\\000\\001\\a\\b\\f\\n\\r\\t\\v\\\\\\'\\\"",
TextFormat.EscapeText("\0\u0001\u0007\b\f\n\r\t\v\\\'\""));
- Assert.Equal(Bytes("\0\u0001\u0007\b\f\n\r\t\v\\\'\""),
+ Assert.AreEqual(Bytes("\0\u0001\u0007\b\f\n\r\t\v\\\'\""),
TextFormat.UnescapeBytes("\\000\\001\\a\\b\\f\\n\\r\\t\\v\\\\\\'\\\""));
- Assert.Equal("\0\u0001\u0007\b\f\n\r\t\v\\\'\"",
+ Assert.AreEqual("\0\u0001\u0007\b\f\n\r\t\v\\\'\"",
TextFormat.UnescapeText("\\000\\001\\a\\b\\f\\n\\r\\t\\v\\\\\\'\\\""));
// Unicode handling.
- Assert.Equal("\\341\\210\\264", TextFormat.EscapeText("\u1234"));
- Assert.Equal("\\341\\210\\264", TextFormat.EscapeBytes(Bytes(0xe1, 0x88, 0xb4)));
- Assert.Equal("\u1234", TextFormat.UnescapeText("\\341\\210\\264"));
- Assert.Equal(Bytes(0xe1, 0x88, 0xb4), TextFormat.UnescapeBytes("\\341\\210\\264"));
- Assert.Equal("\u1234", TextFormat.UnescapeText("\\xe1\\x88\\xb4"));
- Assert.Equal(Bytes(0xe1, 0x88, 0xb4), TextFormat.UnescapeBytes("\\xe1\\x88\\xb4"));
+ Assert.AreEqual("\\341\\210\\264", TextFormat.EscapeText("\u1234"));
+ Assert.AreEqual("\\341\\210\\264", TextFormat.EscapeBytes(Bytes(0xe1, 0x88, 0xb4)));
+ Assert.AreEqual("\u1234", TextFormat.UnescapeText("\\341\\210\\264"));
+ Assert.AreEqual(Bytes(0xe1, 0x88, 0xb4), TextFormat.UnescapeBytes("\\341\\210\\264"));
+ Assert.AreEqual("\u1234", TextFormat.UnescapeText("\\xe1\\x88\\xb4"));
+ Assert.AreEqual(Bytes(0xe1, 0x88, 0xb4), TextFormat.UnescapeBytes("\\xe1\\x88\\xb4"));
// Errors.
Assert.Throws<FormatException>(() => TextFormat.UnescapeText("\\x"));
@@ -470,55 +470,55 @@ namespace Google.ProtocolBuffers
Assert.Throws<FormatException>(() => TextFormat.UnescapeText("\\"));
}
- [Fact]
+ [Test]
public void ParseInteger()
{
- Assert.Equal(0, TextFormat.ParseInt32("0"));
- Assert.Equal(1, TextFormat.ParseInt32("1"));
- Assert.Equal(-1, TextFormat.ParseInt32("-1"));
- Assert.Equal(12345, TextFormat.ParseInt32("12345"));
- Assert.Equal(-12345, TextFormat.ParseInt32("-12345"));
- Assert.Equal(2147483647, TextFormat.ParseInt32("2147483647"));
- Assert.Equal(-2147483648, TextFormat.ParseInt32("-2147483648"));
-
- Assert.Equal(0u, TextFormat.ParseUInt32("0"));
- Assert.Equal(1u, TextFormat.ParseUInt32("1"));
- Assert.Equal(12345u, TextFormat.ParseUInt32("12345"));
- Assert.Equal(2147483647u, TextFormat.ParseUInt32("2147483647"));
- Assert.Equal(2147483648U, TextFormat.ParseUInt32("2147483648"));
- Assert.Equal(4294967295U, TextFormat.ParseUInt32("4294967295"));
-
- Assert.Equal(0L, TextFormat.ParseInt64("0"));
- Assert.Equal(1L, TextFormat.ParseInt64("1"));
- Assert.Equal(-1L, TextFormat.ParseInt64("-1"));
- Assert.Equal(12345L, TextFormat.ParseInt64("12345"));
- Assert.Equal(-12345L, TextFormat.ParseInt64("-12345"));
- Assert.Equal(2147483647L, TextFormat.ParseInt64("2147483647"));
- Assert.Equal(-2147483648L, TextFormat.ParseInt64("-2147483648"));
- Assert.Equal(4294967295L, TextFormat.ParseInt64("4294967295"));
- Assert.Equal(4294967296L, TextFormat.ParseInt64("4294967296"));
- Assert.Equal(9223372036854775807L, TextFormat.ParseInt64("9223372036854775807"));
- Assert.Equal(-9223372036854775808L, TextFormat.ParseInt64("-9223372036854775808"));
-
- Assert.Equal(0uL, TextFormat.ParseUInt64("0"));
- Assert.Equal(1uL, TextFormat.ParseUInt64("1"));
- Assert.Equal(12345uL, TextFormat.ParseUInt64("12345"));
- Assert.Equal(2147483647uL, TextFormat.ParseUInt64("2147483647"));
- Assert.Equal(4294967295uL, TextFormat.ParseUInt64("4294967295"));
- Assert.Equal(4294967296uL, TextFormat.ParseUInt64("4294967296"));
- Assert.Equal(9223372036854775807UL, TextFormat.ParseUInt64("9223372036854775807"));
- Assert.Equal(9223372036854775808UL, TextFormat.ParseUInt64("9223372036854775808"));
- Assert.Equal(18446744073709551615UL, TextFormat.ParseUInt64("18446744073709551615"));
+ Assert.AreEqual(0, TextFormat.ParseInt32("0"));
+ Assert.AreEqual(1, TextFormat.ParseInt32("1"));
+ Assert.AreEqual(-1, TextFormat.ParseInt32("-1"));
+ Assert.AreEqual(12345, TextFormat.ParseInt32("12345"));
+ Assert.AreEqual(-12345, TextFormat.ParseInt32("-12345"));
+ Assert.AreEqual(2147483647, TextFormat.ParseInt32("2147483647"));
+ Assert.AreEqual(-2147483648, TextFormat.ParseInt32("-2147483648"));
+
+ Assert.AreEqual(0u, TextFormat.ParseUInt32("0"));
+ Assert.AreEqual(1u, TextFormat.ParseUInt32("1"));
+ Assert.AreEqual(12345u, TextFormat.ParseUInt32("12345"));
+ Assert.AreEqual(2147483647u, TextFormat.ParseUInt32("2147483647"));
+ Assert.AreEqual(2147483648U, TextFormat.ParseUInt32("2147483648"));
+ Assert.AreEqual(4294967295U, TextFormat.ParseUInt32("4294967295"));
+
+ Assert.AreEqual(0L, TextFormat.ParseInt64("0"));
+ Assert.AreEqual(1L, TextFormat.ParseInt64("1"));
+ Assert.AreEqual(-1L, TextFormat.ParseInt64("-1"));
+ Assert.AreEqual(12345L, TextFormat.ParseInt64("12345"));
+ Assert.AreEqual(-12345L, TextFormat.ParseInt64("-12345"));
+ Assert.AreEqual(2147483647L, TextFormat.ParseInt64("2147483647"));
+ Assert.AreEqual(-2147483648L, TextFormat.ParseInt64("-2147483648"));
+ Assert.AreEqual(4294967295L, TextFormat.ParseInt64("4294967295"));
+ Assert.AreEqual(4294967296L, TextFormat.ParseInt64("4294967296"));
+ Assert.AreEqual(9223372036854775807L, TextFormat.ParseInt64("9223372036854775807"));
+ Assert.AreEqual(-9223372036854775808L, TextFormat.ParseInt64("-9223372036854775808"));
+
+ Assert.AreEqual(0uL, TextFormat.ParseUInt64("0"));
+ Assert.AreEqual(1uL, TextFormat.ParseUInt64("1"));
+ Assert.AreEqual(12345uL, TextFormat.ParseUInt64("12345"));
+ Assert.AreEqual(2147483647uL, TextFormat.ParseUInt64("2147483647"));
+ Assert.AreEqual(4294967295uL, TextFormat.ParseUInt64("4294967295"));
+ Assert.AreEqual(4294967296uL, TextFormat.ParseUInt64("4294967296"));
+ Assert.AreEqual(9223372036854775807UL, TextFormat.ParseUInt64("9223372036854775807"));
+ Assert.AreEqual(9223372036854775808UL, TextFormat.ParseUInt64("9223372036854775808"));
+ Assert.AreEqual(18446744073709551615UL, TextFormat.ParseUInt64("18446744073709551615"));
// Hex
- Assert.Equal(0x1234abcd, TextFormat.ParseInt32("0x1234abcd"));
- Assert.Equal(-0x1234abcd, TextFormat.ParseInt32("-0x1234abcd"));
- Assert.Equal(0xffffffffffffffffUL, TextFormat.ParseUInt64("0xffffffffffffffff"));
- Assert.Equal(0x7fffffffffffffffL,
+ Assert.AreEqual(0x1234abcd, TextFormat.ParseInt32("0x1234abcd"));
+ Assert.AreEqual(-0x1234abcd, TextFormat.ParseInt32("-0x1234abcd"));
+ Assert.AreEqual(0xffffffffffffffffUL, TextFormat.ParseUInt64("0xffffffffffffffff"));
+ Assert.AreEqual(0x7fffffffffffffffL,
TextFormat.ParseInt64("0x7fffffffffffffff"));
// Octal
- Assert.Equal(342391, TextFormat.ParseInt32("01234567"));
+ Assert.AreEqual(342391, TextFormat.ParseInt32("01234567"));
// Out-of-range
Assert.Throws<FormatException>(() => TextFormat.ParseInt32("2147483648"));
@@ -532,7 +532,7 @@ namespace Google.ProtocolBuffers
Assert.Throws<FormatException>(() => TextFormat.ParseInt32("abcd"));
}
- [Fact]
+ [Test]
public void ParseLongString()
{
string longText =
@@ -554,7 +554,7 @@ namespace Google.ProtocolBuffers
"123456789012345678901234567890123456789012345678901234567890";
TestAllTypes.Builder builder = TestAllTypes.CreateBuilder();
TextFormat.Merge("optional_string: \"" + longText + "\"", builder);
- Assert.Equal(longText, builder.OptionalString);
+ Assert.AreEqual(longText, builder.OptionalString);
}
}
} \ No newline at end of file