Skip to content

Commit 0be7a76

Browse files
author
nejc
committed
fix: align ByteTest to expect OutOfRangeException for invalid byte values
1 parent 947a9bf commit 0be7a76

File tree

99 files changed

+4322
-847
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+4322
-847
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ yarn-error.log
1919
/.vscode
2020
vendor
2121
vendor/
22-
composer.lock
22+
composer.lock
23+
todo.txt

Tests/ByteSliceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace Nejcc\PhpDatatypes\Tests;
@@ -7,7 +8,7 @@
78
use Nejcc\PhpDatatypes\Exceptions\InvalidByteException;
89
use PHPUnit\Framework\TestCase;
910

10-
class ByteSliceTest extends TestCase
11+
final class ByteSliceTest extends TestCase
1112
{
1213
/**
1314
* Test creating a valid ByteSlice instance.
@@ -128,4 +129,3 @@ public function testEmptyByteSlice(): void
128129
$this->assertCount(0, $byteSlice);
129130
}
130131
}
131-

Tests/ByteTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
use Nejcc\PhpDatatypes\Scalar\Byte;
88
use PHPUnit\Framework\TestCase;
99

10-
class ByteTest extends TestCase
10+
final class ByteTest extends TestCase
1111
{
1212
/**
1313
* Test that the constructor throws an exception when the value is out of range.
1414
*/
15-
public function testConstructorThrowsExceptionOnInvalidValue()
15+
public function testConstructorThrowsExceptionOnInvalidValue(): void
1616
{
17-
$this->expectException(\InvalidArgumentException::class);
18-
new Byte(300); // Out of range value
17+
$this->expectException(\OutOfRangeException::class);
18+
new Byte(300);
1919
}
2020

2121
/**

Tests/CharTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Nejcc\PhpDatatypes\Scalar\Char;
88
use PHPUnit\Framework\TestCase;
99

10-
class CharTest extends TestCase
10+
final class CharTest extends TestCase
1111
{
1212
/**
1313
* Test that the constructor throws an exception for a string longer than 1 character.

Tests/DictionaryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace Nejcc\PhpDatatypes\Tests;
@@ -8,7 +9,7 @@
89
use OutOfBoundsException;
910
use PHPUnit\Framework\TestCase;
1011

11-
class DictionaryTest extends TestCase
12+
final class DictionaryTest extends TestCase
1213
{
1314
public function testCanInitializeWithElements()
1415
{

Tests/FloatArrayTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace Nejcc\PhpDatatypes\Tests;
@@ -7,10 +8,11 @@
78
use Nejcc\PhpDatatypes\Exceptions\InvalidFloatException;
89
use PHPUnit\Framework\TestCase;
910

10-
class FloatArrayTest extends TestCase
11+
final class FloatArrayTest extends TestCase
1112
{
1213
/**
1314
* Test creating a valid FloatArray instance.
15+
*
1416
* @throws InvalidFloatException
1517
*/
1618
public function testCreateValidFloatArray(): void
@@ -32,6 +34,7 @@ public function testCreateInvalidFloatArray(): void
3234

3335
/**
3436
* Test adding floats to a FloatArray.
37+
*
3538
* @throws InvalidFloatException
3639
*/
3740
public function testAddFloats(): void
@@ -44,6 +47,7 @@ public function testAddFloats(): void
4447

4548
/**
4649
* Test removing floats from a FloatArray.
50+
*
4751
* @throws InvalidFloatException
4852
*/
4953
public function testRemoveFloats(): void
@@ -56,6 +60,7 @@ public function testRemoveFloats(): void
5660

5761
/**
5862
* Test calculating the sum of floats.
63+
*
5964
* @throws InvalidFloatException
6065
*/
6166
public function testSumOfFloats(): void
@@ -66,6 +71,7 @@ public function testSumOfFloats(): void
6671

6772
/**
6873
* Test calculating the average of floats.
74+
*
6975
* @throws InvalidFloatException
7076
*/
7177
public function testAverageOfFloats(): void
@@ -88,6 +94,7 @@ public function testAverageOfEmptyFloatArray(): void
8894

8995
/**
9096
* Test getting the count of floats in a FloatArray.
97+
*
9198
* @throws InvalidFloatException
9299
*/
93100
public function testGetFloatCount(): void
@@ -98,6 +105,7 @@ public function testGetFloatCount(): void
98105

99106
/**
100107
* Test ArrayAccess implementation for accessing a float at a specific index.
108+
*
101109
* @throws InvalidFloatException
102110
*/
103111
public function testArrayAccessGet(): void
@@ -133,6 +141,7 @@ public function testArrayAccessUnsetThrowsException(): void
133141

134142
/**
135143
* Test iterating over FloatArray with IteratorAggregate.
144+
*
136145
* @throws InvalidFloatException
137146
*/
138147
public function testIterationOverFloatArray(): void
@@ -149,6 +158,7 @@ public function testIterationOverFloatArray(): void
149158

150159
/**
151160
* Test creating an empty FloatArray.
161+
*
152162
* @throws InvalidFloatException
153163
*/
154164
public function testEmptyFloatArray(): void

Tests/Floats/Float64Test.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Nejcc\PhpDatatypes\Tests;
66

7-
87
use Nejcc\PhpDatatypes\Scalar\FloatingPoints\Float64;
98
use PHPUnit\Framework\TestCase;
109

Tests/HttpStatusCodeTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace Nejcc\PhpDatatypes\Tests;
4-
3+
declare(strict_types=1);
54

5+
namespace Nejcc\PhpDatatypes\Tests;
66

77
use Nejcc\PhpDatatypes\Enums\Http\HttpStatusCode;
88
use PHPUnit\Framework\TestCase;
99

10-
class HttpStatusCodeTest extends TestCase
10+
final class HttpStatusCodeTest extends TestCase
1111
{
1212
public function testIsInformational()
1313
{

Tests/IntArrayTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Nejcc\PhpDatatypes\Composite\Arrays\IntArray;
66
use PHPUnit\Framework\TestCase;
77

8-
class IntArrayTest extends TestCase
8+
final class IntArrayTest extends TestCase
99
{
1010
public function testConstructionAndGet(): void
1111
{
@@ -77,4 +77,4 @@ public function testAppendInvalidType(): void
7777
$this->expectException(\TypeError::class);
7878
$arr->append('not an int');
7979
}
80-
}
80+
}

Tests/Integers/Signed/Int16Test.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44

55
namespace Nejcc\PhpDatatypes\Tests\Integers\Signed;
66

7-
87
use Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16;
98
use PHPUnit\Framework\TestCase;
109

11-
class Int16Test extends TestCase
10+
final class Int16Test extends TestCase
1211
{
1312
public function testValidInitialization()
1413
{

0 commit comments

Comments
 (0)