|
| 1 | +BUILTIN_GROUP = Group(:builtin) |
| 2 | +USER_GROUP = Group(:user) |
| 3 | +TEST_GROUP = Group(:test) |
| 4 | + |
| 5 | +# list_groups |
| 6 | +groups = list_groups() |
| 7 | +@test isa(groups, Vector) |
| 8 | +@test all(isa.(groups, Group)) |
| 9 | +@test BUILTIN_GROUP ∈ groups && USER_GROUP ∈ groups |
| 10 | + |
| 11 | +# add_to_groups |
| 12 | +add_to_groups(Matrix, USER_GROUP) |
| 13 | +@test Matrix ∈ list_matrices(USER_GROUP) |
| 14 | +@test_throws ArgumentError add_to_groups(Matrix, BUILTIN_GROUP) |
| 15 | + |
| 16 | +# add_to_groups alternative interfaces |
| 17 | +@test isnothing(add_to_groups(Matrix, USER_GROUP, TEST_GROUP)) |
| 18 | +@test isnothing(add_to_groups(Matrix, [USER_GROUP, TEST_GROUP])) |
| 19 | +@test isnothing(add_to_groups(Matrix, :user, :test)) |
| 20 | +@test isnothing(add_to_groups(Matrix, [:user, :test])) |
| 21 | + |
| 22 | +# add_to_groups cleanup |
| 23 | +remove_from_all_groups(Matrix) |
| 24 | + |
| 25 | +# remove_from_group |
| 26 | +add_to_groups(Matrix, USER_GROUP) |
| 27 | +remove_from_group(Matrix, USER_GROUP) |
| 28 | +@test Matrix ∉ list_matrices(USER_GROUP) |
| 29 | +@test_throws ArgumentError remove_from_group(Matrix, BUILTIN_GROUP) |
| 30 | +@test_throws ArgumentError remove_from_group(Matrix, USER_GROUP) |
| 31 | +@test_throws ArgumentError remove_from_group(Matrix, Group(:notexists)) |
| 32 | + |
| 33 | +# remove_from_all_groups |
| 34 | +add_to_groups(Matrix, USER_GROUP, TEST_GROUP) |
| 35 | +add_to_groups(Tridiagonal, USER_GROUP, TEST_GROUP) |
| 36 | +remove_from_all_groups(Matrix) |
| 37 | +@test Matrix ∉ list_matrices(USER_GROUP) |
| 38 | +@test Matrix ∉ list_matrices(TEST_GROUP) |
| 39 | +remove_from_all_groups(Tridiagonal) |
| 40 | + |
| 41 | +# list_matrices |
| 42 | +matrices = list_matrices() |
| 43 | +@test isa(matrices, Vector) |
| 44 | +@test all(isa.(matrices, Type)) |
| 45 | +@test_throws ArgumentError list_matrices(:notexists) |
| 46 | +@test_throws ArgumentError list_matrices(Property(:notexists)) |
| 47 | +@test_throws ArgumentError list_matrices(Group(:notexists)) |
| 48 | + |
| 49 | +# list_matrices filtering |
| 50 | +@properties Matrix [:symmetric, :inverse] |
| 51 | +add_to_groups(Matrix, USER_GROUP, TEST_GROUP) |
| 52 | +@test Matrix ∉ list_matrices(:posdef) |
| 53 | +@test Matrix ∈ list_matrices(:symmetric) |
| 54 | +@test Matrix ∈ list_matrices(:inverse) |
| 55 | +@test Matrix ∈ list_matrices(:symmetric, :inverse) |
| 56 | +@test Matrix ∉ list_matrices(:symmetric, :inverse, :posdef) |
| 57 | +@test Matrix ∉ list_matrices(BUILTIN_GROUP) |
| 58 | +@test Matrix ∈ list_matrices(USER_GROUP) |
| 59 | +@test Matrix ∈ list_matrices(TEST_GROUP) |
| 60 | +@test Matrix ∈ list_matrices(USER_GROUP, TEST_GROUP) |
| 61 | +@test Matrix ∉ list_matrices(BUILTIN_GROUP, USER_GROUP, TEST_GROUP) |
| 62 | + |
| 63 | +# list_matrices alternative interfaces |
| 64 | +@test Matrix ∈ list_matrices(Property(:symmetric), Property(:inverse)) |
| 65 | +@test Matrix ∈ list_matrices([Property(:symmetric), Property(:inverse)]) |
| 66 | +@test Matrix ∈ list_matrices(:symmetric, :inverse) |
| 67 | +@test Matrix ∈ list_matrices([:symmetric, :inverse]) |
| 68 | +@test Matrix ∈ list_matrices(PropertyTypes.Symmetric, PropertyTypes.Inverse) |
| 69 | +@test Matrix ∈ list_matrices([PropertyTypes.Symmetric, PropertyTypes.Inverse]) |
| 70 | +@test Matrix ∈ list_matrices(PropertyTypes.Symmetric(), PropertyTypes.Inverse()) |
| 71 | +@test Matrix ∈ list_matrices([PropertyTypes.Symmetric(), PropertyTypes.Inverse()]) |
| 72 | +@test Matrix ∈ list_matrices(USER_GROUP, TEST_GROUP) |
| 73 | +@test Matrix ∈ list_matrices([USER_GROUP, TEST_GROUP]) |
0 commit comments