Skip to content

Commit

Permalink
Merge branch 'rpottsoh/updatePangram' (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpottsoh committed Jun 30, 2019
2 parents c2ac6ad + 2775dfd commit 2207cd2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 33 deletions.
15 changes: 5 additions & 10 deletions exercises/pangram/uPangramExample.pas
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,21 @@ interface
uses
System.Generics.Collections;

function isPangram(aWords: string): Boolean;
function isPangram(const aWords: string): Boolean;

implementation
uses SysUtils;

function isPangram(aWords: string): Boolean;
function isPangram(const aWords: string): Boolean;
const
CAlphabetLength = 26;
CFirstLetter = 'a';
CLastLetter = 'z';
var
Letters: TList<char>;
lChar: char;
begin
result := false;
Letters := TList<char>.Create;
Letters.Clear;
var Letters := TList<char>.Create;
try
for lChar in aWords.ToLowerInvariant do
if (lChar in [CFirstLetter..CLastLetter]) and not Letters.Contains(lChar) then
for var lChar in aWords.ToLowerInvariant do
if CharInSet(lChar, [CFirstLetter..CLastLetter]) and not Letters.Contains(lChar) then
Letters.Add(lChar);
result := Letters.Count = CAlphabetLength;
finally
Expand Down
46 changes: 23 additions & 23 deletions exercises/pangram/uPangramTests.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5,109 +5,109 @@ interface
DUnitX.TestFramework;

const
CanonicalVersion = '1.4.0';
CanonicalVersion = '2.0.0';

type

[TestFixture]
PangramTests = class(TObject)
[TestFixture('isPangram')]
TPangramTests = class(TObject)
public
[Test]
// [Ignore('Comment the "[Ignore]" statement to run the test')]
procedure sentence_empty;
procedure empty_sentence;

[Test]
[Ignore]
procedure recognizes_a_perfect_lower_case_pangram;
procedure perfect_lower_case;

[Test]
[Ignore]
procedure pangram_with_only_lower_case;
procedure only_lower_case;

[Test]
[Ignore]
procedure missing_character_x;
procedure missing_the_letter_x;

[Test]
[Ignore]
procedure another_missing_character_h;
procedure missing_the_letter_h;

[Test]
[Ignore]
procedure pangram_with_underscores;
procedure with_underscores;

[Test]
[Ignore]
procedure pangram_with_numbers;
procedure with_numbers;

[Test]
[Ignore]
procedure missing_letters_replaced_by_numbers;

[Test]
[Ignore]
procedure pangram_with_mixed_case_and_punctuation;
procedure mixed_case_and_punctuation;

[Test]
[Ignore]
procedure upper_and_lower_case_versions_of_the_same_character_should_not_be_counted_separately;
procedure case_insensitive;
end;

implementation
uses SysUtils, uPangram;

{ PangramTests }

procedure PangramTests.sentence_empty;
procedure TPangramTests.empty_sentence;
begin
Assert.IsFalse(isPangram(''));
end;

procedure PangramTests.recognizes_a_perfect_lower_case_pangram;
procedure TPangramTests.perfect_lower_case;
begin
Assert.IsTrue(isPangram('abcdefghijklmnopqrstuvwxyz'));
end;

procedure PangramTests.pangram_with_only_lower_case;
procedure TPangramTests.only_lower_case;
begin
Assert.IsTrue(isPangram('the quick brown fox jumps over the lazy dog'));
end;

procedure PangramTests.missing_character_x;
procedure TPangramTests.missing_the_letter_x;
begin
Assert.IsFalse(isPangram('a quick movement of the enemy will jeopardize five gunboats'));
end;

procedure PangramTests.another_missing_character_h;
procedure TPangramTests.missing_the_letter_h;
begin
Assert.IsFalse(isPangram('five boxing wizards jump quickly at it'));
end;

procedure PangramTests.pangram_with_underscores;
procedure TPangramTests.with_underscores;
begin
Assert.IsTrue(isPangram('the_quick_brown_fox_jumps_over_the_lazy_dog'));
end;

procedure PangramTests.pangram_with_numbers;
procedure TPangramTests.with_numbers;
begin
Assert.IsTrue(isPangram('the 1 quick brown fox jumps over the 2 lazy dogs'));
end;

procedure PangramTests.missing_letters_replaced_by_numbers;
procedure TPangramTests.missing_letters_replaced_by_numbers;
begin
Assert.IsFalse(isPangram('7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog'));
end;

procedure PangramTests.pangram_with_mixed_case_and_punctuation;
procedure TPangramTests.mixed_case_and_punctuation;
begin
Assert.IsTrue(isPangram('Five quacking Zephyrs jolt my wax bed.'));
end;

procedure PangramTests.upper_and_lower_case_versions_of_the_same_character_should_not_be_counted_separately;
procedure TPangramTests.case_insensitive;
begin
Assert.IsFalse(isPangram('the quick brown fox jumps over with lazy FX'));
end;

initialization
TDUnitX.RegisterTestFixture(PangramTests);
TDUnitX.RegisterTestFixture(TPangramTests);
end.

0 comments on commit 2207cd2

Please sign in to comment.