doc tests verified

This commit is contained in:
Jon Lipstate
2023-04-06 14:58:57 -07:00
parent 846c0f7cfc
commit 7a8aa03e54
2 changed files with 28 additions and 27 deletions
+1 -1
View File
@@ -500,7 +500,7 @@ Rounds down the decimal value to the specified number of decimal places
Example: Example:
import "core:fmt" import "core:fmt"
import "core:strconv" import "core:strconv/decimal"
round_down_example :: proc() { round_down_example :: proc() {
d: decimal.Decimal d: decimal.Decimal
str := [64]u8{} str := [64]u8{}
+11 -10
View File
@@ -829,7 +829,7 @@ Example:
import "core:fmt" import "core:fmt"
import "core:strconv" import "core:strconv"
parse_f64_prefix_example :: proc() { parse_f64_prefix_example :: proc() {
n, _, ok := strconv.parse_f64_prefix("12.34eee") n, _, ok := strconv.parse_f64_prefix("12.34eee")
fmt.println(n, ok) fmt.println(n, ok)
@@ -1135,8 +1135,8 @@ Example:
import "core:fmt" import "core:fmt"
import "core:strconv" import "core:strconv"
append_bool_example :: proc() { append_bool_example :: proc() {
buf: [4]byte buf: [6]byte
result := strconv.append_bool(buf[:], true) result := strconv.append_bool(buf[:], true)
fmt.println(result, buf) fmt.println(result, buf)
} }
@@ -1169,7 +1169,7 @@ Example:
import "core:fmt" import "core:fmt"
import "core:strconv" import "core:strconv"
append_uint_example :: proc() { append_uint_example :: proc() {
buf: [4]byte buf: [4]byte
result := strconv.append_uint(buf[:], 42, 16) result := strconv.append_uint(buf[:], 42, 16)
fmt.println(result, buf) fmt.println(result, buf)
@@ -1197,7 +1197,7 @@ Example:
import "core:fmt" import "core:fmt"
import "core:strconv" import "core:strconv"
append_int_example :: proc() { append_int_example :: proc() {
buf: [4]byte buf: [4]byte
result := strconv.append_int(buf[:], -42, 10) result := strconv.append_int(buf[:], -42, 10)
fmt.println(result, buf) fmt.println(result, buf)
@@ -1224,7 +1224,7 @@ Example:
import "core:fmt" import "core:fmt"
import "core:strconv" import "core:strconv"
itoa_example :: proc() { itoa_example :: proc() {
buf: [4]byte buf: [4]byte
result := strconv.itoa(buf[:], 42) result := strconv.itoa(buf[:], 42)
fmt.println(result, buf) // "42" fmt.println(result, buf) // "42"
@@ -1329,6 +1329,8 @@ Appends a quoted string representation of the input string to a given byte slice
- buf: The byte slice to which the quoted string will be appended - buf: The byte slice to which the quoted string will be appended
- str: The input string to be quoted - str: The input string to be quoted
!! ISSUE !! NOT EXPECTED -- "\"hello\"" was expected
Example: Example:
import "core:fmt" import "core:fmt"
@@ -1341,7 +1343,6 @@ Example:
Output: Output:
!! ISSUE !! NOT EXPECTED -- "\"hello\"" was expected
"'h''e''l''l''o'" [34, 39, 104, 39, 39, 101, 39, 39, 108, 39, 39, 108, 39, 39, 111, 39, 34, 0, 0, 0] "'h''e''l''l''o'" [34, 39, 104, 39, 39, 101, 39, 39, 108, 39, 39, 108, 39, 39, 111, 39, 34, 0, 0, 0]
**Returns** **Returns**
@@ -1610,7 +1611,7 @@ Example:
fmt.println(src) fmt.println(src)
fmt.printf("Unquoted: <%s>, alloc:%v, ok:%v\n\n", s, allocated, ok) fmt.printf("Unquoted: <%s>, alloc:%v, ok:%v\n\n", s, allocated, ok)
src="The raven \"Huginn\" is black." src="The raven \'Huginn\' is black."
s, allocated, ok = strconv.unquote_string(src) // Will produce undesireable results s, allocated, ok = strconv.unquote_string(src) // Will produce undesireable results
fmt.println(src) fmt.println(src)
fmt.printf("Unquoted: <%s>, alloc:%v, ok:%v\n", s, allocated, ok) fmt.printf("Unquoted: <%s>, alloc:%v, ok:%v\n", s, allocated, ok)
@@ -1624,8 +1625,8 @@ Output:
'The raven Huginn' is black. 'The raven Huginn' is black.
Unquoted: <The raven Huginn' is black>, alloc:false, ok:true Unquoted: <The raven Huginn' is black>, alloc:false, ok:true
Source: The raven `Huginn` is black. The raven 'Huginn' is black.
Unquoted: <he raven `Huginn` is black>, alloc:false, ok:true Unquoted: <he raven 'Huginn' is black>, alloc:false, ok:true
**Returns** **Returns**
- res: The resulting unquoted string - res: The resulting unquoted string