You are here

public static function NumberTest::providerTestValidStepOffset in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/Utility/NumberTest.php \Drupal\Tests\Component\Utility\NumberTest::providerTestValidStepOffset()

Data provider for \Drupal\Tests\Component\Utility\NumberTest::testValidStepOffset().

See also

\Drupal\Tests\Component\Utility\NumberTest::testValidStepOffset()

File

core/tests/Drupal/Tests/Component/Utility/NumberTest.php, line 100

Class

NumberTest
Tests number manipulation utilities.

Namespace

Drupal\Tests\Component\Utility

Code

public static function providerTestValidStepOffset() {
  return [
    // Try obvious fits.
    [
      11.3,
      10.3,
      1,
      TRUE,
    ],
    [
      100,
      10,
      50,
      TRUE,
    ],
    [
      -100,
      90 / 7,
      -10,
      TRUE,
    ],
    [
      2 / 7 + 5 / 9,
      1 / 7,
      5 / 9,
      TRUE,
    ],
    // Ensure a small offset is still invalid.
    [
      10.3,
      10.3,
      0.0001,
      FALSE,
    ],
    [
      1 / 5,
      1 / 7,
      1 / 11,
      FALSE,
    ],
    // Try negative values and offsets.
    [
      1000,
      10,
      -5,
      FALSE,
    ],
    [
      -10,
      4,
      0,
      FALSE,
    ],
    [
      -10,
      4,
      -4,
      FALSE,
    ],
  ];
}