using SmallFixedSizeSets
using Base.Test

using Combinatorics

function test_issubset0()
    Empty = SFSSFromOrderedVec(Int32[])    
    # Size-0 subset, is subset
    A = SFSSFromOrderedVec(Int32[])
    @test SFSS_issubset(A, Empty)
    @test SFSS_issubset(A, SFSSFromOrderedVec([11]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 11111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 11111, 111111]))
end

function test_issubset1()
    Empty = SFSSFromOrderedVec(Int32[])        
    # Size-1 subset 
    A = SFSSFromOrderedVec([11])
    # Size-1, size-0, smaller
    @test !SFSS_issubset(A, Empty)
    # Size-1, size-1, is subset
    @test SFSS_issubset(A, SFSSFromOrderedVec([11]))
    # Size-1, size-2, is subset
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 12]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([10, 11]))
    # Size-1, size-3, is subset
    @test SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 11]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 13]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 12, 13]))
    # Size-1, size-4, is subset
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 12, 13, 14]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 12, 13]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 11, 13]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([7, 8, 9, 11]))
    # Size-1, size-5, is subset
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 12, 13, 14, 15]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 12, 13, 14]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 11, 12, 13]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([7, 8, 9, 11, 12]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([6, 7, 8, 9, 11]))    

    # Size 1, not subset
    @test !SFSS_issubset(A, SFSSFromOrderedVec([21]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([21, 22]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([21, 22, 23]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([21, 22, 23, 24]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([21, 22, 23, 24, 25]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([7]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([7, 22]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([7, 22, 23]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([7, 22, 23, 24]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([7, 22, 23, 24, 25]))
end

function test_issubset2()
    Empty = SFSSFromOrderedVec(Int32[])        
    # Size-2 subset
    A = SFSSFromOrderedVec([11, 111])
    
    # Size-2, Size-2, is subset
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 111]))
    # Size-2, Size-3, is subset
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 112]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 111]))
    # Size-2, Size-4, is subset
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 11111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 111, 1111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 108, 109, 111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 111, 1111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 109, 111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 11, 111]))
    # Size-2, Size-5, is subset
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 11111, 111111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 111, 1111, 11111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 108, 109, 111, 1111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 107, 108, 109, 111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 111, 1111, 11111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 109, 111, 1111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 108, 109, 111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 11, 111, 1111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 11, 109, 111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([7, 8, 9, 11, 111]))

    # Size-2, smaller, not subset
    @test !SFSS_issubset(A, Empty)
    @test !SFSS_issubset(A, SFSSFromOrderedVec([50]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([111]))    
    # Size-2, size-2, not subset
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112]))
    # Size-2, size-3, not subset
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 113]))    
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 112]))    
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1111, 11111]))    
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 111, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 112, 1111]))    
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 108, 109, 111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 108, 109, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 108, 109, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 111, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 109, 111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 109, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 109, 112]))    
    @test !SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 12, 111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 11, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 12, 112]))    
    # Size-2, size-4, not subset    
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1111, 11111]))    
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 111, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 108, 109, 111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 108, 109, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 108, 109, 112]))    
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 111, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 112, 1111]))    
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 109, 111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 109, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 109, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 12, 111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 11, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 12, 112]))
    # Size-2, Size-5, not subset
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1111, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1111, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1111, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 111, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 112, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 112, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 108, 109, 111, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 108, 109, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 108, 109, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 107, 108, 109, 111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 107, 108, 109, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 107, 108, 109, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 111, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 112, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 112, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 109, 111, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 109, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 109, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 108, 109, 111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 108, 109, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 108, 109, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 12, 111, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 11, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 12, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 12, 109, 111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 11, 109, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 12, 109, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([7, 8, 9, 12, 111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([7, 8, 9, 11, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([7, 8, 9, 12, 112]))
end

function test_issubset3()
    Empty = SFSSFromOrderedVec(Int32[])
    A = SFSSFromOrderedVec([11, 111, 1111])
    # Size-3, Size-3, is subset
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111]))
    # Size-3, Size-4, is subset    
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 11111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 111, 1111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 111, 1111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1109, 1111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 1112]))
    # Size-3, Size-5, is subset
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 11111, 111111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 111, 1111, 11111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 111, 1109, 1111]))    
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 108, 109, 111, 1111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 111, 1111, 11111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 109, 111, 1111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 11, 111, 1111]))
    # Size-3 subset, smaller, not subset
    @test !SFSS_issubset(A, Empty)
    @test !SFSS_issubset(A, SFSSFromOrderedVec([50]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([50, 51]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 50]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([111, 150]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([50, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([1111, 1150]))
    # Size-3, Size-3, not subset
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1112]))
    # Size-3, Size-4, not subset    
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 111, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 111, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 111, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 112, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 112, 1112]))    
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 111, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 111, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 111, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 112, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 112, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1109, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1109, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1109, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1109, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1109, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1109, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1109, 1112]))    
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1111, 1113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1111, 1113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1112, 1113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1111, 1113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1112, 1113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1112, 1113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1112, 1113]))
    # Size-3, Size-5, not subset
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1111, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1111, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1112, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1111, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1112, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1112, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1112, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 111, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 112, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 111, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 112, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 111, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 112, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 112, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 111, 1109, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 112, 1109, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 111, 1109, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 112, 1109, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 111, 1109, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 112, 1109, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 112, 1109, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 108, 109, 111, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 108, 109, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 108, 109, 111, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 108, 109, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 108, 109, 111, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 108, 109, 112, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 108, 109, 112, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 111, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 112, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 111, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 112, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 111, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 112, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 112, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 109, 111, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 109, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 109, 111, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 109, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 109, 111, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 109, 112, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 109, 112, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 12, 111, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 11, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 11, 111, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 12, 112, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 12, 111, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 11, 112, 1112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([8, 9, 12, 112, 1112]))
end

