Skip to content

Commit fca0109

Browse files
committed
adjust text cases and tests to match problem specs
1 parent 895eb33 commit fca0109

2 files changed

Lines changed: 40 additions & 37 deletions

File tree

exercises/practice/grains/.meta/tests.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@
33
# so comments can be added in a "comment" key.
44

55
[9fbde8de-36b2-49de-baf2-cd42d6f28405]
6-
description = "1"
6+
description = "grains on square 1"
77

88
[ee1f30c2-01d8-4298-b25d-c677331b5e6d]
9-
description = "2"
9+
description = "grains on square 2"
1010

1111
[10f45584-2fc3-4875-8ec6-666065d1163b]
12-
description = "3"
12+
description = "grains on square 3"
1313

1414
[a7cbe01b-36f4-4601-b053-c5f6ae055170]
15-
description = "4"
15+
description = "grains on square 4"
1616

1717
[c50acc89-8535-44e4-918f-b848ad2817d4]
18-
description = "16"
18+
description = "grains on square 16"
1919

2020
[acd81b46-c2ad-4951-b848-80d15ed5a04f]
21-
description = "32"
21+
description = "grains on square 32"
2222

2323
[c73b470a-5efb-4d53-9ac6-c5f6487f227b]
24-
description = "64"
24+
description = "grains on square 64"
2525

2626
[1d47d832-3e85-4974-9466-5bd35af484e3]
27-
description = "square 0 raises an exception"
27+
description = "square 0 is invalid"
2828

2929
[61974483-eeb2-465e-be54-ca5dde366453]
30-
description = "negative square raises an exception"
30+
description = "negative square is invalid"
3131

3232
[a95e4374-f32c-45a7-a10d-ffec475c012f]
33-
description = "square greater than 64 raises an exception"
33+
description = "square greater than 64 is invalid"
3434

3535
[6eb07385-3659-4b45-a6be-9dc474222750]
3636
description = "returns the total number of grains on the board"

exercises/practice/grains/GrainsTest.php

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,99 +23,102 @@ public static function setUpBeforeClass(): void
2323
* Don't use gmp or any other similar libraries.
2424
* Try to make the solution for virtually any board size.
2525
*/
26-
26+
2727
/**
2828
* uuid: 9fbde8de-36b2-49de-baf2-cd42d6f28405
2929
*/
30-
#[TestDox('1')]
31-
public function testInput1(): void
30+
#[TestDox('grains on square 1')]
31+
public function testGrainsOnSquare1(): void
3232
{
33-
$this->assertSame('1', square(1));
33+
$this->assertSame(1, square(1));
3434
}
3535

3636
/**
3737
* uuid: ee1f30c2-01d8-4298-b25d-c677331b5e6d
3838
*/
39-
#[TestDox('2')]
40-
public function testInput2(): void
39+
#[TestDox('grains on square 2')]
40+
public function testGrainsOnSquare2(): void
4141
{
42-
$this->assertSame('2', square(2));
42+
$this->assertSame(2, square(2));
4343
}
4444

4545
/**
4646
* uuid: 10f45584-2fc3-4875-8ec6-666065d1163b
4747
*/
48-
#[TestDox('3')]
49-
public function testInput3(): void
48+
#[TestDox('grains on square 3')]
49+
public function testGrainsOnSquare3(): void
5050
{
51-
$this->assertSame('4', square(3));
51+
$this->assertSame(4, square(3));
5252
}
5353

5454
/**
5555
* uuid: a7cbe01b-36f4-4601-b053-c5f6ae055170
5656
*/
57-
#[TestDox('4')]
58-
public function testInput4(): void
57+
#[TestDox('grains on square 4')]
58+
public function testGrainsOnSquare4(): void
5959
{
60-
$this->assertSame('8', square(4));
60+
$this->assertSame(8, square(4));
6161
}
6262

6363
/**
6464
* uuid: c50acc89-8535-44e4-918f-b848ad2817d4
6565
*/
66-
#[TestDox('16')]
67-
public function testInput16(): void
66+
#[TestDox('grains on square 16')]
67+
public function testGrainsOnSquare16(): void
6868
{
69-
$this->assertSame('32768', square(16));
69+
$this->assertSame(32768, square(16));
7070
}
7171

7272
/**
7373
* uuid: acd81b46-c2ad-4951-b848-80d15ed5a04f
7474
*/
75-
#[TestDox('32')]
76-
public function testInput32(): void
75+
#[TestDox('grains on square 32')]
76+
public function testGrainsOnSquare32(): void
7777
{
78-
$this->assertSame('2147483648', square(32));
78+
$this->assertSame(2147483648, square(32));
7979
}
8080

8181
/**
8282
* uuid: c73b470a-5efb-4d53-9ac6-c5f6487f227b
8383
*/
84-
#[TestDox('64')]
85-
public function testInput64(): void
84+
#[TestDox('grains on square 64')]
85+
public function testGrainsOnSquare64(): void
8686
{
87-
$this->assertSame('9223372036854775808', square(64));
87+
$this->assertSame(9223372036854775808, square(64));
8888
}
8989

9090
/**
9191
* uuid: 1d47d832-3e85-4974-9466-5bd35af484e3
9292
*/
93-
#[TestDox('square 0 raises an exception')]
94-
public function testRejectsZero(): void
93+
#[TestDox('square 0 is invalid')]
94+
public function testSquare0IsInvalid(): void
9595
{
9696
$this->expectException(InvalidArgumentException::class);
97+
$this->expectExceptionMessage('square must be between 1 and 64');
9798

9899
square(0);
99100
}
100101

101102
/**
102103
* uuid: 61974483-eeb2-465e-be54-ca5dde366453
103104
*/
104-
#[TestDox('negative square raises an exception')]
105+
#[TestDox('negative square is invalid')]
105106
public function testRejectsNegative(): void
106107
{
107108
$this->expectException(InvalidArgumentException::class);
109+
$this->expectExceptionMessage('square must be between 1 and 64');
108110

109111
square(-1);
110112
}
111113

112114
/**
113115
* uuid: a95e4374-f32c-45a7-a10d-ffec475c012f
114116
*/
115-
#[TestDox('square greater than 64 raises an exception')]
117+
#[TestDox('square greater than 64 is invalid')]
116118
public function testRejectsGreaterThan64(): void
117119
{
118120
$this->expectException(InvalidArgumentException::class);
121+
$this->expectExceptionMessage('square must be between 1 and 64');
119122

120123
square(65);
121124
}
@@ -126,6 +129,6 @@ public function testRejectsGreaterThan64(): void
126129
#[TestDox('returns the total number of grains on the board')]
127130
public function testTotal(): void
128131
{
129-
$this->assertSame('18446744073709551615', total());
132+
$this->assertSame(18446744073709551615, total());
130133
}
131134
}

0 commit comments

Comments
 (0)