Skip to content

Commit 0a60e8c

Browse files
yet another simplification of data providers in tests
1 parent c9bdcae commit 0a60e8c

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

tests/APILengthCoDecTest.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function test__encodeLength($expected, $length)
4646
public function encodedLengthProvider(): array
4747
{
4848
// [encoded length value, length value]
49-
$default = [
49+
$result = [
5050
[0, 0], // Low limit value for 1 byte encoded length
5151
[0x39, 0x39], // Arbitrary median value for 1 byte encoded length
5252
[0x7f, 0x7F], // High limit value for 1 byte encoded length
@@ -64,17 +64,13 @@ public function encodedLengthProvider(): array
6464
[0xEFFFFFFF, 0xFFFFFFF], // High limit value for 4 bytes encoded length
6565
];
6666

67-
if (PHP_INT_SIZE < 8) {
68-
return $default;
67+
if (PHP_INT_SIZE > 4) {
68+
$result[] = [0xF010000000, 0x10000000]; // Low limit value for 5 bytes encoded length
69+
$result[] = [0xF10D4EF9C3, 0x10D4EF9C3]; // Arbitrary median value for 5 bytes encoded length
70+
$result[] = [0xF7FFFFFFFF, 0x7FFFFFFFF]; // High limit value for 5 bytes encoded length
6971
}
7072

71-
$append = [
72-
[0xF010000000, 0x10000000], // Low limit value for 5 bytes encoded length
73-
[0xF10D4EF9C3, 0x10D4EF9C3], // Arbitrary median value for 5 bytes encoded length
74-
[0xF7FFFFFFFF, 0x7FFFFFFFF], // High limit value for 5 bytes encoded length
75-
];
76-
77-
return array_merge($default, $append);
73+
return $result;
7874
}
7975

8076
/**

tests/Helpers/BinaryStringHelperTest.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function test__IntegerToNBOBinaryString($value, $expected)
2424

2525
public function IntegerToNBOBinaryStringProvider(): array
2626
{
27-
$default = [
27+
$result = [
2828
[0, chr(0)], // lower boundary value
2929
[0xFFFFFFFF, chr(0xFF) . chr(0xFF) . chr(0xFF) . chr(0xFF)], // 32 bits maximal value
3030

@@ -38,16 +38,12 @@ public function IntegerToNBOBinaryStringProvider(): array
3838
[0x390DDD99, chr(0x39) . chr(0x0D) . chr(0xDD) . chr(0x99)],
3939
];
4040

41-
if (PHP_INT_SIZE < 8) {
42-
return $default;
43-
}
44-
45-
$append = [
41+
if (PHP_INT_SIZE > 4) {
4642
// -1 is encoded with 0xFFFFFFF.....
4743
// 64 bits maximal value (on a 64 bits system only)
48-
[-1, chr(0xFF) . chr(0xFF) . chr(0xFF) . chr(0xFF) . chr(0xFF) . chr(0xFF) . chr(0xFF) . chr(0xFF)], // 64 bits upper boundary value
49-
];
44+
$result[] = [-1, chr(0xFF) . chr(0xFF) . chr(0xFF) . chr(0xFF) . chr(0xFF) . chr(0xFF) . chr(0xFF) . chr(0xFF)]; // 64 bits upper boundary value
45+
}
5046

51-
return array_merge($default, $append);
47+
return $result;
5248
}
5349
}

0 commit comments

Comments
 (0)