Skip to content

Commit

Permalink
Use Str.Parse in LetterBoxStr[Words] tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbymcr committed Apr 5, 2019
1 parent 5bc6661 commit bdfc8e0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 37 deletions.
15 changes: 1 addition & 14 deletions test/Words.Test/LetterBoxStrTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,7 @@ public void InputTooShort()

private static LetterBoxStr New()
{
Str box = default(Str)
.Append(Ch.A)
.Append(Ch.B)
.Append(Ch.C)
.Append(Ch.D)
.Append(Ch.E)
.Append(Ch.F)
.Append(Ch.G)
.Append(Ch.H)
.Append(Ch.I)
.Append(Ch.J)
.Append(Ch.K)
.Append(Ch.L);
return new LetterBoxStr(box);
return new LetterBoxStr(Str.Parse("ABCDEFGHIJKL"));
}
}
}
38 changes: 15 additions & 23 deletions test/Words.Test/LetterBoxStrWordsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void EmptyFindsNothing()
public void OneWordFindsNothing()
{
LetterBoxStrWords words = new LetterBoxStrWords();
words.Add(default(Str).Append(Ch.A).Append(Ch.L).Append(Ch.E), new LetterBoxStr.Vertices(0b100000010001));
words.Add(Str.Parse("ALE"), new LetterBoxStr.Vertices(0b100000010001));

FindSolutions(words).Should().BeEmpty();
}
Expand All @@ -31,8 +31,8 @@ public void OneWordFindsNothing()
public void TwoWordsInvalidSolutionFindsNothing()
{
LetterBoxStrWords words = new LetterBoxStrWords();
words.Add(default(Str).Append(Ch.A).Append(Ch.L).Append(Ch.E), new LetterBoxStr.Vertices(0b100000010001));
words.Add(default(Str).Append(Ch.E).Append(Ch.L).Append(Ch.F), new LetterBoxStr.Vertices(0b100000110000));
words.Add(Str.Parse("ALE"), new LetterBoxStr.Vertices(0b100000010001));
words.Add(Str.Parse("ELF"), new LetterBoxStr.Vertices(0b100000110000));

FindSolutions(words).Should().BeEmpty();
}
Expand All @@ -41,10 +41,8 @@ public void TwoWordsInvalidSolutionFindsNothing()
public void TwoWordsValidSolutionFindsOne()
{
LetterBoxStrWords words = new LetterBoxStrWords();
Str w1 = default(Str).Append(Ch.A).Append(Ch.D).Append(Ch.B).Append(Ch.E).Append(Ch.C).Append(Ch.F);
Str w2 = default(Str).Append(Ch.F).Append(Ch.G).Append(Ch.J).Append(Ch.H).Append(Ch.K).Append(Ch.I).Append(Ch.L);
words.Add(w1, new LetterBoxStr.Vertices(0b000000111111));
words.Add(w2, new LetterBoxStr.Vertices(0b111111100000));
words.Add(Str.Parse("ADBECF"), new LetterBoxStr.Vertices(0b000000111111));
words.Add(Str.Parse("FGJHKIL"), new LetterBoxStr.Vertices(0b111111100000));

FindSolutions(words).Should().BeEquivalentTo("ADBECF-FGJHKIL");
}
Expand All @@ -53,18 +51,12 @@ public void TwoWordsValidSolutionFindsOne()
public void ManyWordsFindsAllSolutions()
{
LetterBoxStrWords words = new LetterBoxStrWords();
Str w1 = default(Str).Append(Ch.A).Append(Ch.D).Append(Ch.B);
words.Add(w1, new LetterBoxStr.Vertices(0b000000001011));
Str w2 = default(Str).Append(Ch.A).Append(Ch.D).Append(Ch.B).Append(Ch.E).Append(Ch.C).Append(Ch.F);
words.Add(w2, new LetterBoxStr.Vertices(0b000000111111));
Str w3 = default(Str).Append(Ch.B).Append(Ch.E).Append(Ch.C).Append(Ch.F).Append(Ch.H).Append(Ch.J).Append(Ch.G).Append(Ch.K).Append(Ch.I).Append(Ch.L);
words.Add(w3, new LetterBoxStr.Vertices(0b111111111110));
Str w4 = default(Str).Append(Ch.F).Append(Ch.G).Append(Ch.J).Append(Ch.H).Append(Ch.K).Append(Ch.I).Append(Ch.L);
words.Add(w4, new LetterBoxStr.Vertices(0b111111100000));
Str w5 = default(Str).Append(Ch.F).Append(Ch.A).Append(Ch.H).Append(Ch.K).Append(Ch.I).Append(Ch.L).Append(Ch.J).Append(Ch.G);
words.Add(w5, new LetterBoxStr.Vertices(0b111111100001));
Str w6 = default(Str).Append(Ch.F).Append(Ch.A).Append(Ch.H).Append(Ch.K).Append(Ch.I).Append(Ch.L).Append(Ch.J);
words.Add(w6, new LetterBoxStr.Vertices(0b111110100001));
words.Add(Str.Parse("ADB"), new LetterBoxStr.Vertices(0b000000001011));
words.Add(Str.Parse("ADBECF"), new LetterBoxStr.Vertices(0b000000111111));
words.Add(Str.Parse("BECFHJGKIL"), new LetterBoxStr.Vertices(0b111111111110));
words.Add(Str.Parse("FGJHKIL"), new LetterBoxStr.Vertices(0b111111100000));
words.Add(Str.Parse("FAHKILJG"), new LetterBoxStr.Vertices(0b111111100001));
words.Add(Str.Parse("FAHKILJ"), new LetterBoxStr.Vertices(0b111110100001));

FindSolutions(words).Should().BeEquivalentTo("ADB-BECFHJGKIL", "ADBECF-FGJHKIL", "ADBECF-FAHKILJG");
}
Expand All @@ -76,19 +68,19 @@ public void CountsWords()

words.Count.Should().Be(0);

words.Add(default(Str).Append(Ch.A).Append(Ch.B), default(LetterBoxStr.Vertices));
words.Add(Str.Parse("AB"), default(LetterBoxStr.Vertices));

words.Count.Should().Be(1);

words.Add(default(Str).Append(Ch.A).Append(Ch.B), default(LetterBoxStr.Vertices));
words.Add(Str.Parse("AB"), default(LetterBoxStr.Vertices));

words.Count.Should().Be(1);

words.Add(default(Str).Append(Ch.A).Append(Ch.B).Append(Ch.C), default(LetterBoxStr.Vertices));
words.Add(Str.Parse("ABC"), default(LetterBoxStr.Vertices));

words.Count.Should().Be(2);

words.Add(default(Str).Append(Ch.B).Append(Ch.C).Append(Ch.D), default(LetterBoxStr.Vertices));
words.Add(Str.Parse("ABCD"), default(LetterBoxStr.Vertices));

words.Count.Should().Be(3);
}
Expand Down

0 comments on commit bdfc8e0

Please sign in to comment.