Fixed output for writeText(s,float) and added unit test
This commit is contained in:
parent
2c32157fd3
commit
5e17ffae3a
2 changed files with 16 additions and 6 deletions
|
|
@ -99,15 +99,13 @@ when defined(c):
|
|||
## than `$` because it is directly written to the stream without
|
||||
## allocating a standard Nim 'string'.
|
||||
##
|
||||
## Because this procedure uses stdlib, it is only active when nim compiles
|
||||
## with the 'c' flag. Otherwise, float types fall back to the generic writeText
|
||||
## Because this procedure uses stdlib, it is only active when Nim compiles
|
||||
## with the 'c' flag. Otherwise, float types are passed to the generic writeText
|
||||
## procedure.
|
||||
var buffer: array[65, char]
|
||||
discard writeFloatToBuffer(buffer, x)
|
||||
for index in 0 ..< 65:
|
||||
if buffer[index] == '\0':
|
||||
break
|
||||
write s, buffer[index]
|
||||
let bs: cstring = addr buffer
|
||||
write s, bs.toOpenArray(0, bs.len - 1)
|
||||
|
||||
template writeText*(s: OutputStream, str: string) =
|
||||
write s, str
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue