MDL-19270 core_text: added unit tests for strrev
authorSam Hemelryk <sam@moodle.com>
Tue, 8 Jul 2014 02:14:51 +0000 (14:14 +1200)
committerSam Hemelryk <sam@moodle.com>
Tue, 8 Jul 2014 02:14:51 +0000 (14:14 +1200)
lib/tests/text_test.php

index 460c5c9..46eb90d 100644 (file)
@@ -249,6 +249,26 @@ class core_text_testcase extends advanced_testcase {
         $this->assertSame($str, core_text::strtoupper($str, 'GB18030'));
     }
 
+    /**
+     * Test the strrev method.
+     */
+    public function test_strrev() {
+        $strings = array(
+            "Žluťoučký koníček" => "kečínok ýkčuoťulŽ",
+            'ŽLUŤOUČKÝ KONÍČEK' => "KEČÍNOK ÝKČUOŤULŽ",
+            '言語設定' => '定設語言',
+            '简体中文' => '文中体简',
+            "Der eine stößt den Speer zum Mann" => "nnaM muz reepS ned tßöts enie reD"
+        );
+        foreach ($strings as $before => $after) {
+            // Make sure we can reverse it both ways and that it comes out the same.
+            $this->assertSame($after, core_text::strrev($before));
+            $this->assertSame($before, core_text::strrev($after));
+            // Reverse it twice to be doubly sure.
+            $this->assertSame($after, core_text::strrev(core_text::strrev($after)));
+        }
+    }
+
     /**
      * Tests the static strpos method.
      */