Permalink
Browse files

test escaped values

Previouse optimization breakes this test
  • Loading branch information...
Nuzhdin Urii aka tz-lom
Nuzhdin Urii aka tz-lom committed Jan 20, 2013
1 parent 15204a9 commit bf09243bb3614c6ddc85e6c82edf27635bd3fba1
Showing with 26 additions and 31 deletions.
  1. +24 −15 tests/HSPHP/ReadSocketTest.php
  2. +2 −16 tests/HSPHP/import.sql
@@ -4,43 +4,42 @@ class ReadSocketTest extends PHPUnit_Framework_TestCase
{
protected $db = 'HSPHP_test';
- function __construct()
+ public function __construct()
{
if(file_exists(__DIR__.'/my.cfg'))
{
$this->db = trim(file_get_contents(__DIR__.'/my.cfg'));
}
}
-
- function testConnection()
+
+ public function testConnection()
{
$c = new \HSPHP\ReadSocket();
$c->connect();
$this->assertEquals(true,$c->isConnected());
$c->disconnect();
$this->assertEquals(false,$c->isConnected());
}
-
- function testIndex()
+
+ public function testIndex()
{
$c = new \HSPHP\ReadSocket();
$c->connect();
$this->assertEquals(1,$c->getIndexId($this->db,'read1','','key,date,float,varchar,text,set,union,null'));
$this->assertEquals(1,$c->getIndexId($this->db,'read1','','key,date,float,varchar,text,set,union,null'));
}
-
- function testSelect()
+
+ public function testSelect()
{
$c = new \HSPHP\ReadSocket();
$c->connect();
$id = $c->getIndexId($this->db,'read1','','key,date,float,varchar,text,set,union,null');
$c->select($id,'=',array(42));
$response = $c->readResponse();
- if($response instanceof \HSPHP\ErrorMessage) throw $response;
$this->assertEquals(array(array(42,'2010-10-29','3.14159','variable length',"some\r\nbig\r\ntext",'a,c','b',NULL)),$response);
}
-
- function testSelectRange()
+
+ public function testSelectRange()
{
$c = new \HSPHP\ReadSocket();
$c->connect();
@@ -50,8 +49,8 @@ function testSelectRange()
$this->assertEquals(array(array(4),array(3),array(2)),$response);
}
-
- function testSelectMoved()
+
+ public function testSelectMoved()
{
$c = new \HSPHP\ReadSocket();
$c->connect();
@@ -61,8 +60,8 @@ function testSelectMoved()
$this->assertEquals(array(array(1)),$response);
}
-
- function testSelectMovedRange()
+
+ public function testSelectMovedRange()
{
$c = new \HSPHP\ReadSocket();
$c->connect();
@@ -75,7 +74,7 @@ function testSelectMovedRange()
/**
* @bug 1
*/
- function testSelectWithZeroValue()
+ public function testSelectWithZeroValue()
{
$c = new \HSPHP\ReadSocket();
$c->connect();
@@ -84,4 +83,14 @@ function testSelectWithZeroValue()
$response = $c->readResponse();
$this->assertEquals(array(array(0)),$response);
}
+
+ public function testSelectWithSpecialChars()
+ {
+ $c = new \HSPHP\ReadSocket();
+ $c->connect();
+ $id = $c->getIndexId($this->db, 'read1', '', 'text');
+ $c->select($id, '=', array(10001));
+ $response = $c->readResponse();
+ $this->assertEquals(array(array("\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F")), $response);
+ }
}
View
@@ -1,20 +1,5 @@
--- phpMyAdmin SQL Dump
--- version 3.2.0.1
--- http://www.phpmyadmin.net
---
--- Хост: localhost
--- Время создания: Ноя 05 2010 г., 13:49
--- Версия сервера: 5.1.51
--- Версия PHP: 5.3.3-pl1-gentoo
-
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
-
-/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
-/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
-/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
-
--
-- База данных: `HSPHP_test`
--
@@ -49,7 +34,8 @@ INSERT INTO `read1` (`key`, `date`, `float`, `varchar`, `text`, `set`, `union`,
(2, '0000-00-00', 2, '', '', '', '', NULL),
(3, '0000-00-00', 3, '', '', '', '', NULL),
(4, '0000-00-00', 4, '', '', '', '', NULL),
-(100, '0000-00-00', 0, '', '', '', '', NULL);
+(100, '0000-00-00', 0, '', '', '', '', NULL),
+(10001, '2012-01-20', 1 , 'text with special chars', CONCAT(CHAR(0),CHAR(1),CHAR(2),CHAR(3),CHAR(4),CHAR(5),CHAR(6),CHAR(7),CHAR(8),CHAR(9),CHAR(10),CHAR(11),CHAR(12),CHAR(13),CHAR(14),CHAR(15)), '', '', NULL);
-- --------------------------------------------------------

0 comments on commit bf09243

Please sign in to comment.