From e26b83796fd8d311512dedf5dee1a15506acfd0c Mon Sep 17 00:00:00 2001 From: Ledjon Behluli Date: Sat, 22 Jul 2023 18:27:05 +0200 Subject: [PATCH 1/2] fixed problems with fields being null due to using default keyword, and added more tests --- src/OrleanSpaces/Helpers/TemplateHelpers.cs | 2 +- src/OrleanSpaces/Helpers/TupleHelpers.cs | 2 +- src/OrleanSpaces/Tuples/SpaceTuple.cs | 14 ++++++++------ src/OrleanSpaces/Tuples/Specialized/BoolTuple.cs | 10 ++++++---- src/OrleanSpaces/Tuples/Specialized/ByteTuple.cs | 10 ++++++---- src/OrleanSpaces/Tuples/Specialized/CharTuple.cs | 10 ++++++---- .../Tuples/Specialized/DateTimeOffsetTuple.cs | 10 ++++++---- .../Tuples/Specialized/DateTimeTuple.cs | 10 ++++++---- .../Tuples/Specialized/DecimalTuple.cs | 10 ++++++---- .../Tuples/Specialized/DoubleTuple.cs | 10 ++++++---- .../Tuples/Specialized/FloatTuple.cs | 10 ++++++---- src/OrleanSpaces/Tuples/Specialized/GuidTuple.cs | 10 ++++++---- src/OrleanSpaces/Tuples/Specialized/HugeTuple.cs | 10 ++++++---- src/OrleanSpaces/Tuples/Specialized/IntTuple.cs | 10 ++++++---- src/OrleanSpaces/Tuples/Specialized/LongTuple.cs | 10 ++++++---- .../Tuples/Specialized/SByteTuple.cs | 10 ++++++---- .../Tuples/Specialized/ShortTuple.cs | 10 ++++++---- .../Tuples/Specialized/TimeSpanTuple.cs | 10 ++++++---- .../Tuples/Specialized/UHugeTuple.cs | 10 ++++++---- src/OrleanSpaces/Tuples/Specialized/UIntTuple.cs | 10 ++++++---- .../Tuples/Specialized/ULongTuple.cs | 10 ++++++---- .../Tuples/Specialized/UShortTuple.cs | 10 ++++++---- .../OrleanSpaces.Tests/Tuples/BoolTupleTests.cs | 16 ++++++++++++++++ .../OrleanSpaces.Tests/Tuples/ByteTupleTests.cs | 16 ++++++++++++++++ .../OrleanSpaces.Tests/Tuples/CharTupleTests.cs | 16 ++++++++++++++++ .../Tuples/DateTimeOffsetTupleTests.cs | 16 ++++++++++++++++ .../Tuples/DateTimeTupleTests.cs | 16 ++++++++++++++++ .../Tuples/DecimalTupleTests.cs | 16 ++++++++++++++++ .../Tuples/DoubleTupleTests.cs | 16 ++++++++++++++++ .../OrleanSpaces.Tests/Tuples/FloatTupleTests.cs | 16 ++++++++++++++++ .../OrleanSpaces.Tests/Tuples/GuidTupleTests.cs | 16 ++++++++++++++++ .../OrleanSpaces.Tests/Tuples/HugeTupleTests.cs | 16 ++++++++++++++++ tests/OrleanSpaces.Tests/Tuples/IntTupleTests.cs | 16 ++++++++++++++++ .../OrleanSpaces.Tests/Tuples/LongTupleTests.cs | 16 ++++++++++++++++ .../OrleanSpaces.Tests/Tuples/SByteTupleTests.cs | 16 ++++++++++++++++ .../OrleanSpaces.Tests/Tuples/ShortTupleTests.cs | 16 ++++++++++++++++ .../OrleanSpaces.Tests/Tuples/SpaceTupleTests.cs | 16 ++++++++++++++++ .../Tuples/TimeSpanTupleTests.cs | 16 ++++++++++++++++ .../OrleanSpaces.Tests/Tuples/UHugeTupleTests.cs | 16 ++++++++++++++++ .../OrleanSpaces.Tests/Tuples/UIntTupleTests.cs | 16 ++++++++++++++++ .../OrleanSpaces.Tests/Tuples/ULongTupleTests.cs | 16 ++++++++++++++++ .../Tuples/UShortTupleTests.cs | 16 ++++++++++++++++ 42 files changed, 444 insertions(+), 84 deletions(-) diff --git a/src/OrleanSpaces/Helpers/TemplateHelpers.cs b/src/OrleanSpaces/Helpers/TemplateHelpers.cs index a47313cc..da0f26be 100644 --- a/src/OrleanSpaces/Helpers/TemplateHelpers.cs +++ b/src/OrleanSpaces/Helpers/TemplateHelpers.cs @@ -58,5 +58,5 @@ public static bool Matches(this TTemplate template, TTuple [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToString(T?[] fields) where T : unmanaged - => $"({string.Join(", ", fields.Select(field => field is null ? "{NULL}" : field.ToString()))})"; + => fields is null ? "()" : $"({string.Join(", ", fields.Select(field => field is null ? "{NULL}" : field.ToString()))})"; } diff --git a/src/OrleanSpaces/Helpers/TupleHelpers.cs b/src/OrleanSpaces/Helpers/TupleHelpers.cs index 1ae03a6a..3f1ceb2c 100644 --- a/src/OrleanSpaces/Helpers/TupleHelpers.cs +++ b/src/OrleanSpaces/Helpers/TupleHelpers.cs @@ -244,5 +244,5 @@ static int GetCharCount(int tupleLength, int maxFieldCharLength) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static string ToString(T[] fields) where T : unmanaged - => $"({string.Join(", ", fields)})"; + => fields is null ? "()" : $"({string.Join(", ", fields)})"; } diff --git a/src/OrleanSpaces/Tuples/SpaceTuple.cs b/src/OrleanSpaces/Tuples/SpaceTuple.cs index 4104b698..db45d15b 100644 --- a/src/OrleanSpaces/Tuples/SpaceTuple.cs +++ b/src/OrleanSpaces/Tuples/SpaceTuple.cs @@ -102,13 +102,14 @@ public bool Equals(SpaceTuple other) return true; } - public override int GetHashCode() => fields.GetHashCode(); - public override string ToString() => $"({string.Join(", ", fields)})"; + public override int GetHashCode() => fields?.GetHashCode() ?? 0; + public override string ToString() => $"({string.Join(", ", fields ?? Array.Empty())})"; /// /// Returns an enumerator to enumerate over the fields of this tuple. /// - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } /// @@ -224,11 +225,12 @@ public bool Equals(SpaceTemplate other) return true; } - public override int GetHashCode() => fields.GetHashCode(); - public override string ToString() => $"({string.Join(", ", fields.Select(field => field ?? "{NULL}"))})"; + public override int GetHashCode() => fields?.GetHashCode() ?? 0; + public override string ToString() => fields is null ? "()" : $"({string.Join(", ", fields.Select(field => field ?? "{NULL}"))})"; /// /// Returns an enumerator to enumerate over the fields of this tuple. /// - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } \ No newline at end of file diff --git a/src/OrleanSpaces/Tuples/Specialized/BoolTuple.cs b/src/OrleanSpaces/Tuples/Specialized/BoolTuple.cs index ec5ee430..08a585c1 100644 --- a/src/OrleanSpaces/Tuples/Specialized/BoolTuple.cs +++ b/src/OrleanSpaces/Tuples/Specialized/BoolTuple.cs @@ -55,12 +55,13 @@ public bool Equals(BoolTuple other) return marshaller.TryParallelEquals(out bool result) ? result : this.SequentialEquals(other); } - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TupleHelpers.ToString(fields); static BoolTuple ISpaceFactory.Create(bool[] fields) => new(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); public ReadOnlySpan AsSpan() { @@ -131,8 +132,9 @@ public BoolTemplate([AllowNull] params bool?[] fields) public bool Matches(BoolTuple tuple) => this.Matches(tuple); public bool Equals(BoolTemplate other) => this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TemplateHelpers.ToString(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } diff --git a/src/OrleanSpaces/Tuples/Specialized/ByteTuple.cs b/src/OrleanSpaces/Tuples/Specialized/ByteTuple.cs index 0bf9d324..fdbf510f 100644 --- a/src/OrleanSpaces/Tuples/Specialized/ByteTuple.cs +++ b/src/OrleanSpaces/Tuples/Specialized/ByteTuple.cs @@ -55,13 +55,14 @@ public bool Equals(ByteTuple other) => this.TryParallelEquals(other, out bool result) ? result : this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TupleHelpers.ToString(fields); static ByteTuple ISpaceFactory.Create(byte[] fields) => new(fields); public ReadOnlySpan AsSpan() => this.AsSpan(Constants.MaxFieldCharLength_Byte); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } /// @@ -98,8 +99,9 @@ public ByteTemplate([AllowNull] params byte?[] fields) public bool Matches(ByteTuple tuple) => this.Matches(tuple); public bool Equals(ByteTemplate other) => this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TemplateHelpers.ToString(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } diff --git a/src/OrleanSpaces/Tuples/Specialized/CharTuple.cs b/src/OrleanSpaces/Tuples/Specialized/CharTuple.cs index a8660cf2..e7c9a70d 100644 --- a/src/OrleanSpaces/Tuples/Specialized/CharTuple.cs +++ b/src/OrleanSpaces/Tuples/Specialized/CharTuple.cs @@ -66,13 +66,14 @@ public bool Equals(CharTuple other) result : this.SequentialEquals(other); } - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TupleHelpers.ToString(fields); static CharTuple ISpaceFactory.Create(char[] fields) => new(fields); public ReadOnlySpan AsSpan() => this.AsSpan(Constants.MaxFieldCharLength_Char); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } /// @@ -109,8 +110,9 @@ public CharTemplate([AllowNull] params char?[] fields) public bool Matches(CharTuple tuple) => this.Matches(tuple); public bool Equals(CharTemplate other) => this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TemplateHelpers.ToString(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } diff --git a/src/OrleanSpaces/Tuples/Specialized/DateTimeOffsetTuple.cs b/src/OrleanSpaces/Tuples/Specialized/DateTimeOffsetTuple.cs index d9f6f47e..7fd825be 100644 --- a/src/OrleanSpaces/Tuples/Specialized/DateTimeOffsetTuple.cs +++ b/src/OrleanSpaces/Tuples/Specialized/DateTimeOffsetTuple.cs @@ -56,13 +56,14 @@ public bool Equals(DateTimeOffsetTuple other) result : this.SequentialEquals(other); } - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TupleHelpers.ToString(fields); static DateTimeOffsetTuple ISpaceFactory.Create(DateTimeOffset[] fields) => new(fields); public ReadOnlySpan AsSpan() => this.AsSpan(Constants.MaxFieldCharLength_DateTimeOffset); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } /// @@ -99,8 +100,9 @@ public DateTimeOffsetTemplate([AllowNull] params DateTimeOffset?[] fields) => public bool Matches(DateTimeOffsetTuple tuple) => this.Matches(tuple); public bool Equals(DateTimeOffsetTemplate other) => this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TemplateHelpers.ToString(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } diff --git a/src/OrleanSpaces/Tuples/Specialized/DateTimeTuple.cs b/src/OrleanSpaces/Tuples/Specialized/DateTimeTuple.cs index 6c9c4467..d3ebd96f 100644 --- a/src/OrleanSpaces/Tuples/Specialized/DateTimeTuple.cs +++ b/src/OrleanSpaces/Tuples/Specialized/DateTimeTuple.cs @@ -56,13 +56,14 @@ public bool Equals(DateTimeTuple other) result : this.SequentialEquals(other); } - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TupleHelpers.ToString(fields); static DateTimeTuple ISpaceFactory.Create(DateTime[] fields) => new(fields); public ReadOnlySpan AsSpan() => this.AsSpan(Constants.MaxFieldCharLength_DateTime); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } /// @@ -99,8 +100,9 @@ public DateTimeTemplate([AllowNull] params DateTime?[] fields) => public bool Matches(DateTimeTuple tuple) => this.Matches(tuple); public bool Equals(DateTimeTemplate other) => this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TemplateHelpers.ToString(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } diff --git a/src/OrleanSpaces/Tuples/Specialized/DecimalTuple.cs b/src/OrleanSpaces/Tuples/Specialized/DecimalTuple.cs index 0d9788ac..e28833d7 100644 --- a/src/OrleanSpaces/Tuples/Specialized/DecimalTuple.cs +++ b/src/OrleanSpaces/Tuples/Specialized/DecimalTuple.cs @@ -79,13 +79,14 @@ public bool Equals(DecimalTuple other) return new Comparer(this, other).AllocateAndExecute(8 * Length); // 8 x Length, because each decimal will be decomposed into 4 ints, and we have 2 tuples to compare. } - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TupleHelpers.ToString(fields); static DecimalTuple ISpaceFactory.Create(decimal[] fields) => new(fields); public ReadOnlySpan AsSpan() => this.AsSpan(Constants.MaxFieldCharLength_Decimal); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); readonly struct Comparer : IBufferConsumer { @@ -151,8 +152,9 @@ public DecimalTemplate([AllowNull] params decimal?[] fields) public bool Matches(DecimalTuple tuple) => this.Matches(tuple); public bool Equals(DecimalTemplate other) => this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TemplateHelpers.ToString(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } diff --git a/src/OrleanSpaces/Tuples/Specialized/DoubleTuple.cs b/src/OrleanSpaces/Tuples/Specialized/DoubleTuple.cs index d8b8d3f7..459340fb 100644 --- a/src/OrleanSpaces/Tuples/Specialized/DoubleTuple.cs +++ b/src/OrleanSpaces/Tuples/Specialized/DoubleTuple.cs @@ -55,13 +55,14 @@ public bool Equals(DoubleTuple other) => this.TryParallelEquals(other, out bool result) ? result : this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TupleHelpers.ToString(fields); static DoubleTuple ISpaceFactory.Create(double[] fields) => new(fields); public ReadOnlySpan AsSpan() => this.AsSpan(Constants.MaxFieldCharLength_Double); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } /// @@ -98,8 +99,9 @@ public DoubleTemplate([AllowNull] params double?[] fields) public bool Matches(DoubleTuple tuple) => this.Matches(tuple); public bool Equals(DoubleTemplate other) => this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TemplateHelpers.ToString(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } diff --git a/src/OrleanSpaces/Tuples/Specialized/FloatTuple.cs b/src/OrleanSpaces/Tuples/Specialized/FloatTuple.cs index d8de8b73..83b8231d 100644 --- a/src/OrleanSpaces/Tuples/Specialized/FloatTuple.cs +++ b/src/OrleanSpaces/Tuples/Specialized/FloatTuple.cs @@ -55,13 +55,14 @@ public bool Equals(FloatTuple other) => this.TryParallelEquals(other, out bool result) ? result : this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TupleHelpers.ToString(fields); static FloatTuple ISpaceFactory.Create(float[] fields) => new(fields); public ReadOnlySpan AsSpan() => this.AsSpan(Constants.MaxFieldCharLength_Float); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } /// @@ -98,8 +99,9 @@ public FloatTemplate([AllowNull] params float?[] fields) public bool Matches(FloatTuple tuple) => this.Matches(tuple); public bool Equals(FloatTemplate other) => this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TemplateHelpers.ToString(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } diff --git a/src/OrleanSpaces/Tuples/Specialized/GuidTuple.cs b/src/OrleanSpaces/Tuples/Specialized/GuidTuple.cs index b005b892..d09ffbff 100644 --- a/src/OrleanSpaces/Tuples/Specialized/GuidTuple.cs +++ b/src/OrleanSpaces/Tuples/Specialized/GuidTuple.cs @@ -80,13 +80,14 @@ public bool Equals(GuidTuple other) return true; } - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TupleHelpers.ToString(fields); static GuidTuple ISpaceFactory.Create(Guid[] fields) => new(fields); public ReadOnlySpan AsSpan() => this.AsSpan(Constants.MaxFieldCharLength_Guid); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } /// @@ -123,8 +124,9 @@ public GuidTemplate([AllowNull] params Guid?[] fields) public bool Matches(GuidTuple tuple) => this.Matches(tuple); public bool Equals(GuidTemplate other) => this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TemplateHelpers.ToString(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } diff --git a/src/OrleanSpaces/Tuples/Specialized/HugeTuple.cs b/src/OrleanSpaces/Tuples/Specialized/HugeTuple.cs index 9230cab7..9b08b9f7 100644 --- a/src/OrleanSpaces/Tuples/Specialized/HugeTuple.cs +++ b/src/OrleanSpaces/Tuples/Specialized/HugeTuple.cs @@ -68,13 +68,14 @@ public bool Equals(HugeTuple other) return new Comparer(this, other).AllocateAndExecute(2 * Constants.ByteCount_Int128 * Length); } - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TupleHelpers.ToString(fields); static HugeTuple ISpaceFactory.Create(Int128[] fields) => new(fields); public ReadOnlySpan AsSpan() => this.AsSpan(Constants.MaxFieldCharLength_Huge); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); readonly struct Comparer : IBufferConsumer { @@ -147,8 +148,9 @@ public HugeTemplate([AllowNull] params Int128?[] fields) public bool Matches(HugeTuple tuple) => this.Matches(tuple); public bool Equals(HugeTemplate other) => this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TemplateHelpers.ToString(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } diff --git a/src/OrleanSpaces/Tuples/Specialized/IntTuple.cs b/src/OrleanSpaces/Tuples/Specialized/IntTuple.cs index c0807031..f180a793 100644 --- a/src/OrleanSpaces/Tuples/Specialized/IntTuple.cs +++ b/src/OrleanSpaces/Tuples/Specialized/IntTuple.cs @@ -55,13 +55,14 @@ public bool Equals(IntTuple other) => this.TryParallelEquals(other, out bool result) ? result : this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TupleHelpers.ToString(fields); static IntTuple ISpaceFactory.Create(int[] fields) => new(fields); public ReadOnlySpan AsSpan() => this.AsSpan(Constants.MaxFieldCharLength_Int); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } /// @@ -98,8 +99,9 @@ public IntTemplate([AllowNull] params int?[] fields) public bool Matches(IntTuple tuple) => this.Matches(tuple); public bool Equals(IntTemplate other) => this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TemplateHelpers.ToString(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } \ No newline at end of file diff --git a/src/OrleanSpaces/Tuples/Specialized/LongTuple.cs b/src/OrleanSpaces/Tuples/Specialized/LongTuple.cs index 6e5995a7..3c53c15c 100644 --- a/src/OrleanSpaces/Tuples/Specialized/LongTuple.cs +++ b/src/OrleanSpaces/Tuples/Specialized/LongTuple.cs @@ -55,13 +55,14 @@ public bool Equals(LongTuple other) => this.TryParallelEquals(other, out bool result) ? result : this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TupleHelpers.ToString(fields); static LongTuple ISpaceFactory.Create(long[] fields) => new(fields); public ReadOnlySpan AsSpan() => this.AsSpan(Constants.MaxFieldCharLength_Long); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } /// @@ -98,8 +99,9 @@ public LongTemplate([AllowNull] params long?[] fields) public bool Matches(LongTuple tuple) => this.Matches(tuple); public bool Equals(LongTemplate other) => this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TemplateHelpers.ToString(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } diff --git a/src/OrleanSpaces/Tuples/Specialized/SByteTuple.cs b/src/OrleanSpaces/Tuples/Specialized/SByteTuple.cs index 83873e31..756cae34 100644 --- a/src/OrleanSpaces/Tuples/Specialized/SByteTuple.cs +++ b/src/OrleanSpaces/Tuples/Specialized/SByteTuple.cs @@ -55,13 +55,14 @@ public bool Equals(SByteTuple other) => this.TryParallelEquals(other, out bool result) ? result : this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TupleHelpers.ToString(fields); static SByteTuple ISpaceFactory.Create(sbyte[] fields) => new(fields); public ReadOnlySpan AsSpan() => this.AsSpan(Constants.MaxFieldCharLength_SByte); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } /// @@ -98,9 +99,10 @@ public SByteTemplate([AllowNull] params sbyte?[] fields) public bool Matches(SByteTuple tuple) => this.Matches(tuple); public bool Equals(SByteTemplate other) => this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TemplateHelpers.ToString(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } diff --git a/src/OrleanSpaces/Tuples/Specialized/ShortTuple.cs b/src/OrleanSpaces/Tuples/Specialized/ShortTuple.cs index 16b1fee0..01897b4c 100644 --- a/src/OrleanSpaces/Tuples/Specialized/ShortTuple.cs +++ b/src/OrleanSpaces/Tuples/Specialized/ShortTuple.cs @@ -55,13 +55,14 @@ public bool Equals(ShortTuple other) => this.TryParallelEquals(other, out bool result) ? result : this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TupleHelpers.ToString(fields); static ShortTuple ISpaceFactory.Create(short[] fields) => new(fields); public ReadOnlySpan AsSpan() => this.AsSpan(Constants.MaxFieldCharLength_Short); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } /// @@ -98,8 +99,9 @@ public ShortTemplate([AllowNull] params short?[] fields) public bool Matches(ShortTuple tuple) => this.Matches(tuple); public bool Equals(ShortTemplate other) => this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TemplateHelpers.ToString(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } diff --git a/src/OrleanSpaces/Tuples/Specialized/TimeSpanTuple.cs b/src/OrleanSpaces/Tuples/Specialized/TimeSpanTuple.cs index 1ddd46fe..0264eebd 100644 --- a/src/OrleanSpaces/Tuples/Specialized/TimeSpanTuple.cs +++ b/src/OrleanSpaces/Tuples/Specialized/TimeSpanTuple.cs @@ -56,13 +56,14 @@ public bool Equals(TimeSpanTuple other) result : this.SequentialEquals(other); } - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TupleHelpers.ToString(fields); static TimeSpanTuple ISpaceFactory.Create(TimeSpan[] fields) => new(fields); public ReadOnlySpan AsSpan() => this.AsSpan(Constants.MaxFieldCharLength_TimeSpan); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } /// @@ -99,8 +100,9 @@ public TimeSpanTemplate([AllowNull] params TimeSpan?[] fields) public bool Matches(TimeSpanTuple tuple) => this.Matches(tuple); public bool Equals(TimeSpanTemplate other) => this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TemplateHelpers.ToString(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } \ No newline at end of file diff --git a/src/OrleanSpaces/Tuples/Specialized/UHugeTuple.cs b/src/OrleanSpaces/Tuples/Specialized/UHugeTuple.cs index 6f844976..956fb991 100644 --- a/src/OrleanSpaces/Tuples/Specialized/UHugeTuple.cs +++ b/src/OrleanSpaces/Tuples/Specialized/UHugeTuple.cs @@ -68,13 +68,14 @@ public bool Equals(UHugeTuple other) return new Comparer(this, other).AllocateAndExecute(2 * Constants.ByteCount_UInt128 * Length); } - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TupleHelpers.ToString(fields); static UHugeTuple ISpaceFactory.Create(UInt128[] fields) => new(fields); public ReadOnlySpan AsSpan() => this.AsSpan(Constants.MaxFieldCharLength_UHuge); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); readonly struct Comparer : IBufferConsumer { @@ -147,8 +148,9 @@ public UHugeTemplate([AllowNull] params UInt128?[] fields) public bool Matches(UHugeTuple tuple) => this.Matches(tuple); public bool Equals(UHugeTemplate other) => this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TemplateHelpers.ToString(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } diff --git a/src/OrleanSpaces/Tuples/Specialized/UIntTuple.cs b/src/OrleanSpaces/Tuples/Specialized/UIntTuple.cs index 35dd6564..3a37ce70 100644 --- a/src/OrleanSpaces/Tuples/Specialized/UIntTuple.cs +++ b/src/OrleanSpaces/Tuples/Specialized/UIntTuple.cs @@ -55,13 +55,14 @@ public bool Equals(UIntTuple other) => this.TryParallelEquals(other, out bool result) ? result : this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TupleHelpers.ToString(fields); static UIntTuple ISpaceFactory.Create(uint[] fields) => new(fields); public ReadOnlySpan AsSpan() => this.AsSpan(Constants.MaxFieldCharLength_UInt); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } /// @@ -98,8 +99,9 @@ public UIntTemplate([AllowNull] params uint?[] fields) public bool Matches(UIntTuple tuple) => this.Matches(tuple); public bool Equals(UIntTemplate other) => this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TemplateHelpers.ToString(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } \ No newline at end of file diff --git a/src/OrleanSpaces/Tuples/Specialized/ULongTuple.cs b/src/OrleanSpaces/Tuples/Specialized/ULongTuple.cs index 76b1de70..0421c834 100644 --- a/src/OrleanSpaces/Tuples/Specialized/ULongTuple.cs +++ b/src/OrleanSpaces/Tuples/Specialized/ULongTuple.cs @@ -55,13 +55,14 @@ public bool Equals(ULongTuple other) => this.TryParallelEquals(other, out bool result) ? result : this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TupleHelpers.ToString(fields); static ULongTuple ISpaceFactory.Create(ulong[] fields) => new(fields); public ReadOnlySpan AsSpan() => this.AsSpan(Constants.MaxFieldCharLength_ULong); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } /// @@ -98,8 +99,9 @@ public ULongTemplate([AllowNull] params ulong?[] fields) public bool Matches(ULongTuple tuple) => this.Matches(tuple); public bool Equals(ULongTemplate other) => this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TemplateHelpers.ToString(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } diff --git a/src/OrleanSpaces/Tuples/Specialized/UShortTuple.cs b/src/OrleanSpaces/Tuples/Specialized/UShortTuple.cs index c724cca2..4615e178 100644 --- a/src/OrleanSpaces/Tuples/Specialized/UShortTuple.cs +++ b/src/OrleanSpaces/Tuples/Specialized/UShortTuple.cs @@ -55,13 +55,14 @@ public bool Equals(UShortTuple other) => this.TryParallelEquals(other, out bool result) ? result : this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TupleHelpers.ToString(fields); static UShortTuple ISpaceFactory.Create(ushort[] fields) => new(fields); public ReadOnlySpan AsSpan() => this.AsSpan(Constants.MaxFieldCharLength_UShort); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } /// @@ -98,8 +99,9 @@ public UShortTemplate([AllowNull] params ushort?[] fields) public bool Matches(UShortTuple tuple) => this.Matches(tuple); public bool Equals(UShortTemplate other) => this.SequentialEquals(other); - public override int GetHashCode() => fields.GetHashCode(); + public override int GetHashCode() => fields?.GetHashCode() ?? 0; public override string ToString() => TemplateHelpers.ToString(fields); - public ReadOnlySpan.Enumerator GetEnumerator() => new ReadOnlySpan(fields).GetEnumerator(); + public ReadOnlySpan.Enumerator GetEnumerator() => + (fields is null ? ReadOnlySpan.Empty : new ReadOnlySpan(fields)).GetEnumerator(); } diff --git a/tests/OrleanSpaces.Tests/Tuples/BoolTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/BoolTupleTests.cs index 0c4240aa..91327549 100644 --- a/tests/OrleanSpaces.Tests/Tuples/BoolTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/BoolTupleTests.cs @@ -16,6 +16,14 @@ public void Should_Be_Created_On_Array() Assert.True(tuple[2]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + BoolTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -133,6 +141,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + BoolTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Default_Constructor() { diff --git a/tests/OrleanSpaces.Tests/Tuples/ByteTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/ByteTupleTests.cs index e863d0dd..ada9028b 100644 --- a/tests/OrleanSpaces.Tests/Tuples/ByteTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/ByteTupleTests.cs @@ -16,6 +16,14 @@ public void Should_Be_Created_On_Array() Assert.Equal((byte)3, tuple[2]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + ByteTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -133,6 +141,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + ByteTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Default_Constructor() { diff --git a/tests/OrleanSpaces.Tests/Tuples/CharTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/CharTupleTests.cs index 7d0bd57b..21c0769a 100644 --- a/tests/OrleanSpaces.Tests/Tuples/CharTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/CharTupleTests.cs @@ -17,6 +17,14 @@ public void Should_Be_Created_On_Array() Assert.Equal('c', tuple[2]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + CharTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -134,6 +142,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + CharTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Default_Constructor() { diff --git a/tests/OrleanSpaces.Tests/Tuples/DateTimeOffsetTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/DateTimeOffsetTupleTests.cs index 03e52b22..01bae0c6 100644 --- a/tests/OrleanSpaces.Tests/Tuples/DateTimeOffsetTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/DateTimeOffsetTupleTests.cs @@ -21,6 +21,14 @@ public void Should_Be_Created_On_Array() Assert.Equal(offset3, tuple[2]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + DateTimeOffsetTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -143,6 +151,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + DateTimeOffsetTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Default_Constructor() { diff --git a/tests/OrleanSpaces.Tests/Tuples/DateTimeTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/DateTimeTupleTests.cs index 2e65a72b..6ebc4336 100644 --- a/tests/OrleanSpaces.Tests/Tuples/DateTimeTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/DateTimeTupleTests.cs @@ -21,6 +21,14 @@ public void Should_Be_Created_On_Array() Assert.Equal(dateTime3, tuple[2]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + DateTimeTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -143,6 +151,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + DateTimeTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Default_Constructor() { diff --git a/tests/OrleanSpaces.Tests/Tuples/DecimalTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/DecimalTupleTests.cs index 1ef0300c..a37103af 100644 --- a/tests/OrleanSpaces.Tests/Tuples/DecimalTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/DecimalTupleTests.cs @@ -16,6 +16,14 @@ public void Should_Be_Created_On_Array() Assert.Equal(3, tuple[2]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + DecimalTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -133,6 +141,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + DecimalTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Default_Constructor() { diff --git a/tests/OrleanSpaces.Tests/Tuples/DoubleTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/DoubleTupleTests.cs index ab171687..c6bc91a6 100644 --- a/tests/OrleanSpaces.Tests/Tuples/DoubleTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/DoubleTupleTests.cs @@ -16,6 +16,14 @@ public void Should_Be_Created_On_Array() Assert.Equal(3, tuple[2]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + DoubleTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -133,6 +141,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + DoubleTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Default_Constructor() { diff --git a/tests/OrleanSpaces.Tests/Tuples/FloatTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/FloatTupleTests.cs index 86b1d294..5e187922 100644 --- a/tests/OrleanSpaces.Tests/Tuples/FloatTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/FloatTupleTests.cs @@ -16,6 +16,14 @@ public void Should_Be_Created_On_Array() Assert.Equal(3, tuple[2]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + FloatTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -133,6 +141,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + FloatTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Default_Constructor() { diff --git a/tests/OrleanSpaces.Tests/Tuples/GuidTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/GuidTupleTests.cs index 5d0cc471..b7f2017e 100644 --- a/tests/OrleanSpaces.Tests/Tuples/GuidTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/GuidTupleTests.cs @@ -21,6 +21,14 @@ public void Should_Be_Created_On_Array() Assert.Equal(guid3, tuple[2]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + GuidTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -143,6 +151,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + GuidTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Default_Constructor() { diff --git a/tests/OrleanSpaces.Tests/Tuples/HugeTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/HugeTupleTests.cs index 8f7f818d..c5fa1426 100644 --- a/tests/OrleanSpaces.Tests/Tuples/HugeTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/HugeTupleTests.cs @@ -16,6 +16,14 @@ public void Should_Be_Created_On_Array() Assert.Equal(3, tuple[2]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + HugeTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -133,6 +141,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + HugeTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Default_Constructor() { diff --git a/tests/OrleanSpaces.Tests/Tuples/IntTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/IntTupleTests.cs index d03d40b2..86b55854 100644 --- a/tests/OrleanSpaces.Tests/Tuples/IntTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/IntTupleTests.cs @@ -16,6 +16,14 @@ public void Should_Be_Created_On_Array() Assert.Equal(3, tuple[2]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + IntTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -133,6 +141,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + IntTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Default_Constructor() { diff --git a/tests/OrleanSpaces.Tests/Tuples/LongTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/LongTupleTests.cs index 7b116596..8d55b96d 100644 --- a/tests/OrleanSpaces.Tests/Tuples/LongTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/LongTupleTests.cs @@ -16,6 +16,14 @@ public void Should_Be_Created_On_Array() Assert.Equal(3, tuple[2]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + LongTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -133,6 +141,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + LongTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Default_Constructor() { diff --git a/tests/OrleanSpaces.Tests/Tuples/SByteTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/SByteTupleTests.cs index bb2e5edc..2ad6aab3 100644 --- a/tests/OrleanSpaces.Tests/Tuples/SByteTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/SByteTupleTests.cs @@ -16,6 +16,14 @@ public void Should_Be_Created_On_Array() Assert.Equal((sbyte)-3, tuple[2]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + SByteTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -133,6 +141,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + SByteTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Default_Constructor() { diff --git a/tests/OrleanSpaces.Tests/Tuples/ShortTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/ShortTupleTests.cs index ce33a170..9fced7f4 100644 --- a/tests/OrleanSpaces.Tests/Tuples/ShortTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/ShortTupleTests.cs @@ -16,6 +16,14 @@ public void Should_Be_Created_On_Array() Assert.Equal((short)3, tuple[2]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + ShortTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -133,6 +141,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + ShortTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Default_Constructor() { diff --git a/tests/OrleanSpaces.Tests/Tuples/SpaceTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/SpaceTupleTests.cs index 74a55070..a8863aa4 100644 --- a/tests/OrleanSpaces.Tests/Tuples/SpaceTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/SpaceTupleTests.cs @@ -69,6 +69,14 @@ public void Should_Not_Throw_On_Empty_String() Assert.Null(expection); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + SpaceTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -186,6 +194,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + SpaceTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Value_Type() { diff --git a/tests/OrleanSpaces.Tests/Tuples/TimeSpanTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/TimeSpanTupleTests.cs index ec6b6bef..81735225 100644 --- a/tests/OrleanSpaces.Tests/Tuples/TimeSpanTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/TimeSpanTupleTests.cs @@ -21,6 +21,14 @@ public void Should_Be_Created_On_Array() Assert.Equal(timeSpan3, tuple[2]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + TimeSpanTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -143,6 +151,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + TimeSpanTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Default_Constructor() { diff --git a/tests/OrleanSpaces.Tests/Tuples/UHugeTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/UHugeTupleTests.cs index 3e421be4..55d71b95 100644 --- a/tests/OrleanSpaces.Tests/Tuples/UHugeTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/UHugeTupleTests.cs @@ -16,6 +16,14 @@ public void Should_Be_Created_On_Array() Assert.Equal((UInt128)3, tuple[2]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + UHugeTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -133,6 +141,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + UHugeTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Default_Constructor() { diff --git a/tests/OrleanSpaces.Tests/Tuples/UIntTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/UIntTupleTests.cs index d2969466..475673fb 100644 --- a/tests/OrleanSpaces.Tests/Tuples/UIntTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/UIntTupleTests.cs @@ -16,6 +16,14 @@ public void Should_Be_Created_On_Array() Assert.Equal((uint)3, tuple[2]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + UIntTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -133,6 +141,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + UIntTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Default_Constructor() { diff --git a/tests/OrleanSpaces.Tests/Tuples/ULongTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/ULongTupleTests.cs index bf60f96e..c8d3901c 100644 --- a/tests/OrleanSpaces.Tests/Tuples/ULongTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/ULongTupleTests.cs @@ -16,6 +16,14 @@ public void Should_Be_Created_On_Array() Assert.Equal((ulong)3, tuple[2]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + ULongTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -133,6 +141,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + ULongTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Default_Constructor() { diff --git a/tests/OrleanSpaces.Tests/Tuples/UShortTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/UShortTupleTests.cs index e86b7804..98b70b15 100644 --- a/tests/OrleanSpaces.Tests/Tuples/UShortTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/UShortTupleTests.cs @@ -16,6 +16,14 @@ public void Should_Be_Created_On_Array() Assert.Equal((ushort)3, tuple[2]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + UShortTuple tuple = default; + Assert.Equal(0, tuple.Length); + Assert.True(tuple.IsEmpty); + } + [Fact] public void Should_Create_Empty_Tuple_On_Default_Constructor() { @@ -133,6 +141,14 @@ public void Should_Be_Created_On_Empty_Array() Assert.Null(template[0]); } + [Fact] + public void Should_Create_Empty_Tuple_On_Default_Keyword() + { + UShortTemplate template = default; + Assert.Equal(1, template.Length); + Assert.Null(template[0]); + } + [Fact] public void Should_Be_Created_On_Default_Constructor() { From 2b628eb49973605dae7e5cb63d4bde8001553cdc Mon Sep 17 00:00:00 2001 From: Ledjon Behluli Date: Sat, 22 Jul 2023 20:03:26 +0200 Subject: [PATCH 2/2] fixed tests --- tests/OrleanSpaces.Tests/Tuples/BoolTupleTests.cs | 5 ++--- tests/OrleanSpaces.Tests/Tuples/ByteTupleTests.cs | 5 ++--- tests/OrleanSpaces.Tests/Tuples/CharTupleTests.cs | 5 ++--- .../Tuples/DateTimeOffsetTupleTests.cs | 5 ++--- .../OrleanSpaces.Tests/Tuples/DateTimeTupleTests.cs | 5 ++--- .../OrleanSpaces.Tests/Tuples/DecimalTupleTests.cs | 5 ++--- tests/OrleanSpaces.Tests/Tuples/DoubleTupleTests.cs | 5 ++--- tests/OrleanSpaces.Tests/Tuples/FloatTupleTests.cs | 13 ++----------- tests/OrleanSpaces.Tests/Tuples/GuidTupleTests.cs | 5 ++--- tests/OrleanSpaces.Tests/Tuples/HugeTupleTests.cs | 5 ++--- tests/OrleanSpaces.Tests/Tuples/IntTupleTests.cs | 5 ++--- tests/OrleanSpaces.Tests/Tuples/LongTupleTests.cs | 5 ++--- tests/OrleanSpaces.Tests/Tuples/SByteTupleTests.cs | 5 ++--- tests/OrleanSpaces.Tests/Tuples/ShortTupleTests.cs | 5 ++--- tests/OrleanSpaces.Tests/Tuples/SpaceTupleTests.cs | 5 ++--- .../OrleanSpaces.Tests/Tuples/TimeSpanTupleTests.cs | 5 ++--- tests/OrleanSpaces.Tests/Tuples/UHugeTupleTests.cs | 5 ++--- tests/OrleanSpaces.Tests/Tuples/UIntTupleTests.cs | 5 ++--- tests/OrleanSpaces.Tests/Tuples/ULongTupleTests.cs | 5 ++--- tests/OrleanSpaces.Tests/Tuples/UShortTupleTests.cs | 5 ++--- 20 files changed, 40 insertions(+), 68 deletions(-) diff --git a/tests/OrleanSpaces.Tests/Tuples/BoolTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/BoolTupleTests.cs index 91327549..f5dacec3 100644 --- a/tests/OrleanSpaces.Tests/Tuples/BoolTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/BoolTupleTests.cs @@ -142,11 +142,10 @@ public void Should_Be_Created_On_Empty_Array() } [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { BoolTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact] diff --git a/tests/OrleanSpaces.Tests/Tuples/ByteTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/ByteTupleTests.cs index ada9028b..e56ee6e1 100644 --- a/tests/OrleanSpaces.Tests/Tuples/ByteTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/ByteTupleTests.cs @@ -142,11 +142,10 @@ public void Should_Be_Created_On_Empty_Array() } [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { ByteTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact] diff --git a/tests/OrleanSpaces.Tests/Tuples/CharTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/CharTupleTests.cs index 21c0769a..27f1d4bf 100644 --- a/tests/OrleanSpaces.Tests/Tuples/CharTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/CharTupleTests.cs @@ -143,11 +143,10 @@ public void Should_Be_Created_On_Empty_Array() } [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { CharTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact] diff --git a/tests/OrleanSpaces.Tests/Tuples/DateTimeOffsetTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/DateTimeOffsetTupleTests.cs index 01bae0c6..23ee429b 100644 --- a/tests/OrleanSpaces.Tests/Tuples/DateTimeOffsetTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/DateTimeOffsetTupleTests.cs @@ -152,11 +152,10 @@ public void Should_Be_Created_On_Empty_Array() } [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { DateTimeOffsetTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact] diff --git a/tests/OrleanSpaces.Tests/Tuples/DateTimeTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/DateTimeTupleTests.cs index 6ebc4336..c572d2e7 100644 --- a/tests/OrleanSpaces.Tests/Tuples/DateTimeTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/DateTimeTupleTests.cs @@ -152,11 +152,10 @@ public void Should_Be_Created_On_Empty_Array() } [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { DateTimeTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact] diff --git a/tests/OrleanSpaces.Tests/Tuples/DecimalTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/DecimalTupleTests.cs index a37103af..07c29a35 100644 --- a/tests/OrleanSpaces.Tests/Tuples/DecimalTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/DecimalTupleTests.cs @@ -142,11 +142,10 @@ public void Should_Be_Created_On_Empty_Array() } [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { DecimalTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact] diff --git a/tests/OrleanSpaces.Tests/Tuples/DoubleTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/DoubleTupleTests.cs index c6bc91a6..e2450818 100644 --- a/tests/OrleanSpaces.Tests/Tuples/DoubleTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/DoubleTupleTests.cs @@ -142,11 +142,10 @@ public void Should_Be_Created_On_Empty_Array() } [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { DoubleTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact] diff --git a/tests/OrleanSpaces.Tests/Tuples/FloatTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/FloatTupleTests.cs index 5e187922..fecb848a 100644 --- a/tests/OrleanSpaces.Tests/Tuples/FloatTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/FloatTupleTests.cs @@ -134,19 +134,10 @@ public void Should_Be_Created_On_Array() } [Fact] - public void Should_Be_Created_On_Empty_Array() - { - FloatTemplate template = new(Array.Empty()); - Assert.Equal(1, template.Length); - Assert.Null(template[0]); - } - - [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { FloatTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact] diff --git a/tests/OrleanSpaces.Tests/Tuples/GuidTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/GuidTupleTests.cs index b7f2017e..66978118 100644 --- a/tests/OrleanSpaces.Tests/Tuples/GuidTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/GuidTupleTests.cs @@ -152,11 +152,10 @@ public void Should_Be_Created_On_Empty_Array() } [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { GuidTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact] diff --git a/tests/OrleanSpaces.Tests/Tuples/HugeTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/HugeTupleTests.cs index c5fa1426..b3a14746 100644 --- a/tests/OrleanSpaces.Tests/Tuples/HugeTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/HugeTupleTests.cs @@ -142,11 +142,10 @@ public void Should_Be_Created_On_Empty_Array() } [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { HugeTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact] diff --git a/tests/OrleanSpaces.Tests/Tuples/IntTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/IntTupleTests.cs index 86b55854..cfa0f102 100644 --- a/tests/OrleanSpaces.Tests/Tuples/IntTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/IntTupleTests.cs @@ -142,11 +142,10 @@ public void Should_Be_Created_On_Empty_Array() } [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { IntTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact] diff --git a/tests/OrleanSpaces.Tests/Tuples/LongTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/LongTupleTests.cs index 8d55b96d..ff10502f 100644 --- a/tests/OrleanSpaces.Tests/Tuples/LongTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/LongTupleTests.cs @@ -142,11 +142,10 @@ public void Should_Be_Created_On_Empty_Array() } [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { LongTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact] diff --git a/tests/OrleanSpaces.Tests/Tuples/SByteTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/SByteTupleTests.cs index 2ad6aab3..42ebc92d 100644 --- a/tests/OrleanSpaces.Tests/Tuples/SByteTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/SByteTupleTests.cs @@ -142,11 +142,10 @@ public void Should_Be_Created_On_Empty_Array() } [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { SByteTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact] diff --git a/tests/OrleanSpaces.Tests/Tuples/ShortTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/ShortTupleTests.cs index 9fced7f4..b545319a 100644 --- a/tests/OrleanSpaces.Tests/Tuples/ShortTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/ShortTupleTests.cs @@ -142,11 +142,10 @@ public void Should_Be_Created_On_Empty_Array() } [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { ShortTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact] diff --git a/tests/OrleanSpaces.Tests/Tuples/SpaceTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/SpaceTupleTests.cs index a8863aa4..92f5cbd9 100644 --- a/tests/OrleanSpaces.Tests/Tuples/SpaceTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/SpaceTupleTests.cs @@ -195,11 +195,10 @@ public void Should_Be_Created_On_Empty_Array() } [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { SpaceTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact] diff --git a/tests/OrleanSpaces.Tests/Tuples/TimeSpanTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/TimeSpanTupleTests.cs index 81735225..308ccaed 100644 --- a/tests/OrleanSpaces.Tests/Tuples/TimeSpanTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/TimeSpanTupleTests.cs @@ -152,11 +152,10 @@ public void Should_Be_Created_On_Empty_Array() } [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { TimeSpanTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact] diff --git a/tests/OrleanSpaces.Tests/Tuples/UHugeTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/UHugeTupleTests.cs index 55d71b95..2980edb9 100644 --- a/tests/OrleanSpaces.Tests/Tuples/UHugeTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/UHugeTupleTests.cs @@ -142,11 +142,10 @@ public void Should_Be_Created_On_Empty_Array() } [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { UHugeTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact] diff --git a/tests/OrleanSpaces.Tests/Tuples/UIntTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/UIntTupleTests.cs index 475673fb..f9b8d118 100644 --- a/tests/OrleanSpaces.Tests/Tuples/UIntTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/UIntTupleTests.cs @@ -142,11 +142,10 @@ public void Should_Be_Created_On_Empty_Array() } [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { UIntTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact] diff --git a/tests/OrleanSpaces.Tests/Tuples/ULongTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/ULongTupleTests.cs index c8d3901c..6aca0293 100644 --- a/tests/OrleanSpaces.Tests/Tuples/ULongTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/ULongTupleTests.cs @@ -142,11 +142,10 @@ public void Should_Be_Created_On_Empty_Array() } [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { ULongTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact] diff --git a/tests/OrleanSpaces.Tests/Tuples/UShortTupleTests.cs b/tests/OrleanSpaces.Tests/Tuples/UShortTupleTests.cs index 98b70b15..5a7a9cfc 100644 --- a/tests/OrleanSpaces.Tests/Tuples/UShortTupleTests.cs +++ b/tests/OrleanSpaces.Tests/Tuples/UShortTupleTests.cs @@ -142,11 +142,10 @@ public void Should_Be_Created_On_Empty_Array() } [Fact] - public void Should_Create_Empty_Tuple_On_Default_Keyword() + public void Should_Be_Created_On_Default_Keyword() { UShortTemplate template = default; - Assert.Equal(1, template.Length); - Assert.Null(template[0]); + Assert.Equal(0, template.Length); } [Fact]