Skip to content

Commit 133d41d

Browse files
committed
make tests independent of string representation
1 parent eef764a commit 133d41d

File tree

6 files changed

+28
-32
lines changed

6 files changed

+28
-32
lines changed

test/core.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -624,10 +624,6 @@ let
624624
@test !isdefined(a, :foo)
625625
@test !isdefined(2, :a)
626626

627-
@test isdefined("a",:data)
628-
@test isdefined("a", 1)
629-
@test !isdefined("a", 2)
630-
631627
@test_throws TypeError isdefined(2)
632628
end
633629

@@ -3988,7 +3984,7 @@ b = "aaa"
39883984
c = [0x2, 0x1, 0x3]
39893985

39903986
@test check_nul(a)
3991-
@test check_nul(b.data)
3987+
@test check_nul(convert(Vector{UInt8},b))
39923988
@test check_nul(c)
39933989
d = [0x2, 0x1, 0x3]
39943990
@test check_nul(d)

test/misc.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ end
403403

404404
let s = "abcα🐨\0x\0"
405405
for T in (UInt8, UInt16, UInt32, Int32)
406-
@test transcode(T, s) == transcode(T, s.data)
406+
@test transcode(T, s) == transcode(T, convert(Vector{UInt8},s))
407407
@test transcode(String, transcode(T, s)) == s
408408
end
409409
end

test/mmap.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
file = tempname()
44
write(file, "Hello World\n")
5-
t = "Hello World".data
5+
t = b"Hello World"
66
@test Mmap.mmap(file, Array{UInt8,3}, (11,1,1)) == reshape(t,(11,1,1))
77
gc(); gc()
88
@test Mmap.mmap(file, Array{UInt8,3}, (1,11,1)) == reshape(t,(1,11,1))
@@ -16,7 +16,7 @@ gc(); gc()
1616
gc(); gc()
1717
@test Mmap.mmap(file, Array{UInt8,2}, (0,12)) == Array{UInt8}((0,0))
1818
m = Mmap.mmap(file, Array{UInt8,3}, (1,2,1))
19-
@test m == reshape("He".data,(1,2,1))
19+
@test m == reshape(b"He",(1,2,1))
2020
finalize(m); m=nothing; gc()
2121

2222
# constructors
@@ -49,7 +49,7 @@ s = open(f->f,file,"w")
4949
@test Mmap.mmap(file) == Array{UInt8}(0) # requested len=0 on empty file
5050
@test Mmap.mmap(file,Vector{UInt8},0) == Array{UInt8}(0)
5151
m = Mmap.mmap(file,Vector{UInt8},12)
52-
m[:] = "Hello World\n".data
52+
m[:] = b"Hello World\n"
5353
Mmap.sync!(m)
5454
finalize(m); m=nothing; gc()
5555
@test open(readstring,file) == "Hello World\n"
@@ -115,10 +115,10 @@ write(file, "Hello World\n")
115115
s = open(file, "r")
116116
@test isreadonly(s) == true
117117
c = Mmap.mmap(s, Vector{UInt8}, (11,))
118-
@test c == "Hello World".data
118+
@test c == b"Hello World"
119119
finalize(c); c=nothing; gc()
120120
c = Mmap.mmap(s, Vector{UInt8}, (UInt16(11),))
121-
@test c == "Hello World".data
121+
@test c == b"Hello World"
122122
finalize(c); c=nothing; gc()
123123
@test_throws ArgumentError Mmap.mmap(s, Vector{UInt8}, (Int16(-11),))
124124
@test_throws ArgumentError Mmap.mmap(s, Vector{UInt8}, (typemax(UInt),))
@@ -136,18 +136,18 @@ close(s)
136136
finalize(c); c=nothing; gc()
137137

