Skip to content

Commit

Permalink
fix doc test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yu-zh committed Jan 14, 2025
1 parent 38e6e46 commit 477e1ed
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions string/string.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 477e1ed

Please sign in to comment.