1
exercism fetch delphi armstrong-numbers

uArmstrongNumbersTests.pas

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
unit uArmstrongNumbersTests;

interface
uses
  DUnitX.TestFramework;

const
  CanonicalVersion = '1.0.0';

type

  [TestFixture]
  ArmstrongNumbersTests = class(TObject) 
  public
    [Test]
//    [Ignore('Comment the "[Ignore]" statement to run the test')]
    procedure Single_digit_numbers_are_Armstrong_numbers;

    [Test]
    [Ignore]
    procedure There_are_no_2_digit_Armstrong_numbers;

    [Test]
    [Ignore]
    procedure Three_digit_number_that_is_an_Armstrong_number;

    [Test]
    [Ignore]
    procedure Three_digit_number_that_is_not_an_Armstrong_number;

    [Test]
    [Ignore]
    procedure Four_digit_number_that_is_an_Armstrong_number;

    [Test]
    [Ignore]
    procedure Four_digit_number_that_is_not_an_Armstrong_number;

    [Test]
    [Ignore]
    procedure Seven_digit_number_that_is_an_Armstrong_number;

    [Test]
    [Ignore]
    procedure Seven_digit_number_that_is_not_an_Armstrong_number;
  end;

implementation
uses uArmstrongNumbers;

{ ArmstrongNumbersTests }

procedure ArmstrongNumbersTests.Four_digit_number_that_is_an_Armstrong_number;
begin
  Assert.IsTrue(isArmstrongNumber(9474));
end;

procedure ArmstrongNumbersTests.Four_digit_number_that_is_not_an_Armstrong_number;
begin
  Assert.IsFalse(isArmstrongNumber(9475));
end;

procedure ArmstrongNumbersTests.Seven_digit_number_that_is_an_Armstrong_number;
begin
  Assert.IsTrue(isArmstrongNumber(9926315));
end;

procedure ArmstrongNumbersTests.Seven_digit_number_that_is_not_an_Armstrong_number;
begin
  Assert.IsFalse(isArmstrongNumber(9926314));
end;

procedure ArmstrongNumbersTests.Single_digit_numbers_are_Armstrong_numbers;
var
  i: integer;
begin
  for i := 0 to 9 do
    Assert.IsTrue(isArmstrongNumber(i));
end;

procedure ArmstrongNumbersTests.There_are_no_2_digit_Armstrong_numbers;
var
  i: integer;
begin
  for i := 10 to 99 do
    Assert.IsFalse(isArmstrongNumber(i));
end;

procedure ArmstrongNumbersTests.Three_digit_number_that_is_an_Armstrong_number;
begin
  Assert.IsTrue(isArmstrongNumber(153));
end;

procedure ArmstrongNumbersTests.Three_digit_number_that_is_not_an_Armstrong_number;
begin
  Assert.IsFalse(isArmstrongNumber(100));
end;

initialization
  TDUnitX.RegisterTestFixture(ArmstrongNumbersTests);
end.