Skip to content

Commit

Permalink
Refactor Legacy\PositiveNotationTest to Feature\test
Browse files Browse the repository at this point in the history
  • Loading branch information
danon committed Jun 30, 2023
1 parent 867dfa6 commit d617344
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 262 deletions.
30 changes: 27 additions & 3 deletions test/Feature/CleanRegex/match/_integer/isInt/DetailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ public function shouldBeIntegerBase10(string $string, int $expected)
$this->assertTrue($detail->isInt());
}

/**
* @test
* @dataProvider integers
*/
public function shouldBeIntegerGivenBase(string $input, int $expected, int $base)
{
// given
$detail = $this->detail($input);
// when, then
$this->assertTrue($detail->isInt($base));
}

/**
* @test
*/
Expand Down Expand Up @@ -124,12 +136,24 @@ public function shouldNotBeIntegerMalformed(int $base, string $text)
* @test
* @dataProvider cornerDigits
*/
public function shouldNotBeIntegerCornerDigit(int $base, string $text)
public function shouldBeIntegerCornerDigit(string $cornerDigit, int $value, int $base)
{
// given
$detail = $this->detail($text);
$detail = $this->detail($cornerDigit);
// when, then
$this->assertFalse($detail->isInt($base));
$this->assertTrue($detail->isInt($base));
}

/**
* @test
* @dataProvider cornerDigits
*/
public function shouldNotBeIntegerAboveCornerDigit(string $cornerDigit, int $value, int $base)
{
// given
$detail = $this->detail($cornerDigit);
// when, then
$this->assertFalse($detail->isInt($base - 1));
}

/**
Expand Down
32 changes: 28 additions & 4 deletions test/Feature/CleanRegex/match/_integer/toInt/DetailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ public function shouldParseIntegerBase10(string $string, int $expected)
$this->assertSame($expected, $detail->toInt());
}

/**
* @test
* @dataProvider integers
*/
public function shouldBeIntegerGivenBase(string $input, int $expected, int $base)
{
// given
$detail = $this->detail($input);
// when, then
$this->assertSame($expected, $detail->toInt($base));
}

/**
* @test
*/
Expand Down Expand Up @@ -141,15 +153,27 @@ public function shouldThrowForIntegerMalformed(int $base, string $text)
* @test
* @dataProvider cornerDigits
*/
public function shouldThrowForCornerDigit(int $base, string $text)
public function shouldParseIntegerCornerDigit(string $cornerDigit, int $value, int $base)
{
// given
$detail = $this->detail($text);
$detail = $this->detail($cornerDigit);
// when, then
$this->assertEquals($value, $detail->toInt($base));
}

/**
* @test
* @dataProvider cornerDigits
*/
public function shouldThrowForAboveCornerDigit(string $cornerDigit, int $value, int $base)
{
// given
$detail = $this->detail($cornerDigit);
// then
$this->expectException(IntegerFormatException::class);
$this->expectExceptionMessage("Expected to parse '$text', but it is not a valid integer in base $base");
$this->expectExceptionMessage("Expected to parse '$cornerDigit', but it is not a valid integer in base " . ($base - 1));
// when
$detail->toInt($base);
$detail->toInt($base - 1);
}

/**
Expand Down
251 changes: 0 additions & 251 deletions test/Legacy/CleanRegex/Internal/Numeral/PositiveNotationTest.php

This file was deleted.

Loading

0 comments on commit d617344

Please sign in to comment.