From a49763dd739c3c68c4a8322896d594e926ac8e6b Mon Sep 17 00:00:00 2001 From: Zhineng Li Date: Mon, 5 Jan 2026 16:26:11 +0800 Subject: first commit --- tests/SequenceTest.php | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/SequenceTest.php (limited to 'tests/SequenceTest.php') diff --git a/tests/SequenceTest.php b/tests/SequenceTest.php new file mode 100644 index 0000000..fc02d87 --- /dev/null +++ b/tests/SequenceTest.php @@ -0,0 +1,53 @@ +assertSame('sequence', $seq->name); + $this->assertSame(12, $seq->bits); + } + + public function testSequenceHasMakeFactoryMethod(): void + { + $seq = Sequence::make('sequence', 12); + $this->assertSame('sequence', $seq->name); + $this->assertSame(12, $seq->bits); + } + + public function testNextValueResolution(): void + { + $seq = new Sequence('sequence', 12); + $this->assertSame(0, $seq->next()); + $this->assertSame(1, $seq->next()); + $this->assertSame(2, $seq->next()); + } + + public function testExceptionShouldBeThrownWhenMaxValueExceeded(): void + { + $seq = new Sequence('sequence', 1); // Max value is 1 + $this->assertSame(0, $seq->next()); + $this->assertSame(1, $seq->next()); + $this->expectException(\OverflowException::class); + $this->expectExceptionMessage('Sequence "sequence" exceeded its maximum value of 1.'); + $seq->next(); + } + + public function testSequenceCanBeReset(): void + { + $seq = new Sequence('sequence', 12); + $this->assertSame(0, $seq->next()); + $this->assertSame(1, $seq->next()); + $this->assertSame(0, $seq->reset()->next()); + } +} -- cgit v1.2.3