@@ -56,10 +56,23 @@ bits(x) = x
5656 @test v9 isa NVector{Bool,9 }
5757 @test v9. data == (0x55 , 0x01 )
5858 @test Tuple (v9) == bools9
59+ @test v9[1 ] === true
60+ @test v9[9 ] === true
5961 @test reinterpret (UInt16, v9) == 0x0155
6062
63+ f6 = NVector ((float6 (0x01 ), float6 (0x02 ), float6 (0x03 ), float6 (0x04 )))
64+ @test f6 isa NVector{Float6_E3M2FN,4 }
65+ @test f6. data == (0x81 , 0x30 , 0x10 )
66+ @test bits .(Tuple (f6)) == (0x01 , 0x02 , 0x03 , 0x04 )
67+ @test bits (f6[1 ]) == 0x01
68+ @test bits (f6[2 ]) == 0x02
69+ @test bits (f6[3 ]) == 0x03
70+ @test bits (f6[4 ]) == 0x04
71+ @test_throws BoundsError f6[5 ]
72+
6173 m = NMatrix {Bool,2,4} (bools)
6274 @test m isa NMatrix{Bool,2 ,4 }
75+ @test IndexStyle (typeof (m)) === IndexLinear ()
6376 @test size (m) == (2 , 4 )
6477 @test Tuple (m) == bools
6578 @test m[1 , 1 ] === true
@@ -145,7 +158,13 @@ bits(x) = x
145158 @test sprint (show, T3) == " @NarrowTuple{Float4_E2M1FN, UInt8, Float4_E2M1FN}"
146159 @test sprint (show, NarrowTuple) == " NarrowTuple"
147160 @test sprint (show, NarrowTuple{Tuple{UInt8,Bool}}) == " NarrowTuple{Tuple{UInt8, Bool}}"
161+ @test startswith (sprint (show, Union{typeof (nt_bool),T3}), " Union{" )
148162 @test contains (sprint (show, methods (show, Tuple{IO,Type{<: NarrowTuple }})), " T<:NarrowTuple" )
163+ @test length (typeof (nt_bool)) == 2
164+ @test firstindex (nt_bool) == 1
165+ @test lastindex (nt_bool) == 2
166+ @test convert (Tuple{UInt8,Bool}, nt_bool) == (0x00 , true )
167+ @test NarrowTuple {Tuple{UInt8,Bool}} (0x00 , true ) == nt_bool
149168 @test @NarrowTuple (0x00 , true ) == nt_bool
150169 @test @NarrowTuple ((0x00 , true )) == nt_bool
151170
@@ -161,6 +180,8 @@ bits(x) = x
161180 @test BitPacking. bitwidth (BitPacking. OnePad{7 }) == 7
162181 @test BitPacking. bitwidth (BitPacking. ZeroPad (7 )) == 7
163182 @test BitPacking. bitwidth (BitPacking. OnePad (7 )) == 7
183+ @test BitPacking. ZeroPad {7} () == BitPacking. ZeroPad (7 )
184+ @test BitPacking. OnePad {7} () == BitPacking. OnePad (7 )
164185 @test sprint (show, BitPacking. ZeroPad (7 )) == " BitPacking.ZeroPad(7)"
165186 @test sprint (show, BitPacking. OnePad (7 )) == " BitPacking.OnePad(7)"
166187
@@ -189,6 +210,8 @@ bits(x) = x
189210 nt_one = Tone (0x00 , true )
190211 @test nt_one. data == 0xff00
191212 @test Tuple (nt_one) == (0x00 , true , BitPacking. OnePad (7 ))
213+ @test NarrowTuple ((0x00 , true , BitPacking. OnePad (7 ))) == nt_one
214+ @test NarrowTuple {Tuple{UInt8,Bool,BitPacking.OnePad{7}}} (0x00 , true , BitPacking. OnePad (7 )) == nt_one
192215 @test_throws ArgumentError Tone (0x0100 )
193216
194217 Tbytes = @NarrowTuple {Float4_E2M1FN,BitPacking. ZeroPad{5 },UInt8}
@@ -256,6 +279,7 @@ bits(x) = x
256279 @test eltype (parent (f4x4_narrow)) <: NVector{Float4_E2M1FN,4}
257280 @test collect (reinterpret (UInt8, f4x4_narrow)) == UInt8[0x21 , 0x43 ]
258281 @test bits .(copy (f4x4_narrow)) == bits .(f4_values)
282+ @test NarrowArray {Float4_E2M1FN,1,4} (f4x4_narrow) === f4x4_narrow
259283 @test NarrowVector {Float4_E2M1FN,4} (f4_narrow) == f4x4_narrow
260284
261285 f4_bits = reinterpret (Bool, f4_narrow)
@@ -269,6 +293,9 @@ bits(x) = x
269293 @test collect (reinterpret (UInt8, host_f4_bits)) == UInt8[0x21 , 0x43 ]
270294
271295 f4_matrix = NarrowArray {Float4_E2M1FN} (reshape (f4_values, 2 , 2 ))
296+ f4_matrix_explicit = NarrowArray {Float4_E2M1FN,2} (reshape (f4_values, 2 , 2 ))
297+ @test f4_matrix_explicit == f4_matrix
298+ @test NarrowArray {Float4_E2M1FN,2} (f4_matrix) === f4_matrix
272299 f4_bytes = reinterpret (UInt8, f4_matrix)
273300 @test size (f4_bytes) == (1 , 2 )
274301 @test collect (f4_bytes) == UInt8[0x21 0x43 ]
0 commit comments