From 9a9c04512e5dcb77c7fe5d850e3f2a0250cc160e Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 18 Jan 2017 20:07:16 +0100 Subject: * Motor Sport Magazine feed provider --- .../test/Tests/QueryPath/CSS/UtilTest.php | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 lib/querypath/test/Tests/QueryPath/CSS/UtilTest.php (limited to 'lib/querypath/test/Tests/QueryPath/CSS/UtilTest.php') diff --git a/lib/querypath/test/Tests/QueryPath/CSS/UtilTest.php b/lib/querypath/test/Tests/QueryPath/CSS/UtilTest.php new file mode 100644 index 0000000..bdb8533 --- /dev/null +++ b/lib/querypath/test/Tests/QueryPath/CSS/UtilTest.php @@ -0,0 +1,51 @@ +assertEquals('foo', Util::removeQuotes('"foo"')); + $this->assertEquals('foo', Util::removeQuotes("'foo'")); + $this->assertEquals('"foo\'', Util::removeQuotes("\"foo'")); + $this->assertEquals('f"o"o', Util::removeQuotes('f"o"o')); + + } + public function testParseAnB() { + // even + $this->assertEquals(array(2, 0), Util::parseAnB('even')); + // odd + $this->assertEquals(array(2, 1), Util::parseAnB('odd')); + // 5 + $this->assertEquals(array(0, 5), Util::parseAnB('5')); + // +5 + $this->assertEquals(array(0, 5), Util::parseAnB('+5')); + // n + $this->assertEquals(array(1, 0), Util::parseAnB('n')); + // 2n + $this->assertEquals(array(2, 0), Util::parseAnB('2n')); + // -234n + $this->assertEquals(array(-234, 0), Util::parseAnB('-234n')); + // -2n+1 + $this->assertEquals(array(-2, 1), Util::parseAnB('-2n+1')); + // -2n + 1 + $this->assertEquals(array(-2, 1), Util::parseAnB(' -2n + 1 ')); + // +2n-1 + $this->assertEquals(array(2, -1), Util::parseAnB('2n-1')); + $this->assertEquals(array(2, -1), Util::parseAnB('2n - 1')); + // -n + 3 + $this->assertEquals(array(-1, 3), Util::parseAnB('-n+3')); + + // Test invalid values + $this->assertEquals(array(0, 0), Util::parseAnB('obviously + invalid')); + } +} -- cgit v1.2.3