function test_issubset4()
    Empty = SFSSFromOrderedVec(Int32[])
    A = SFSSFromOrderedVec([11, 111, 1111, 11111])
    
    # Size-4, Size-4, is subset
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 11111]))
    # Size-4, Size-5, is subset
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 11111, 111111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 111, 1111, 11111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 111, 1111, 11111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1109, 1111, 11111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 11109, 11111]))
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 11111, 11112]))

    # Size-4 subset, smaller, not subset
    @test !SFSS_issubset(A, Empty)
    @test !SFSS_issubset(A, SFSSFromOrderedVec([50]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([1111]))    
    @test !SFSS_issubset(A, SFSSFromOrderedVec([50, 51]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 50]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([111, 150]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([1111, 150]))    
    @test !SFSS_issubset(A, SFSSFromOrderedVec([50, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([1111, 1150]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([50, 51, 52]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 51, 52]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([1111, 51, 52]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([51, 1111, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 112]))    
    # Size-4, Size-4, not subset
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1111, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1111, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1112, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1111, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1112, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1112, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1112, 11112]))
    # Size-4, Size-5, not subset
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1111, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1111, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1112, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 11112, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1111, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1112, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1111, 11112, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1112, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1111, 11112, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1112, 11112, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1112, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1111, 11112, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1112, 11112, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1112, 11112, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1112, 11112, 111111]))    
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 111, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 112, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 111, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 111, 1111, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 112, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 111, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 111, 1111, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 112, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 112, 1111, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 111, 1112, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 112, 1112, 11111]))    
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 112, 1111, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 111, 1112, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 11, 112, 1112, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([9, 12, 112, 1112, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 111, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 112, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 111, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 111, 1111, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 112, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 111, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 111, 1111, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 112, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 112, 1111, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 111, 1112, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 112, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 112, 1111, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 111, 1112, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 109, 112, 1112, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 109, 112, 1112, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1109, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1109, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1109, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1109, 1111, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1109, 1111, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1109, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1109, 1111, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1109, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1109, 1111, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1109, 1112, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1109, 1112, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1109, 1111, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1109, 1112, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1109, 1112, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1109, 1112, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1111, 11109, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1111, 11109, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1112, 11109, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 11109, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1111, 11109, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1112, 11109, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1111, 11109, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1112, 11109, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1111, 11109, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1112, 11109, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1112, 11109, 11111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1111, 11109, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1112, 11109, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1112, 11109, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1112, 11109, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1111, 11111, 11113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1111, 11111, 11113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1112, 11111, 11113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 11112, 11113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1111, 11111, 11113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1112, 11111, 11113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1111, 11112, 11113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1112, 11111, 11113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1111, 11112, 11113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1112, 11112, 11113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1112, 11111, 11113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1111, 11112, 11113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1112, 11112, 11113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1112, 11112, 11113]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1112, 11112, 11113]))
end

