From 8f098e8dead85b6512ac72b2d805314baec72a2f Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Mon, 17 Sep 2012 16:04:16 -0400
Subject: [PATCH] Merge branch 'master' of github.com:roundcube/roundcubemail

---
 tests/Framework/Shared.php |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/tests/Framework/Shared.php b/tests/Framework/Shared.php
index 99ef829..0394cd0 100644
--- a/tests/Framework/Shared.php
+++ b/tests/Framework/Shared.php
@@ -201,4 +201,32 @@
 
     }
 
+    /**
+     * rcube_shared.inc: is_ascii()
+     */
+    function test_is_ascii()
+    {
+        $result = is_ascii("0123456789");
+        $this->assertTrue($result, "Valid ASCII (numbers)");
+
+        $result = is_ascii("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
+        $this->assertTrue($result, "Valid ASCII (letters)");
+
+        $result = is_ascii(" !\"#\$%&'()*+,-./:;<=>?@[\\^_`{|}~");
+        $this->assertTrue($result, "Valid ASCII (special characters)");
+
+        $result = is_ascii("\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"
+            ."\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F");
+        $this->assertTrue($result, "Valid ASCII (control characters)");
+
+        $result = is_ascii("\n", false);
+        $this->assertFalse($result, "Valid ASCII (control characters)");
+
+        $result = is_ascii("ż");
+        $this->assertFalse($result, "Invalid ASCII (UTF-8 character)");
+
+        $result = is_ascii("ż", false);
+        $this->assertFalse($result, "Invalid ASCII (UTF-8 character [2])");
+    }
+
 }

--
Gitblit v1.9.1