diff options
Diffstat (limited to 'tests/MathTest.php')
-rw-r--r-- | tests/MathTest.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/MathTest.php b/tests/MathTest.php index 1e5da5a..a5061ad 100644 --- a/tests/MathTest.php +++ b/tests/MathTest.php @@ -589,4 +589,28 @@ class MathTest extends TestCase ]; } + public function testCache() + { + $calculator = new MathExecutor(); + $this->assertEquals(256, $calculator->execute('2 ^ 8')); // second arg $cache is true by default + + $this->assertIsArray($calculator->getCache()); + $this->assertEquals(1, count($calculator->getCache())); + + $this->assertEquals(512, $calculator->execute('2 ^ 9', true)); + $this->assertEquals(2, count($calculator->getCache())); + + $this->assertEquals(1024, $calculator->execute('2 ^ 10', false)); + $this->assertEquals(2, count($calculator->getCache())); + + $calculator->clearCache(); + $this->assertIsArray($calculator->getCache()); + $this->assertEquals(0, count($calculator->getCache())); + + $this->assertEquals(2048, $calculator->execute('2 ^ 11', false)); + $this->assertEquals(0, count($calculator->getCache())); + + + } + }
\ No newline at end of file |