Esempio n. 1
0
 public function testBoxAByteUnit()
 {
     $byteUnitInMetricSystem = Metric::bytes(42);
     $byteUnitInBinarySystem = Binary::bytes(42);
     $this->assertEquals($byteUnitInMetricSystem, box($byteUnitInMetricSystem));
     $this->assertEquals($byteUnitInBinarySystem, box($byteUnitInBinarySystem));
 }
Esempio n. 2
0
 public function testAutoboxing()
 {
     $this->assertTrue(Metric::bytes(1)->isEqualTo(1));
     $this->assertTrue(Metric::bytes(1)->isEqualTo('1B'));
     $this->assertTrue(Metric::bytes(1)->isGreaterThanOrEqualTo(1));
     $this->assertTrue(Metric::bytes(1)->isGreaterThanOrEqualTo('1B'));
     $this->assertTrue(Metric::bytes(5)->isGreaterThan(1));
     $this->assertTrue(Metric::bytes(5)->isGreaterThan('1B'));
     $this->assertTrue(Metric::bytes(1)->isLessThanOrEqualTo(1));
     $this->assertTrue(Metric::bytes(1)->isLessThanOrEqualTo('1B'));
     $this->assertTrue(Metric::bytes(1)->isLessThan(5));
     $this->assertTrue(Metric::bytes(1)->isLessThan('5B'));
 }
 /**
  * @expectedException ByteUnits\NegativeBytesException
  */
 public function testCannotBeNegative()
 {
     Metric::bytes(-1);
 }
Esempio n. 4
0
 public function asMetric()
 {
     return Metric::bytes($this->numberOfBytes);
 }
 public function testConvertFromMetricToBinarySystem()
 {
     $this->assertInstanceOf('ByteUnits\\Binary', Metric::bytes(1)->asBinary());
 }
Esempio n. 6
0
 public function testParseWithSeparator()
 {
     $this->assertEquals(Metric::bytes(1000), parse('1.00 kB'));
     $this->assertEquals(Metric::bytes(1000), parse('1.00/kB'));
     $this->assertEquals(Metric::bytes(1000), parse('1.00~~~kB'));
 }
 public function testFormatWithRoundPrecision()
 {
     $this->assertEquals('1MB', Metric::bytes(1259566)->format(0));
     $this->assertEquals('1MB', Metric::bytes(1259566)->format('MB/'));
     $this->assertEquals('1MB', Metric::bytes(1259566, 0)->format());
 }
Esempio n. 8
0
 public function testPreserveFormatPrecisionOfReceiver()
 {
     $result = Metric::bytes(3000, 6)->add(Binary::bytes(256, 2));
     $this->assertEquals(Metric::bytes(3256, 6)->format(), $result->format());
 }