Fixed output for writeText(s,float) and added unit test

This commit is contained in:
John Dupuy 2020-05-14 17:44:39 -05:00 • committed by zah
commit 5e17ffae3a
2 changed files with 16 additions and 6 deletions

View file

@ -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