NumberTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. class HTMLPurifier_AttrDef_CSS_NumberTest extends HTMLPurifier_AttrDefHarness
  3. {
  4. function test() {
  5. $this->def = new HTMLPurifier_AttrDef_CSS_Number();
  6. $this->assertDef('0');
  7. $this->assertDef('0.0', '0');
  8. $this->assertDef('1.0', '1');
  9. $this->assertDef('34');
  10. $this->assertDef('4.5');
  11. $this->assertDef('.5');
  12. $this->assertDef('0.5', '.5');
  13. $this->assertDef('-56.9');
  14. $this->assertDef('0.', '0');
  15. $this->assertDef('.0', '0');
  16. $this->assertDef('0.0', '0');
  17. $this->assertDef('1.', '1');
  18. $this->assertDef('.1', '.1');
  19. $this->assertDef('1.0', '1');
  20. $this->assertDef('0.1', '.1');
  21. $this->assertDef('000', '0');
  22. $this->assertDef(' 9', '9');
  23. $this->assertDef('+5.0000', '5');
  24. $this->assertDef('02.20', '2.2');
  25. $this->assertDef('2.', '2');
  26. $this->assertDef('.', false);
  27. $this->assertDef('asdf', false);
  28. $this->assertDef('0.5.6', false);
  29. }
  30. function testNonNegative() {
  31. $this->def = new HTMLPurifier_AttrDef_CSS_Number(true);
  32. $this->assertDef('23');
  33. $this->assertDef('-12', false);
  34. }
  35. }
  36. // vim: et sw=4 sts=4