diff --git a/X10D.Tests/src/Math/ByteTests.cs b/X10D.Tests/src/Math/ByteTests.cs index 660822200..ac1b99e60 100644 --- a/X10D.Tests/src/Math/ByteTests.cs +++ b/X10D.Tests/src/Math/ByteTests.cs @@ -51,13 +51,29 @@ public void CountDigits_ShouldReturn3_Given199() } [Test] - public void DigitalRootShouldBeCorrect() + public void DigitalRoot_ShouldReturn4_Given238() { const byte value = 238; Assert.That(value.DigitalRoot(), Is.EqualTo(4)); Assert.That((-value).DigitalRoot(), Is.EqualTo(4)); } + [Test] + public void DigitalRoot_ShouldReturn9_Given9() + { + const byte value = 9; + Assert.That(value.DigitalRoot(), Is.EqualTo(9)); + Assert.That((-value).DigitalRoot(), Is.EqualTo(9)); + } + + [Test] + public void DigitalRoot_ShouldReturn9_Given18() + { + const byte value = 18; + Assert.That(value.DigitalRoot(), Is.EqualTo(9)); + Assert.That((-value).DigitalRoot(), Is.EqualTo(9)); + } + [Test] public void FactorialShouldBeCorrect() { diff --git a/X10D.Tests/src/Math/Int16Tests.cs b/X10D.Tests/src/Math/Int16Tests.cs index 7ba50a23b..ac68889f4 100644 --- a/X10D.Tests/src/Math/Int16Tests.cs +++ b/X10D.Tests/src/Math/Int16Tests.cs @@ -62,13 +62,29 @@ public void CountDigits_ShouldReturn3_Given199() } [Test] - public void DigitalRootShouldBeCorrect() + public void DigitalRoot_ShouldReturn4_Given238() { const short value = 238; Assert.That(value.DigitalRoot(), Is.EqualTo(4)); Assert.That((-value).DigitalRoot(), Is.EqualTo(4)); } + [Test] + public void DigitalRoot_ShouldReturn9_Given9() + { + const short value = 9; + Assert.That(value.DigitalRoot(), Is.EqualTo(9)); + Assert.That((-value).DigitalRoot(), Is.EqualTo(9)); + } + + [Test] + public void DigitalRoot_ShouldReturn9_Given18() + { + const short value = 18; + Assert.That(value.DigitalRoot(), Is.EqualTo(9)); + Assert.That((-value).DigitalRoot(), Is.EqualTo(9)); + } + [Test] public void FactorialShouldBeCorrect() { diff --git a/X10D.Tests/src/Math/Int32Tests.cs b/X10D.Tests/src/Math/Int32Tests.cs index 664e16f3c..68e05cdd5 100644 --- a/X10D.Tests/src/Math/Int32Tests.cs +++ b/X10D.Tests/src/Math/Int32Tests.cs @@ -62,13 +62,29 @@ public void CountDigits_ShouldReturn3_Given199() } [Test] - public void DigitalRootShouldBeCorrect() + public void DigitalRoot_ShouldReturn4_Given238() { const int value = 238; Assert.That(value.DigitalRoot(), Is.EqualTo(4)); Assert.That((-value).DigitalRoot(), Is.EqualTo(4)); } + [Test] + public void DigitalRoot_ShouldReturn9_Given9() + { + const int value = 9; + Assert.That(value.DigitalRoot(), Is.EqualTo(9)); + Assert.That((-value).DigitalRoot(), Is.EqualTo(9)); + } + + [Test] + public void DigitalRoot_ShouldReturn9_Given18() + { + const int value = 18; + Assert.That(value.DigitalRoot(), Is.EqualTo(9)); + Assert.That((-value).DigitalRoot(), Is.EqualTo(9)); + } + [Test] public void FactorialShouldBeCorrect() { diff --git a/X10D.Tests/src/Math/Int64Tests.cs b/X10D.Tests/src/Math/Int64Tests.cs index 8dd40a907..e1f37fd02 100644 --- a/X10D.Tests/src/Math/Int64Tests.cs +++ b/X10D.Tests/src/Math/Int64Tests.cs @@ -62,13 +62,29 @@ public void CountDigits_ShouldReturn3_Given199() } [Test] - public void DigitalRootShouldBeCorrect() + public void DigitalRoot_ShouldReturn4_Given238() { const long value = 238; Assert.That(value.DigitalRoot(), Is.EqualTo(4)); Assert.That((-value).DigitalRoot(), Is.EqualTo(4)); } + [Test] + public void DigitalRoot_ShouldReturn9_Given9() + { + const long value = 9; + Assert.That(value.DigitalRoot(), Is.EqualTo(9)); + Assert.That((-value).DigitalRoot(), Is.EqualTo(9)); + } + + [Test] + public void DigitalRoot_ShouldReturn9_Given18() + { + const long value = 18; + Assert.That(value.DigitalRoot(), Is.EqualTo(9)); + Assert.That((-value).DigitalRoot(), Is.EqualTo(9)); + } + [Test] public void FactorialShouldBeCorrect() { diff --git a/X10D.Tests/src/Math/SByteTests.cs b/X10D.Tests/src/Math/SByteTests.cs index 3727af4dd..fd9a4fad3 100644 --- a/X10D.Tests/src/Math/SByteTests.cs +++ b/X10D.Tests/src/Math/SByteTests.cs @@ -62,13 +62,29 @@ public void CountDigits_ShouldReturn3_Given127() } [Test] - public void DigitalRootShouldBeCorrect() + public void DigitalRoot_ShouldReturn4_Given127() { const sbyte value = 127; // sbyte.MaxValue. can't use 238 like the other tests Assert.That(value.DigitalRoot(), Is.EqualTo(1)); Assert.That((-value).DigitalRoot(), Is.EqualTo(1)); } + [Test] + public void DigitalRoot_ShouldReturn9_Given9() + { + const sbyte value = 9; + Assert.That(value.DigitalRoot(), Is.EqualTo(9)); + Assert.That((-value).DigitalRoot(), Is.EqualTo(9)); + } + + [Test] + public void DigitalRoot_ShouldReturn9_Given18() + { + const sbyte value = 18; + Assert.That(value.DigitalRoot(), Is.EqualTo(9)); + Assert.That((-value).DigitalRoot(), Is.EqualTo(9)); + } + [Test] public void FactorialShouldBeCorrect() { diff --git a/X10D.Tests/src/Math/UInt16Tests.cs b/X10D.Tests/src/Math/UInt16Tests.cs index d51f983eb..3a7bb0d96 100644 --- a/X10D.Tests/src/Math/UInt16Tests.cs +++ b/X10D.Tests/src/Math/UInt16Tests.cs @@ -51,13 +51,29 @@ public void CountDigits_ShouldReturn3_Given199() } [Test] - public void DigitalRootShouldBeCorrect() + public void DigitalRoot_ShouldReturn4_Given238() { const ushort value = 238; Assert.That(value.DigitalRoot(), Is.EqualTo(4)); Assert.That((-value).DigitalRoot(), Is.EqualTo(4)); } + [Test] + public void DigitalRoot_ShouldReturn9_Given9() + { + const ushort value = 9; + Assert.That(value.DigitalRoot(), Is.EqualTo(9)); + Assert.That((-value).DigitalRoot(), Is.EqualTo(9)); + } + + [Test] + public void DigitalRoot_ShouldReturn9_Given18() + { + const ushort value = 18; + Assert.That(value.DigitalRoot(), Is.EqualTo(9)); + Assert.That((-value).DigitalRoot(), Is.EqualTo(9)); + } + [Test] public void FactorialShouldBeCorrect() { diff --git a/X10D.Tests/src/Math/UInt32Tests.cs b/X10D.Tests/src/Math/UInt32Tests.cs index f2db8e8f4..e5c9e9103 100644 --- a/X10D.Tests/src/Math/UInt32Tests.cs +++ b/X10D.Tests/src/Math/UInt32Tests.cs @@ -50,11 +50,27 @@ public void CountDigits_ShouldReturn3_Given199() } [Test] - public void DigitalRootShouldBeCorrect() + public void DigitalRoot_ShouldReturn4_Given238() { const uint value = 238; - Assert.That(value.DigitalRoot(), Is.EqualTo(4U)); - Assert.That((-value).DigitalRoot(), Is.EqualTo(4U)); + Assert.That(value.DigitalRoot(), Is.EqualTo(4)); + Assert.That((-value).DigitalRoot(), Is.EqualTo(4)); + } + + [Test] + public void DigitalRoot_ShouldReturn9_Given9() + { + const uint value = 9; + Assert.That(value.DigitalRoot(), Is.EqualTo(9)); + Assert.That((-value).DigitalRoot(), Is.EqualTo(9)); + } + + [Test] + public void DigitalRoot_ShouldReturn9_Given18() + { + const uint value = 18; + Assert.That(value.DigitalRoot(), Is.EqualTo(9)); + Assert.That((-value).DigitalRoot(), Is.EqualTo(9)); } [Test] diff --git a/X10D.Tests/src/Math/UInt64Tests.cs b/X10D.Tests/src/Math/UInt64Tests.cs index 7391cc54b..8c7a215a5 100644 --- a/X10D.Tests/src/Math/UInt64Tests.cs +++ b/X10D.Tests/src/Math/UInt64Tests.cs @@ -51,15 +51,31 @@ public void CountDigits_ShouldReturn3_Given199() } [Test] - public void DigitalRootShouldBeCorrect() + public void DigitalRoot_ShouldReturn4_Given238() { const ulong value = 238; - Assert.That(value.DigitalRoot(), Is.EqualTo(4U)); + Assert.That(value.DigitalRoot(), Is.EqualTo(4)); // -ulong operator not defined because it might exceed long.MinValue, // so instead, cast to long and then negate. // HAX. - Assert.That((-(long)value).DigitalRoot(), Is.EqualTo(4U)); + Assert.That((-(long)value).DigitalRoot(), Is.EqualTo(4)); + } + + [Test] + public void DigitalRoot_ShouldReturn9_Given9() + { + const ulong value = 9; + Assert.That(value.DigitalRoot(), Is.EqualTo(9)); + Assert.That((-(long)value).DigitalRoot(), Is.EqualTo(9)); + } + + [Test] + public void DigitalRoot_ShouldReturn9_Given18() + { + const ulong value = 18; + Assert.That(value.DigitalRoot(), Is.EqualTo(9)); + Assert.That((-(long)value).DigitalRoot(), Is.EqualTo(9)); } [Test]