function test_issubset5()
    Empty = SFSSFromOrderedVec(Int32[])
    A = SFSSFromOrderedVec([11, 111, 1111, 11111, 111111])
    # Size-5, Size-5 is subset
    @test SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 11111, 111111]))
    
    # Size-5 subset, smaller, not subset
    @test !SFSS_issubset(A, Empty)
    @test !SFSS_issubset(A, SFSSFromOrderedVec([50]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([1111]))    
    @test !SFSS_issubset(A, SFSSFromOrderedVec([50, 51]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 50]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([111, 150]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([1111, 150]))    
    @test !SFSS_issubset(A, SFSSFromOrderedVec([50, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([1111, 1150]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([50, 51, 52]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 51, 52]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([1111, 51, 52]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([51, 1111, 11112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 150, 1111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 1112]))
    # Size-5, Size-5, not subset
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1111, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1111, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1112, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 11112, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 11111, 111112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1111, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1112, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1111, 11112, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1111, 11111, 111112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1112, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1111, 11112, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1111, 11111, 111112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1112, 11112, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1112, 11111, 111112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1111, 11112, 111112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1112, 11111, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1111, 11112, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1111, 11111, 111112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1112, 11112, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1112, 11111, 111112]))    
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1111, 11112, 111112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1112, 11112, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1112, 11111, 111112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1111, 11112, 111112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 111, 1112, 11112, 111112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1112, 11112, 111111]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1112, 11111, 111112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1111, 11112, 111112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 111, 1112, 11112, 111112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([11, 112, 1112, 11112, 111112]))
    @test !SFSS_issubset(A, SFSSFromOrderedVec([12, 112, 1112, 11112, 111112]))    
end

function test_intersect()
    function run_test(Av::Vector{Int64}, Bv::Vector{Int64}, Cv::Vector{Int64})
        A = SFSSFromOrderedVec(Av)
        B = SFSSFromOrderedVec(Bv)
        C = SFSSFromOrderedVec(Cv)
        @test SFSS_intersect(A, B) == C
        @test SFSS_intersect(B, A) == C        
    end

    E = Int64[]
    
    run_test(E, [11], E)
    run_test(E, [11, 12], E)
    run_test(E, [11, 12, 13], E)
    run_test(E, [11, 12, 13, 14], E)
    run_test(E, [11, 12, 13, 14, 15], E)
    
    run_test([11], [12], E)
    run_test([11], [12, 13], E)
    run_test([11], [12, 13], E)
    run_test([11], [12, 13, 14], E)
    run_test([11], [12, 13, 14, 15], E)
    run_test([11], [12, 13, 14, 15, 16], E)

    run_test([11], [11], [11])
    run_test([11], [11, 13], [11])
    run_test([11], [11, 13, 14], [11])
    run_test([11], [11, 13, 14, 15], [11])
    run_test([11], [11, 13, 14, 15, 16], [11])
    run_test([13], [11, 13], [13])
    run_test([14], [11, 13, 14], [14])
    run_test([15], [11, 13, 14, 15], [15])
    run_test([16], [11, 13, 14, 15, 16], [16])

    run_test([11, 12], [21, 22], E)
    run_test([11, 12], [11, 22], [11])
    run_test([11, 12], [11, 12], [11, 12])
    run_test([11, 12], [9, 11], [11])
    run_test([11, 12], [12, 13], [12])        
    
    run_test([11, 111], [11, 22, 23], [11])
    run_test([11, 111], [9, 11, 12], [11])
    run_test([11, 111], [9, 10, 11], [11])
    run_test([11, 111], [111, 112, 113], [111])
    run_test([11, 111], [110, 111, 113], [111])
    run_test([11, 111], [109, 110, 111], [111])
    
    run_test([11, 111], [21, 22, 23, 24], E)
    run_test([11, 111], [11, 22, 23, 24], [11])
    run_test([11, 111], [9, 11, 23, 24], [11])
    run_test([11, 111], [8, 9, 11, 24], [11])
    run_test([11, 111], [8, 9, 10, 11], [11])
    run_test([11, 111], [111, 122, 123, 124], [111])
    run_test([11, 111], [19, 111, 123, 124], [111])
    run_test([11, 111], [8, 9, 111, 124], [111])
    run_test([11, 111], [8, 9, 10, 111], [111])

    run_test([11, 111], [11, 111, 122, 133], [11, 111])
    run_test([11, 111], [11, 12, 111, 133], [11, 111])
    run_test([11, 111], [11, 12, 13, 111], [11, 111])
    run_test([11, 111], [9, 11, 111, 122], [11, 111])
    run_test([11, 111], [9, 11, 110, 111], [11, 111])
    run_test([11, 111], [9, 10, 11, 111], [11, 111])

    run_test([11, 111, 2222], [12, 112, 123], E)
    run_test([11, 111, 2222], [9, 11, 123], [11])
    run_test([11, 111, 2222], [9, 10, 11], [11])
    run_test([11, 111, 2222], [111, 112, 122], [111])
    run_test([11, 111, 2222], [10, 111, 122], [111])
    run_test([11, 111, 2222], [10, 110, 111], [111])
    run_test([11, 111, 2222], [2222, 2223, 2224], [2222])
    run_test([11, 111, 2222], [2221, 2222, 2224], [2222])
    run_test([11, 111, 2222], [2220, 2221, 2222], [2222])        
    run_test([11, 111, 2222], [11, 111, 123], [11, 111])
    run_test([11, 111, 2222], [9, 11, 111], [11, 111])
    run_test([11, 111, 2222], [11, 12, 111], [11, 111])
    run_test([11, 111, 2222], [11, 112, 2222], [11, 2222])
    run_test([11, 111, 2222], [11, 2222, 2223], [11, 2222])
    run_test([11, 111, 2222], [9, 11, 2222], [11, 2222])
    run_test([11, 111, 2222], [11, 111, 2222], [11, 111, 2222])

    run_test([10, 20, 30], [100, 200, 300, 400], E)
    run_test([10, 20, 30], [10, 200, 300, 400], [10])
    run_test([10, 20, 30], [5, 20, 300, 400], [20])
    run_test([10, 20, 30], [11, 21, 30, 400], [30])
    run_test([10, 20, 30], [10, 20, 300, 400], [10, 20])
    run_test([10, 20, 30], [5, 6, 10, 20], [10, 20])
    run_test([10, 20, 30], [10, 30, 300, 400], [10, 30])
    run_test([10, 20, 30], [5, 6, 10, 30], [10, 30])
    run_test([10, 20, 30], [10, 20, 30, 40], [10, 20, 30])
    run_test([10, 20, 30], [10, 20, 25, 30], [10, 20, 30])
    run_test([10, 20, 30], [10, 15, 20, 30], [10, 20, 30])
    run_test([10, 20, 30], [5, 10, 20, 30], [10, 20, 30])
    run_test([10, 20, 30], [100, 200, 300, 400, 500], E)
    run_test([10, 20, 30], [10, 20, 30, 400, 500], [10, 20, 30])
    run_test([10, 20, 30], [5, 6, 10, 20, 30], [10, 20, 30])
    run_test([10, 20, 30], [5, 10, 16, 20, 30], [10, 20, 30])
    run_test([10, 20, 30], [5, 10, 20, 26, 30], [10, 20, 30])
    run_test([10, 20, 30], [5, 10, 20, 30, 36], [10, 20, 30])
    run_test([10, 20, 30], [5, 6, 11, 20, 30], [20, 30])
    run_test([10, 20, 30], [5, 11, 16, 20, 30], [20, 30])
    run_test([10, 20, 30], [5, 9, 20, 26, 30], [20, 30])
    run_test([10, 20, 30], [5, 9, 20, 30, 36], [20, 30])
    run_test([10, 20, 30], [5, 6, 10, 21, 30], [10, 30])
    run_test([10, 20, 30], [5, 10, 16, 21, 30], [10, 30])
    run_test([10, 20, 30], [5, 10, 21, 26, 30], [10, 30])
    run_test([10, 20, 30], [5, 10, 21, 30, 36], [10, 30])

    run_test([10, 20, 30, 40], [100, 200, 300, 400, 500], E)
    run_test([10, 20, 30, 40], [10, 20, 30, 40, 50], [10, 20, 30, 40])
    run_test([10, 20, 30, 40], [10, 20, 25, 30, 40], [10, 20, 30, 40])
    run_test([10, 20, 30, 40], [10, 12, 20, 30, 40], [10, 20, 30, 40])
    run_test([10, 20, 30, 40], [8, 10, 20, 30, 40], [10, 20, 30, 40])
    run_test([10, 20, 30, 40], [10, 21, 25, 30, 40], [10, 30, 40])
    run_test([10, 20, 30, 40], [10, 20, 25, 31, 40], [10, 20, 40])
    run_test([10, 20, 30, 40], [9, 20, 25, 30, 40], [20, 30, 40])
    run_test([10, 20, 30, 40], [10, 21, 25, 30, 41], [10, 30])
    run_test([10, 20, 30, 40], [10, 21, 25, 31, 40], [10, 40])
    run_test([10, 20, 30, 40], [9, 10, 21, 25, 40], [10, 40])
    run_test([10, 20, 30, 40], [9, 11, 20, 30, 41], [20, 30])
    run_test([10, 20, 30, 40], [9, 11, 20, 31, 41], [20])
    run_test([10, 20, 30, 40], [40, 41, 42, 43, 44], [40])

    run_test([10, 20, 30, 40, 50], [100, 200, 300, 400, 500], E)
    run_test([10, 20, 30, 40, 50], [10, 20, 30, 40, 50], [10, 20, 30, 40, 50])
    run_test([10, 20, 30, 40, 50], [10, 20, 30, 40, 51], [10, 20, 30, 40])
    run_test([10, 20, 30, 40, 50], [9, 10, 20, 30, 40], [10, 20, 30, 40])
    run_test([10, 20, 30, 40, 50], [10, 21, 30, 40, 50], [10, 30, 40, 50])
    run_test([10, 20, 30, 40, 50], [10, 30, 32, 40, 50], [10, 30, 40, 50])
    run_test([10, 20, 30, 40, 50], [10, 30, 40, 42, 50], [10, 30, 40, 50])
    run_test([10, 20, 30, 40, 50], [9, 10, 30, 40, 50], [10, 30, 40, 50])
    run_test([10, 20, 30, 40, 50], [10, 30, 40, 50, 60], [10, 30, 40, 50])
    run_test([10, 20, 30, 40, 50], [11, 20, 30, 40, 51], [20, 30, 40])
    run_test([10, 20, 30, 40, 50], [20, 21, 30, 40, 51], [20, 30, 40])
    run_test([10, 20, 30, 40, 50], [20, 30, 31, 40, 51], [20, 30, 40])
    run_test([10, 20, 30, 40, 50], [20, 30, 40, 41, 51], [20, 30, 40])
    run_test([10, 20, 30, 40, 50], [9, 20, 30, 40, 51], [20, 30, 40])
    run_test([10, 20, 30, 40, 50], [10, 21, 31, 40, 50], [10, 40, 50])
    run_test([10, 20, 30, 40, 50], [9, 10, 31, 40, 50], [10, 40, 50])
    run_test([10, 20, 30, 40, 50], [8, 9, 10, 40, 50], [10, 40, 50])
    run_test([10, 20, 30, 40, 50], [8, 9, 20, 33, 50], [20, 50])
    run_test([10, 20, 30, 40, 50], [8, 20, 21, 33, 50], [20, 50])
    run_test([10, 20, 30, 40, 50], [8, 20, 21, 50, 51], [20, 50])
    run_test([10, 20, 30, 40, 50], [8, 9, 20, 50, 51], [20, 50])
    run_test([10, 20, 30, 40, 50], [8, 9, 20, 53, 55], [20])
    run_test([10, 20, 30, 40, 50], [8, 20, 51, 53, 55], [20])
    run_test([10, 20, 30, 40, 50], [10, 21, 51, 53, 55], [10])
    run_test([10, 20, 30, 40, 50], [8, 9, 10, 53, 55], [10])
    run_test([10, 20, 30, 40, 50], [2, 3, 4, 5, 10], [10])
    run_test([10, 20, 30, 40, 50], [50, 51, 52, 53, 54], [50])
    run_test([10, 20, 30, 40, 50], [9, 50, 52, 53, 54], [50])
    run_test([10, 20, 30, 40, 50], [9, 11, 50, 52, 53], [50])
    run_test([10, 20, 30, 40, 50], [9, 11, 49, 50, 53], [50])
    run_test([10, 20, 30, 40, 50], [9, 11, 48, 49, 50], [50])
end

function test_setdiff()
    function run_test(Av::Vector{Int64}, Bv::Vector{Int64}, Cv::Vector{Int64})
        A = SFSSFromOrderedVec(Av)
        B = SFSSFromOrderedVec(Bv)
        C = SFSSFromOrderedVec(Cv)
        @test SFSS_setdiff(A, B) == C
    end

    function run_from_base(base::Vector{Int64})
        for r = 1:length(base)
            for inds in combinations(1:length(base), r)
                keep = ones(Bool, length(base))
                keep[inds] = false
                start = base[inds]
                result = base[keep]
                for additional = 0:(5 - length(start))
                    rest = [60 + j for j = 1:additional]
                    other_set = [start; rest]
                    run_test(base, other_set, result)
                end
            end
        end
    end
    run_from_base([10, 20, 30, 40, 50])
    run_from_base([10, 20, 30, 40])
    run_from_base([10, 20, 30])
    run_from_base([10, 20])
    run_from_base([10])
    run_from_base(Int64[])        
end

function test_union()
    function run_test(Av::Vector{Int64}, Bv::Vector{Int64})
        A = SFSSFromOrderedVec(Av)
        B = SFSSFromOrderedVec(Bv)
        C = SFSSFromVec(union(Av, Bv))
        @test SFSS_union(A, B) == C
        @test SFSS_union(B, A) == C
    end

    S = [10, 20, 30, 40, 50]
    nS = length(S)
    for r1 = 0:nS, r2 = 0:nS
        for c1 in combinations(S, r1)
            for c2 in combinations(S, r2)
                run_test(c1, c2)
            end
        end
    end
end

function test_random(num_trials::Int64)
    function run_test(A::Set{Int64}, B::Set{Int64},
                      sA::SmallFixedSizeSet, sB::SmallFixedSizeSet)
        @test (A ⊆ B) == SFSS_issubset(sA, sB)        
        C = A ∩ B
        sC = SFSS_intersect(sA, sB)
        @test SFSSFromSet(C) == sC
        D = setdiff(A, B)
        sD = SFSS_setdiff(sA, sB)
        @test SFSSFromSet(D) == sD
        U = C ∪ D
        sU = SFSSFromSet(U)
        @test SFSS_union(sC, sD) == sU
        @test SFSS_union(sC, sA) == sA
        @test SFSS_union(sA, sC) == sA
        @test SFSS_union(sC, sB) == sB
        @test SFSS_union(sB, sC) == sB
    end
    
    base = collect(1:15)
    for _ in 1:num_trials
        A = Set{Int64}(rand(base, rand(0:5)))
        B = Set{Int64}(rand(base, rand(0:5)))
        sA = SFSSFromSet(A)
        sB = SFSSFromSet(B)
        run_test(A, B, sA, sB)
    end
end

function test_all()
    test_issubset0()
    test_issubset1()
    test_issubset2()
    test_issubset3()
    test_issubset4()
    test_issubset5()        
    test_intersect()
    test_setdiff()
    test_union()
    test_random(5000)
end

test_all()
