Skip to content
Permalink
Browse files

Str - ParseFromString

  • Loading branch information...
bobbymcr committed Apr 5, 2019
1 parent 777b0a1 commit 5bc6661239c4ca9deafb66d8eb5f4106c8df0683
Showing with 30 additions and 0 deletions.
  1. +11 −0 src/Words.Core/Str.cs
  2. +19 −0 test/Words.Test/StrTest.cs
@@ -32,6 +32,17 @@ private Str(ulong data)
}
}

public static Str Parse(string s)
{
Str value = default(Str);
foreach (char c in s)
{
value = value.Append((Ch)(c - 'A' + 1));
}

return value;
}

public bool Equals(Str other) => this.data == other.data;

public override int GetHashCode() => this.data.GetHashCode();
@@ -345,6 +345,25 @@ public void HashCode()
codes.Should().HaveCount(6);
}

[Theory]
[InlineData("")]
[InlineData("A")]
[InlineData("BC")]
[InlineData("DEF")]
[InlineData("GHIJ")]
[InlineData("KLMNO")]
[InlineData("PQRSTU")]
[InlineData("VWXYZAB")]
[InlineData("CDEFGHIJ")]
[InlineData("KLMNOPQRS")]
[InlineData("TUVWXYZABC")]
[InlineData("DEFGHIJKLMN")]
[InlineData("OPQRSTUVWXYZ")]
public void ParseFromString(string expected)
{
Str.Parse(expected).ToString().Should().Be(expected);
}

private static void TestEquals(Str x, Str y, bool expected)
{
x.Equals(y).Should().Be(expected);

0 comments on commit 5bc6661

Please sign in to comment.
You can’t perform that action at this time.