Mercurial > repos > public > sbplib_julia
diff test/Grids/grid_test.jl @ 1270:dcbac783e4c1 refactor/grids
Factor out functions for getting the type and number of components in a type
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sat, 25 Feb 2023 22:42:16 +0100 |
parents | 20f42cf0800c |
children | 3637daad71e8 |
line wrap: on
line diff
--- a/test/Grids/grid_test.jl Sat Feb 25 22:22:50 2023 +0100 +++ b/test/Grids/grid_test.jl Sat Feb 25 22:42:16 2023 +0100 @@ -45,3 +45,23 @@ @testset "getcomponent" begin @test_broken false end + +@testset "_ncomponents" begin + @test Grids._ncomponents(Int) == 1 + @test Grids._ncomponents(Float64) == 1 + @test Grids._ncomponents(Rational) == 1 + + @test Grids._ncomponents(SVector{3,Int}) == 3 + @test Grids._ncomponents(SVector{2,Float64}) == 2 + @test Grids._ncomponents(SVector{4,Rational}) == 4 +end + +@testset "_component_type" begin + @test Grids._component_type(Int) == Int + @test Grids._component_type(Float64) == Float64 + @test Grids._component_type(Rational) == Rational + + @test Grids._component_type(SVector{3,Int}) == Int + @test Grids._component_type(SVector{2,Float64}) == Float64 + @test Grids._component_type(SVector{4,Rational}) == Rational +end