138138
c = Mmap.mmap(file)
139-
@test c == "Hellx World\n".data
139+
@test c == b"Hellx World\n"
140140
finalize(c); c=nothing; gc()
141141
c = Mmap.mmap(file, Vector{UInt8}, 3)
142-
@test c == "Hel".data
142+
@test c == b"Hel"
143143
finalize(c); c=nothing; gc()
144144
s = open(file, "r")
145145
c = Mmap.mmap(s, Vector{UInt8}, 6)
146-
@test c == "Hellx ".data
146+
@test c == b"Hellx "
147147
close(s)
148148
finalize(c); c=nothing; gc()
149149
c = Mmap.mmap(file, Vector{UInt8}, 5, 6)
150-
@test c == "World".data
150+
@test c == b"World"
151151
finalize(c); c=nothing; gc()
152152

153153
s = open(file, "w")
@@ -156,26 +156,26 @@ close(s)
156156

157157
# test Mmap.mmap
158158
m = Mmap.mmap(file)
159-
t = "Hello World\n"
159+
tdata = b"Hello World\n"
160160
for i = 1:12
161-
@test m[i] == t.data[i]
161+
@test m[i] == tdata[i]
162162
end
163163
@test_throws BoundsError m[13]
164164
finalize(m); m=nothing; gc()
165165

166166
m = Mmap.mmap(file,Vector{UInt8},6)
167-
@test m[1] == "H".data[1]
168-
@test m[2] == "e".data[1]
169-
@test m[3] == "l".data[1]
170-
@test m[4] == "l".data[1]
171-
@test m[5] == "o".data[1]
172-
@test m[6] == " ".data[1]
167+
@test m[1] == b"H"[1]
168+
@test m[2] == b"e"[1]
169+
@test m[3] == b"l"[1]
170+
@test m[4] == b"l"[1]
171+
@test m[5] == b"o"[1]
172+
@test m[6] == b" "[1]
173173
@test_throws BoundsError m[7]
174174
finalize(m); m=nothing; gc()
175175

176176
m = Mmap.mmap(file,Vector{UInt8},2,6)
177-
@test m[1] == "W".data[1]
178-
@test m[2] == "o".data[1]
177+
@test m[1] == b"W"[1]
178+
@test m[2] == b"o"[1]
179179
@test_throws BoundsError m[3]
180180
finalize(m); m = nothing; gc()
181181

test/perf/shootout/revcomp.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function revcomp(infile="revcomp-input.txt")
4343
input = open(infile, "r")
4444
buff = UInt8[]
4545
while true
46-
line = readline(input).data
46+
line = readuntil(input, UInt8('\n'))
4747
if isempty(line)
4848
# print_buff(buff)
4949
return

test/read.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ for (name, f) in l
296296
@test readstring("$filename.to") == text
297297

298298
verbose && println("$name write(::IOBuffer, ...)")
299-
to = IOBuffer(copy(text.data), false, true)
299+
to = IOBuffer(copy(convert(Vector{UInt8},text)), false, true)
300300
write(to, io())
301301
@test String(take!(to)) == text
302302

@@ -365,14 +365,14 @@ test_read_nbyte()
365365

366366

367367
let s = "qwerty"
368-
@test read(IOBuffer(s)) == s.data
369-
@test read(IOBuffer(s), 10) == s.data
370-
@test read(IOBuffer(s), 1) == s.data[1:1]
368+
@test read(IOBuffer(s)) == convert(Vector{UInt8},s)
369+
@test read(IOBuffer(s), 10) == convert(Vector{UInt8},s)
370+
@test read(IOBuffer(s), 1) == convert(Vector{UInt8},s)[1:1]
371371

372372
# Test growing output array
373373
x = UInt8[]
374374
n = readbytes!(IOBuffer(s), x, 10)
375-
@test x == s.data
375+
@test x == convert(Vector{UInt8},s)
376376
@test n == length(x)
377377
end
378378

test/unicode/utf8.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
let ch = 0x10000
66
for hi = 0xd800:0xdbff
77
for lo = 0xdc00:0xdfff
8-
@test convert(String, String(Char[hi, lo]).data) == string(Char(ch))
8+
@test convert(String, convert(Vector{UInt8},String(Char[hi, lo]))) == string(Char(ch))
99
ch += 1
1010
end
1111
end

0 commit comments

Comments
 (0)