Skip to content

Commit

Permalink
Formatted files.
Browse files Browse the repository at this point in the history
  • Loading branch information
MeltyPlayer committed Aug 12, 2024
1 parent 113d2f5 commit 3e949c0
Show file tree
Hide file tree
Showing 189 changed files with 1,362 additions and 914 deletions.
4 changes: 3 additions & 1 deletion Benchmarks/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Running;


namespace benchmarks {
public class Program {
public static void Main(string[] args) {
var summary = BenchmarkRunner.Run<ReadingValues>(
ManualConfig
.Create(DefaultConfig.Instance)
.AddDiagnoser(new MemoryDiagnoser(new MemoryDiagnoserConfig(true)))
.AddDiagnoser(
new MemoryDiagnoser(new MemoryDiagnoserConfig(true)))
.WithOptions(ConfigOptions.DisableOptimizationsValidator));
}
}
Expand Down
1 change: 1 addition & 0 deletions Benchmarks/ReadingValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using schema.binary;


namespace benchmarks {
[MemoryDiagnoser]
public class ReadingValues {
Expand Down
1 change: 1 addition & 0 deletions Benchmarks/StreamComparison.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using schema.util.streams;


namespace benchmarks {
public class StreamComparison {
public const int n = 10000;
Expand Down
1 change: 1 addition & 0 deletions Benchmarks/StringBuilderComparison.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using Cysharp.Text;


namespace benchmarks {
public class StringBuilderComparison {
public const int w = 100;
Expand Down
1 change: 1 addition & 0 deletions Benchmarks/StringComparison.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using BenchmarkDotNet.Attributes;


namespace benchmarks {
public class StringComparison {
public const int w = 100;
Expand Down
33 changes: 14 additions & 19 deletions Schema Build Tests/attributes/sequence/ClassSequenceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using schema.binary;
using schema.binary.attributes;


namespace build {
public partial class ClassSequenceTests {
[BinarySchema]
Expand Down Expand Up @@ -40,11 +41,10 @@ public override bool Equals(object other) {
[Test]
public void TestWriteAndReadArrayObject() {
var expectedSw = new ClassArraySequenceWrapper {
Values = new[]
{
new SchemaClass { Value = 1 },
new SchemaClass { Value = 2 },
new SchemaClass { Value = 3 }
Values = new[] {
new SchemaClass {Value = 1},
new SchemaClass {Value = 2},
new SchemaClass {Value = 3}
}
};

Expand All @@ -65,18 +65,17 @@ public void TestWriteAndReadArrayObject() {
[Test]
public void TestWriteAndReadArrayValues() {
var expectedSw = new ClassArraySequenceWrapper {
Values = new[]
{
new SchemaClass { Value = 1 },
new SchemaClass { Value = 2 },
new SchemaClass { Value = 3 }
}
Values = new[] {
new SchemaClass {Value = 1},
new SchemaClass {Value = 2},
new SchemaClass {Value = 3}
}
};

var ms = new MemoryStream();

var endianness = Endianness.BigEndian;

var ew = new SchemaBinaryWriter(endianness);
expectedSw.Write(ew);
ew.CompleteAndCopyTo(ms);
Expand All @@ -89,8 +88,7 @@ public void TestWriteAndReadArrayValues() {


[BinarySchema]
public partial class ClassListSequenceWrapper : IBinaryConvertible
{
public partial class ClassListSequenceWrapper : IBinaryConvertible {
[SequenceLengthSource(SchemaIntegerType.BYTE)]
public List<SchemaClass> Values { get; set; } = new();

Expand All @@ -106,11 +104,8 @@ public override bool Equals(object other) {
[Test]
public void TestWriteAndReadListObject() {
var expectedSw = new ClassListSequenceWrapper {
Values = new List<SchemaClass>
{
new() { Value = 1 },
new() { Value = 2 },
new() { Value = 3 }
Values = new List<SchemaClass> {
new() {Value = 1}, new() {Value = 2}, new() {Value = 3}
}
};

Expand Down
9 changes: 4 additions & 5 deletions Schema Build Tests/attributes/sequence/ISequenceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

using schema.binary;
using schema.binary.attributes;

using schema.util.enumerables;
using schema.util.sequences;

Expand All @@ -32,8 +31,8 @@ public override bool Equals(object? otherObj) {
public void TestWriteAndRead1() {
var expectedSw = new MutableSequenceWrapper1();
expectedSw.Sequence.AddRange(
new[] { 1, 2, 3, 4, 5, 9, 8, 7, 6 }
.Select(value => new IntWrapper { Value = value }));
new[] {1, 2, 3, 4, 5, 9, 8, 7, 6}
.Select(value => new IntWrapper {Value = value}));

var ms = new MemoryStream();

Expand Down Expand Up @@ -75,8 +74,8 @@ public override bool Equals(object? otherObj) {
public void TestWriteAndRead2() {
var expectedSw = new MutableSequenceWrapper2();
expectedSw.Sequence.AddRange(
new[] { 1, 2, 3, 4, 5, 9, 8, 7, 6 }
.Select(value => new IntWrapper { Value = value }));
new[] {1, 2, 3, 4, 5, 9, 8, 7, 6}
.Select(value => new IntWrapper {Value = value}));

var ms = new MemoryStream();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using schema.binary;
using schema.binary.attributes;


namespace build.attributes.sequence {
public partial class RSequenceLengthSourceAttributeTests {
[BinarySchema]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using schema.binary;
using schema.binary.attributes;


namespace build {
public partial class RSequenceUntilEndOfStreamAttributeTests {
[BinarySchema]
Expand All @@ -27,7 +28,7 @@ public override bool Equals(object other) {
[Test]
public void TestWriteAndReadBytes() {
var expectedSw = new ByteSequenceWrapper {
Values = new byte[] { 1, 2, 3, 4, 5, 9, 8, 7, 6 }
Values = new byte[] {1, 2, 3, 4, 5, 9, 8, 7, 6}
};

var ms = new MemoryStream();
Expand All @@ -46,9 +47,9 @@ public void TestWriteAndReadBytes() {

[Test]
public void TestWriteAndReadBytesInSubstream() {
var bytes = new byte[] { 0, 0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 0, };
var bytes = new byte[] {0, 0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 0,};
var expectedSw = new ByteSequenceWrapper {
Values = new byte[] { 1, 2, 3, 4, 5, 6 }
Values = new byte[] {1, 2, 3, 4, 5, 6}
};

var ms = new MemoryStream(bytes);
Expand All @@ -71,9 +72,9 @@ public void TestWriteAndReadBytesInSubstream() {

[Test]
public void TestWriteAndReadBytesInLocalSubstream() {
var bytes = new byte[] { 0, 0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 0, };
var bytes = new byte[] {0, 0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 0,};
var expectedSw = new ByteSequenceWrapper {
Values = new byte[] { 1, 2, 3, 4, 5, 6 }
Values = new byte[] {1, 2, 3, 4, 5, 6}
};

var ms = new MemoryStream(bytes);
Expand Down Expand Up @@ -117,7 +118,7 @@ public override bool Equals(object other) {
[Test]
public void TestWriteAndReadInts() {
var expectedSw = new IntSequenceWrapper {
Values = new[] { 1, 2, 3, 4, 5, 9, 8, 7, 6 }
Values = new[] {1, 2, 3, 4, 5, 9, 8, 7, 6}
};

var ms = new MemoryStream();
Expand Down Expand Up @@ -175,9 +176,9 @@ public override string ToString()
public void TestWriteAndReadClasses() {
var expectedSw = new FloatClassSequenceWrapper {
Values = new Vector3f[] {
new() { X = 1, Y = 2, Z = 3 },
new() { X = 2, Y = 3, Z = 4 },
new() { X = 3, Y = 4, Z = 5 },
new() {X = 1, Y = 2, Z = 3},
new() {X = 2, Y = 3, Z = 4},
new() {X = 3, Y = 4, Z = 5},
},
};

Expand Down Expand Up @@ -234,12 +235,12 @@ public override string ToString()

[Test]
public void TestWriteAndReadClassesInLocalSubstream() {
var bytes = new byte[] { 0, 0, 0, 1, 2, 3, 2, 3, 4, 3, 4, 5, 0, 0, 0, };
var bytes = new byte[] {0, 0, 0, 1, 2, 3, 2, 3, 4, 3, 4, 5, 0, 0, 0,};
var expectedSw = new ByteClassSequenceWrapper {
Values = new Vector3b[] {
new() { X = 1, Y = 2, Z = 3 },
new() { X = 2, Y = 3, Z = 4 },
new() { X = 3, Y = 4, Z = 5 },
new() {X = 1, Y = 2, Z = 3},
new() {X = 2, Y = 3, Z = 4},
new() {X = 3, Y = 4, Z = 5},
},
};

Expand Down
16 changes: 7 additions & 9 deletions Schema Build Tests/attributes/sequence/SequenceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using schema.binary;
using schema.binary.attributes;


namespace build {
public partial class SequenceTests {
[BinarySchema]
Expand All @@ -25,13 +26,13 @@ public override bool Equals(object other) {
[Test]
public void TestWriteAndRead() {
var expectedSw = new SequenceWrapper {
Values = new[] { 1, 2, 3, 4, 5, 9, 8, 7, 6 }
Values = new[] {1, 2, 3, 4, 5, 9, 8, 7, 6}
};

var ms = new MemoryStream();

var endianness = Endianness.BigEndian;

var ew = new SchemaBinaryWriter(endianness);
expectedSw.Write(ew);
ew.CompleteAndCopyTo(ms);
Expand All @@ -43,7 +44,6 @@ public void TestWriteAndRead() {
}



[BinarySchema]
public partial class Uint32LengthSequenceWrapper : IBinaryConvertible {
[SequenceLengthSource(SchemaIntegerType.UINT32)]
Expand All @@ -61,7 +61,7 @@ public override bool Equals(object other) {
[Test]
public void TestWriteAndReadWithUint32Length() {
var expectedSw = new Uint32LengthSequenceWrapper {
Values = new[] { 1, 2, 3, 4, 5, 9, 8, 7, 6 }
Values = new[] {1, 2, 3, 4, 5, 9, 8, 7, 6}
};

var ms = new MemoryStream();
Expand All @@ -79,7 +79,6 @@ public void TestWriteAndReadWithUint32Length() {
}



[BinarySchema]
public partial class Uint16LengthSequenceWrapper : IBinaryConvertible {
[WLengthOfSequence(nameof(Values))]
Expand All @@ -100,7 +99,7 @@ public override bool Equals(object other) {
[Test]
public void TestWriteAndReadWithUint16Length() {
var expectedSw = new Uint16LengthSequenceWrapper {
Values = new[] { 1, 2, 3, 4, 5, 9, 8, 7, 6 }
Values = new[] {1, 2, 3, 4, 5, 9, 8, 7, 6}
};

var ms = new MemoryStream();
Expand All @@ -118,12 +117,11 @@ public void TestWriteAndReadWithUint16Length() {
}



[BinarySchema]
public partial class Uint64LengthSequenceWrapper : IBinaryConvertible {
[WLengthOfSequence(nameof(Values))]
private ulong length;

[RSequenceLengthSource(nameof(length))]
public int[] Values { get; set; }

Expand All @@ -139,7 +137,7 @@ public override bool Equals(object other) {
[Test]
public void TestWriteAndReadWithUint64Length() {
var expectedSw = new Uint64LengthSequenceWrapper {
Values = new[] { 1, 2, 3, 4, 5, 9, 8, 7, 6 }
Values = new[] {1, 2, 3, 4, 5, 9, 8, 7, 6}
};

var ms = new MemoryStream();
Expand Down
15 changes: 8 additions & 7 deletions Schema Build Tests/attributes/sequence/StructSequenceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using schema.binary;
using schema.binary.attributes;


namespace build {
public partial class StructSequenceTests {
[BinarySchema]
Expand Down Expand Up @@ -41,9 +42,9 @@ public override bool Equals(object other) {
public void TestWriteAndReadArrayObject() {
var expectedSw = new StructArraySequenceWrapper {
Values = new[] {
new SchemaStruct { Value = 1 },
new SchemaStruct { Value = 2 },
new SchemaStruct { Value = 3 }
new SchemaStruct {Value = 1},
new SchemaStruct {Value = 2},
new SchemaStruct {Value = 3}
}
};

Expand All @@ -65,9 +66,9 @@ public void TestWriteAndReadArrayObject() {
public void TestWriteAndReadArrayValues() {
var expectedSw = new StructArraySequenceWrapper {
Values = new[] {
new SchemaStruct { Value = 1 },
new SchemaStruct { Value = 2 },
new SchemaStruct { Value = 3 }
new SchemaStruct {Value = 1},
new SchemaStruct {Value = 2},
new SchemaStruct {Value = 3}
}
};

Expand Down Expand Up @@ -104,7 +105,7 @@ public override bool Equals(object other) {
public void TestWriteAndReadListObject() {
var expectedSw = new StructListSequenceWrapper {
Values = new List<SchemaStruct> {
new() { Value = 1 }, new() { Value = 2 }, new() { Value = 3 }
new() {Value = 1}, new() {Value = 2}, new() {Value = 3}
}
};

Expand Down
8 changes: 4 additions & 4 deletions Schema Build Tests/attributes/string/EncodingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public partial class AsciiWrapper : IBinaryConvertible {
[TestCase("Hello world!")]
[TestCase("Multiple\nLines")]
public async Task TestAscii(string text) {
var asciiWrapper = new AsciiWrapper { Text = text };
var asciiWrapper = new AsciiWrapper {Text = text};
await BinarySchemaAssert.WritesAndReadsIdentically(asciiWrapper);
}

Expand All @@ -39,7 +39,7 @@ public partial class Utf8Wrapper : IBinaryConvertible {
[TestCase("Multiple\nLines")]
[TestCase("你好世界")]
public async Task TestUtf8(string text) {
var utf8Wrapper = new Utf8Wrapper { Text = text };
var utf8Wrapper = new Utf8Wrapper {Text = text};
await BinarySchemaAssert.WritesAndReadsIdentically(utf8Wrapper);
}

Expand All @@ -62,7 +62,7 @@ public partial class Utf16Wrapper : IBinaryConvertible {
[TestCase("你好世界", Endianness.LittleEndian)]
[TestCase("你好世界", Endianness.BigEndian)]
public async Task TestUtf16(string text, Endianness endianness) {
var utf16Wrapper = new Utf16Wrapper { Text = text };
var utf16Wrapper = new Utf16Wrapper {Text = text};
await BinarySchemaAssert.WritesAndReadsIdentically(
utf16Wrapper,
endianness);
Expand All @@ -82,7 +82,7 @@ public partial class Utf32Wrapper : IBinaryConvertible {
[TestCase("Multiple\nLines")]
[TestCase("你好世界")]
public async Task TestUtf32(string text) {
var utf32Wrapper = new Utf32Wrapper { Text = text };
var utf32Wrapper = new Utf32Wrapper {Text = text};
await BinarySchemaAssert.WritesAndReadsIdentically(utf32Wrapper);
}
}
Expand Down
Loading

0 comments on commit 3e949c0

Please sign in to comment.