Skip to content

Commit

Permalink
test replace(io, ...) API
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj authored and giordano committed Jun 22, 2023
1 parent 1aff869 commit 0ec87f8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/strings/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,24 @@ end
# Issue 36953
@test replace("abc", "" => "_", count=1) == "_abc"

# tests for io::IO API (in addition to internals exercised above):
let buf = IOBuffer()
replace(buf, "aaa", 'a' => 'z', count=0)
replace(buf, "aaa", 'a' => 'z', count=1)
replace(buf, "bbb", 'a' => 'z')
replace(buf, "aaa", 'a' => 'z')
@test String(take!(buf)) == "aaazaabbbzzz"
end
let tempfile = tempname()
open(tempfile, "w") do f
replace(f, "aaa", 'a' => 'z', count=0)
replace(f, "aaa", 'a' => 'z', count=1)
replace(f, "bbb", 'a' => 'z')
replace(f, "aaa", 'a' => 'z')
print(f, "\n")
end
@test read(tempfile, String) == "aaazaabbbzzz\n"
end
end

@testset "replace many" begin
Expand Down

0 comments on commit 0ec87f8

Please sign in to comment.