diff --git a/tests/Colors/Cmyk/ChannelTest.php b/tests/Colors/Cmyk/ChannelTest.php new file mode 100644 index 00000000..44928abf --- /dev/null +++ b/tests/Colors/Cmyk/ChannelTest.php @@ -0,0 +1,48 @@ +assertInstanceOf(Channel::class, $channel); + } + + public function testValue(): void + { + $channel = new Channel(10); + $this->assertEquals(10, $channel->value()); + } + + public function testNormalize(): void + { + $channel = new Channel(100); + $this->assertEquals(1, $channel->normalize()); + $channel = new Channel(0); + $this->assertEquals(0, $channel->normalize()); + $channel = new Channel(20); + $this->assertEquals(.2, $channel->normalize()); + } + + public function testValidate(): void + { + $this->expectException(ColorException::class); + new Channel(101); + + $this->expectException(ColorException::class); + new Channel(-1); + } +} diff --git a/tests/Colors/Rgb/ChannelTest.php b/tests/Colors/Rgb/ChannelTest.php new file mode 100644 index 00000000..4cc2fadb --- /dev/null +++ b/tests/Colors/Rgb/ChannelTest.php @@ -0,0 +1,47 @@ +assertInstanceOf(Channel::class, $channel); + } + + public function testValue(): void + { + $channel = new Channel(10); + $this->assertEquals(10, $channel->value()); + } + + public function testNormalize(): void + { + $channel = new Channel(255); + $this->assertEquals(1, $channel->normalize()); + $channel = new Channel(0); + $this->assertEquals(0, $channel->normalize()); + $channel = new Channel(51); + $this->assertEquals(.2, $channel->normalize()); + } + + public function testValidate(): void + { + $this->expectException(ColorException::class); + new Channel(256); + + $this->expectException(ColorException::class); + new Channel(-1); + } +} diff --git a/tests/Colors/Rgba/ChannelTest.php b/tests/Colors/Rgba/ChannelTest.php new file mode 100644 index 00000000..a1144e40 --- /dev/null +++ b/tests/Colors/Rgba/ChannelTest.php @@ -0,0 +1,48 @@ +assertInstanceOf(Channel::class, $channel); + } + + public function testValue(): void + { + $channel = new Channel(10); + $this->assertEquals(10, $channel->value()); + } + + public function testNormalize(): void + { + $channel = new Channel(255); + $this->assertEquals(1, $channel->normalize()); + $channel = new Channel(0); + $this->assertEquals(0, $channel->normalize()); + $channel = new Channel(51); + $this->assertEquals(.2, $channel->normalize()); + } + + public function testValidate(): void + { + $this->expectException(ColorException::class); + new Channel(256); + + $this->expectException(ColorException::class); + new Channel(-1); + } +}