@@ -26,13 +26,15 @@ using TranscodingStreams:
2626
2727 data = Vector {UInt8} (b " foobar" )
2828 buf = Buffer (data)
29- @test buf isa Buffer
30- @test bufferptr (buf) === pointer (data)
31- @test buffersize (buf) === 6
32- @test buffermem (buf) === Memory (pointer (data), 6 )
33- @test marginptr (buf) === pointer (data) + 6
34- @test marginsize (buf) === 0
35- @test marginmem (buf) === Memory (pointer (data)+ 6 , 0 )
29+ GC. @preserve data buf begin
30+ @test buf isa Buffer
31+ @test bufferptr (buf) === pointer (data)
32+ @test buffersize (buf) === 6
33+ @test buffermem (buf) === Memory (pointer (data), 6 )
34+ @test marginptr (buf) === pointer (data) + 6
35+ @test marginsize (buf) === 0
36+ @test marginmem (buf) === Memory (pointer (data)+ 6 , 0 )
37+ end
3638
3739 buf = Buffer (2 )
3840 writebyte! (buf, 0x34 )
7274
7375@testset " Memory" begin
7476 data = Vector {UInt8} (b " foobar" )
75- mem = TranscodingStreams. Memory (pointer (data), sizeof (data))
76- @test mem isa TranscodingStreams. Memory
77- @test mem. ptr === pointer (data)
78- @test mem. size === length (mem) === UInt (sizeof (data))
79- @test lastindex (mem) === 6
80- @test mem[1 ] === UInt8 (' f' )
81- @test mem[2 ] === UInt8 (' o' )
82- @test mem[3 ] === UInt8 (' o' )
83- @test mem[4 ] === UInt8 (' b' )
84- @test mem[5 ] === UInt8 (' a' )
85- @test mem[6 ] === UInt8 (' r' )
86- @test_throws BoundsError mem[7 ]
87- @test_throws BoundsError mem[0 ]
88- mem[1 ] = UInt8 (' z' )
89- @test mem[1 ] === UInt8 (' z' )
90- mem[3 ] = UInt8 (' !' )
91- @test mem[3 ] === UInt8 (' !' )
92- @test_throws BoundsError mem[7 ] = 0x00
93- @test_throws BoundsError mem[0 ] = 0x00
77+ GC. @preserve data let mem = TranscodingStreams. Memory (pointer (data), sizeof (data))
78+ @test mem isa TranscodingStreams. Memory
79+ @test mem. ptr === pointer (data)
80+ @test mem. size === length (mem) === UInt (sizeof (data))
81+ @test lastindex (mem) === 6
82+ @test mem[1 ] === UInt8 (' f' )
83+ @test mem[2 ] === UInt8 (' o' )
84+ @test mem[3 ] === UInt8 (' o' )
85+ @test mem[4 ] === UInt8 (' b' )
86+ @test mem[5 ] === UInt8 (' a' )
87+ @test mem[6 ] === UInt8 (' r' )
88+ @test_throws BoundsError mem[7 ]
89+ @test_throws BoundsError mem[0 ]
90+ mem[1 ] = UInt8 (' z' )
91+ @test mem[1 ] === UInt8 (' z' )
92+ mem[3 ] = UInt8 (' !' )
93+ @test mem[3 ] === UInt8 (' !' )
94+ @test_throws BoundsError mem[7 ] = 0x00
95+ @test_throws BoundsError mem[0 ] = 0x00
96+ end
9497
9598 data = Vector {UInt8} (b " foobar" )
96- mem = TranscodingStreams. Memory (data)
97- @test mem isa TranscodingStreams. Memory
98- @test mem. ptr == pointer (data)
99- @test mem. size == sizeof (data)
99+ GC. @preserve data let mem = TranscodingStreams. Memory (pointer (data), sizeof (data))
100+ @test mem isa TranscodingStreams. Memory
101+ @test mem. ptr == pointer (data)
102+ @test mem. size == sizeof (data)
103+ end
100104end
101105
102106@testset " Stats" begin
0 commit comments