using PoissonFE
using Test

@testset "PoissonFE.jl" begin
    y = [1.0, 0.0, 0.0, 0.0, 7.0, 1.0, 0.0, 1.0, 0.0, 0.0, 6.0,
    2.0, 3.0, 0.0, 1.0, 6.0, 0.0, 7.0, 0.0, 21.0]
    id = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
    X = [0.398106 0.496961; -0.612026 -0.224875; 0.34112 -1.11714;
    -1.12936 -0.394995; 1.43302 1.54983; 1.9804 -0.743514; -0.367221 -2.33171;
    -1.04413 0.812245; 0.56972 -0.501311; -0.135055 -0.510887;
    2.40162 -1.21536; -0.03924 -0.0225586; 0.689739 0.701239;
    0.0280022 -0.587482; -0.743273 -0.606728; 0.188792 1.09664;
    -1.80496 -0.24751; 1.46555 -0.159902; 0.153253 -0.625778;
    2.17261 0.900435]
    m = PoissonFEModel(y, X, id)
    @test isa(m, PoissonFEModel)
    coefs, se = fit(m)
    @test isapprox(coefs, [0.9244995462032737, 0.8693710731458504]; rtol=0.00001)
    @test isapprox(se, [0.013507707199824406, 0.12757995666403202]; rtol=0.00001)
end
