module Compatibility_test

using SpikeSorting

if VERSION > v"0.7-"
    using Test
else
    using Base.Test
end

num_channels=1;
(buf,nums)=output_buffer(num_channels);

function make_voltage(num_channels)

    v=rand(1:1000, 1000, num_channels);
    count = 1
    for i=525:550
        v[i,1] = v[i,1] + count
        count = count + 10
    end
    for i=551:775
        v[i,1]+=1
        count -= 10
    end
    v
end

v=make_voltage(num_channels)

detects=subtypes(SpikeSorting.Detect)
aligns=subtypes(SpikeSorting.Align)
features=subtypes(SpikeSorting.Feature)
reduces=subtypes(SpikeSorting.Reduction)
clusters=subtypes(SpikeSorting.Cluster)
thresholds=subtypes(SpikeSorting.Threshold)

for d in detects
    for a in aligns
        for f in features
            for r in reduces
                for c in clusters
                    for t in thresholds

                        s1=create_multi(d(),c(),a(),f(),r(),t(),num_channels)

                        cal!(s1,v,buf,nums,0)
                        cal!(s1,v,buf,nums,1)
                        cal!(s1,v,buf,nums,2)
                        onlinesort!(s1,v,buf,nums)


                            @test s1[1].sigend == v[end-74:end,1]


                    end
                end
            end
        end
    end
end


end
