
using ArrayInterfaceBlockBandedMatrices
using ArrayInterfaceCore
using BlockBandedMatrices
using Test

BB=BlockBandedMatrix(Ones(10,10),[1,2,3,4],[4,3,2,1],(1,0))
BB[Block(1,1)].=[1 2 3 4]
BB[Block(2,1)].=[5 6 7 8;9 10 11 12]
rowind,colind=ArrayInterfaceCore.findstructralnz(BB)
@test [BB[rowind[i],colind[i]] for i in 1:length(rowind)]==
    [1,5,9,2,6,10,3,7,11,4,8,12,
    1,1,1,1,1,1,1,1,1,1,1,1,1,1,
    1,1,1,1,1,1,1,1,1,1,1,1,1,1,
    1,1,1,1,1]
@test ArrayInterfaceCore.isstructured(typeof(BB))
@test ArrayInterfaceCore.has_sparsestruct(typeof(BB))
@test ArrayInterfaceCore.fast_matrix_colors(typeof(BB))

dense=collect(Ones(8,8))
for i in 1:8
    dense[:,i].=[1,2,3,4,5,6,7,8]
end
BBB=BandedBlockBandedMatrix(dense, [4, 4] ,[4, 4], (1, 1), (1, 1))
rowind,colind=ArrayInterfaceCore.findstructralnz(BBB)
@test [BBB[rowind[i],colind[i]] for i in 1:length(rowind)]==
    [1,2,3,1,2,3,4,2,3,4,5,6,7,5,6,7,8,6,7,8,
     1,2,3,1,2,3,4,2,3,4,5,6,7,5,6,7,8,6,7,8]
@test ArrayInterfaceCore.isstructured(typeof(BBB))
@test ArrayInterfaceCore.has_sparsestruct(typeof(BBB))
@test ArrayInterfaceCore.fast_matrix_colors(typeof(BBB))

