Skip to content

Commit 630bfa7

Browse files
committed
wip
refactor tree init starting point in classes no additional functionalities added for now
1 parent 02dfff8 commit 630bfa7

File tree

12 files changed

+40
-105
lines changed

12 files changed

+40
-105
lines changed

.idea/php-datatypes.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/Floats/Float32Test.php renamed to Tests/Floats/Float32Test.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Nejcc\PhpDatatypes\Tests;
5+
namespace Nejcc\PhpDatatypes\Tests\Floats;
66

77
use Nejcc\PhpDatatypes\Scalar\FloatingPoints\Float32;
88
use PHPUnit\Framework\TestCase;
@@ -11,13 +11,17 @@ final class Float32Test extends TestCase
1111
{
1212
public function testSetAndGetValue(): void
1313
{
14-
$float = new Float32(1.234567e10);
14+
$float = float32(1.234567e10);
1515
$this->assertEquals(1.234567e10, $float->getValue());
1616
}
1717

1818
public function testOutOfRangeException(): void
1919
{
20+
// Expect the exception to be thrown before the code that triggers it.
2021
$this->expectException(\OutOfRangeException::class);
21-
new Float32(4.0e38); // Value out of Float32 range
22+
23+
// Now trigger the exception with an out-of-range value.
24+
\float32(4.0e38); // This value is beyond Float32's range.
2225
}
26+
2327
}
File renamed without changes.

tests/Integers/Signed/Int16Test.php renamed to Tests/Integers/Signed/Int16Test.php

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,124 +4,125 @@
44

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

7-
use Nejcc\PhpDatatypes\Interfaces\IntegerInterface;
7+
8+
use Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16;
89
use PHPUnit\Framework\TestCase;
910

1011
class Int16Test extends TestCase
1112
{
1213
public function testValidInitialization()
1314
{
14-
$int16 = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(32767);
15+
$int16 = new Int16(32767);
1516
$this->assertSame(32767, $int16->getValue());
1617
}
1718

1819
public function testInvalidInitialization()
1920
{
2021
$this->expectException(\OutOfRangeException::class);
21-
new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(32768);
22+
new Int16(32768);
2223
}
2324

2425
public function testAdditionWithinBounds()
2526
{
26-
$int16a = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(20000);
27-
$int16b = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(12767);
27+
$int16a = new Int16(20000);
28+
$int16b = new Int16(12767);
2829
$int16c = $int16a->add($int16b);
2930
$this->assertSame(32767, $int16c->getValue());
3031
}
3132

3233
public function testAdditionOverflow()
3334
{
3435
$this->expectException(\OverflowException::class);
35-
$int16a = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(30000);
36-
$int16b = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(5000);
36+
$int16a = new Int16(30000);
37+
$int16b = new Int16(5000);
3738
$int16a->add($int16b);
3839
}
3940

4041
public function testSubtractionWithinBounds()
4142
{
42-
$int16a = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(-20000);
43-
$int16b = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(-12767);
43+
$int16a = new Int16(-20000);
44+
$int16b = new Int16(-12767);
4445
$int16c = $int16a->subtract($int16b);
4546
$this->assertSame(-7233, $int16c->getValue());
4647
}
4748

4849
public function testSubtractionUnderflow()
4950
{
5051
$this->expectException(\UnderflowException::class);
51-
$int16a = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(-30000);
52-
$int16b = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(5000);
52+
$int16a = new Int16(-30000);
53+
$int16b = new Int16(5000);
5354
$int16a->subtract($int16b);
5455
}
5556

5657
public function testMultiplicationWithinBounds()
5758
{
58-
$int16a = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(150);
59-
$int16b = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(200);
59+
$int16a = new Int16(150);
60+
$int16b = new Int16(200);
6061
$int16c = $int16a->multiply($int16b);
6162
$this->assertSame(30000, $int16c->getValue());
6263
}
6364

6465
public function testMultiplicationOverflow()
6566
{
6667
$this->expectException(\OverflowException::class);
67-
$int16a = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(500);
68-
$int16b = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(100);
68+
$int16a = new Int16(500);
69+
$int16b = new Int16(100);
6970
$int16a->multiply($int16b);
7071
}
7172

7273
public function testDivisionWithinBounds()
7374
{
74-
$int16a = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(32766);
75-
$int16b = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(2);
75+
$int16a = new Int16(32766);
76+
$int16b = new Int16(2);
7677
$int16c = $int16a->divide($int16b);
7778
$this->assertSame(16383, $int16c->getValue());
7879
}
7980

8081
public function testDivisionByZero()
8182
{
8283
$this->expectException(\DivisionByZeroError::class);
83-
$int16a = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(10000);
84-
$int16b = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(0);
84+
$int16a = new Int16(10000);
85+
$int16b = new Int16(0);
8586
$int16a->divide($int16b);
8687
}
8788

8889
public function testDivisionResultNotInteger()
8990
{
9091
$this->expectException(\UnexpectedValueException::class);
91-
$int16a = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(5);
92-
$int16b = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(2);
92+
$int16a = new Int16(5);
93+
$int16b = new Int16(2);
9394
$int16a->divide($int16b);
9495
}
9596

9697
public function testModulusWithinBounds()
9798
{
98-
$int16a = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(32767);
99-
$int16b = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(10000);
99+
$int16a = new Int16(32767);
100+
$int16b = new Int16(10000);
100101
$int16c = $int16a->mod($int16b);
101102
$this->assertSame(2767, $int16c->getValue());
102103
}
103104

104105
public function testEquality()
105106
{
106-
$int16a = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(12345);
107-
$int16b = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(12345);
107+
$int16a = new Int16(12345);
108+
$int16b = new Int16(12345);
108109
$this->assertTrue($int16a->equals($int16b));
109110
}
110111

111112
public function testInequality()
112113
{
113-
$int16a = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(12345);
114-
$int16b = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(30000);
114+
$int16a = new Int16(12345);
115+
$int16b = new Int16(30000);
115116
$this->assertFalse($int16a->equals($int16b));
116117
}
117118

118119
public function testComparison()
119120
{
120-
$int16a = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(12345);
121-
$int16b = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(30000); // Valid value within range
121+
$int16a = new Int16(12345);
122+
$int16b = new Int16(30000); // Valid value within range
122123
$this->assertSame(-1, $int16a->compare($int16b));
123124
$this->assertSame(1, $int16b->compare($int16a));
124-
$int16c = new \Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int16(12345);
125+
$int16c = new Int16(12345);
125126
$this->assertSame(0, $int16a->compare($int16c));
126127
}
127128
}

tests/Integers/Signed/Int32Test.php renamed to Tests/Integers/Signed/Int32Test.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\Integers\Signed;
66

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

tests/Integers/Signed/Int8Test.php renamed to Tests/Integers/Signed/Int8Test.php

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

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

7-
use Nejcc\PhpDatatypes\Interfaces\IntegerInterface;
7+
88
use Nejcc\PhpDatatypes\Scalar\Integers\Signed\Int8;
99
use PHPUnit\Framework\TestCase;
1010

tests/Floats/Float128Test.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)