From 477e1ed6963fbe728093bd091dd5e85cb2c54e11 Mon Sep 17 00:00:00 2001 From: Yu Zhang Date: Tue, 14 Jan 2025 10:05:24 +0800 Subject: [PATCH] fix doc test --- string/string.mbt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/string/string.mbt b/string/string.mbt index faedeb1b3..1c13ddf01 100644 --- a/string/string.mbt +++ b/string/string.mbt @@ -19,9 +19,9 @@ /// /// ``` /// let s = "Hello🤣"; -/// assert_eq!(s.code_unit_at(0), 'H'); -/// assert_eq!(s.code_unit_at(5), '\ud83e'); // First surrogate of 🤣 -/// assert_eq!(s.code_unit_at(6), '\udd23'); // Second surrogate of 🤣 +/// inspect!(s.code_unit_at(0), content="'H'"); +/// inspect!(s.code_unit_at(5).to_int(), content="55358"); // First surrogate of 🤣 +/// inspect!(s.code_unit_at(6).to_int(), content="'�'"); // Second surrogate of 🤣 /// ``` /// /// # Panics @@ -44,8 +44,8 @@ pub fn code_unit_at(self : String, index : Int) -> Char { /// /// ``` /// let s = "Hello🤣"; -/// assert_eq!(s.code_point_at(0), 'H'); -/// assert_eq!(s.code_point_at(5), '🤣'); // Returns full emoji character +/// inspect!(s.code_point_at(0), content="'H'"); +/// inspect!(s.code_point_at(5), content="'🤣'"); // Returns full emoji character /// ``` /// /// # Panics @@ -99,8 +99,8 @@ pub fn code_point_at(self : String, index : Int) -> Char { /// /// ``` /// let s = "Hello🤣"; -/// assert_eq!(s.code_unit_length(), 7); // 5 ASCII chars + 2 surrogate pairs -/// assert_eq!(s.code_point_length(), 6); // 6 actual characters +/// inspect!(s.code_unit_length(), content = "7"); // 5 ASCII chars + 2 surrogate pairs +/// inspect!(s.code_point_length(), content = "6"); // 6 actual characters /// ``` pub fn code_unit_length(self : String) -> Int { self.unsafe_length() @@ -117,8 +117,8 @@ pub fn code_unit_length(self : String) -> Int { /// /// ``` /// let s = "Hello🤣"; -/// assert_eq!(s.code_point_length(), 6); // 6 actual characters -/// assert_eq!(s.code_unit_length(), 7); // 5 ASCII chars + 2 surrogate pairs +/// inspect!(s.code_point_length(), content = "6"); // 6 actual characters +/// inspect!(s.code_unit_length(), content = "7"); // 5 ASCII chars + 2 surrogate pairs /// ``` pub fn code_point_length(self : String) -> Int { let code_unit_len = self.unsafe_length()