|
1 | | - |
2 | 1 | # Create a node: |
3 | 2 |
|
| 3 | +@testset "NodeMTG and MutableNodeMTG" begin |
| 4 | + # Test NodeMTG constructor with all arguments |
| 5 | + node_mtg = MultiScaleTreeGraph.NodeMTG("/", "Plant", 1, 2) |
| 6 | + @test node_mtg.link == "/" |
| 7 | + @test node_mtg.symbol == "Plant" |
| 8 | + @test node_mtg.index == 1 |
| 9 | + @test node_mtg.scale == 2 |
| 10 | + |
| 11 | + # Test NodeMTG constructor with nothing as index |
| 12 | + node_mtg_nothing = MultiScaleTreeGraph.NodeMTG("/", "Internode", nothing, 3) |
| 13 | + @test node_mtg_nothing.link == "/" |
| 14 | + @test node_mtg_nothing.symbol == "Internode" |
| 15 | + @test node_mtg_nothing.index == -9999 |
| 16 | + @test node_mtg_nothing.scale == 3 |
| 17 | + |
| 18 | + # Test MutableNodeMTG constructor with all arguments |
| 19 | + mutable_node_mtg = MultiScaleTreeGraph.MutableNodeMTG("+", "Leaf", 2, 4) |
| 20 | + @test mutable_node_mtg.link == "+" |
| 21 | + @test mutable_node_mtg.symbol == "Leaf" |
| 22 | + @test mutable_node_mtg.index == 2 |
| 23 | + @test mutable_node_mtg.scale == 4 |
| 24 | + |
| 25 | + # Test MutableNodeMTG constructor with nothing as index |
| 26 | + mutable_node_mtg_nothing = MultiScaleTreeGraph.MutableNodeMTG("<", "Apex", nothing, 5) |
| 27 | + @test mutable_node_mtg_nothing.link == "<" |
| 28 | + @test mutable_node_mtg_nothing.symbol == "Apex" |
| 29 | + @test mutable_node_mtg_nothing.index == -9999 |
| 30 | + @test mutable_node_mtg_nothing.scale == 5 |
| 31 | + |
| 32 | + # Test mutability of MutableNodeMTG |
| 33 | + mutable_node_mtg.link = "<" |
| 34 | + mutable_node_mtg.symbol = "Flower" |
| 35 | + mutable_node_mtg.index = 3 |
| 36 | + mutable_node_mtg.scale = 6 |
| 37 | + @test mutable_node_mtg.link == "<" |
| 38 | + @test mutable_node_mtg.symbol == "Flower" |
| 39 | + @test mutable_node_mtg.index == 3 |
| 40 | + @test mutable_node_mtg.scale == 6 |
| 41 | + |
| 42 | + # Test assertions |
| 43 | + @test_throws AssertionError MultiScaleTreeGraph.NodeMTG("/", "Plant", 1, -1) # scale < 0 |
| 44 | + @test_throws AssertionError MultiScaleTreeGraph.NodeMTG("invalid", "Plant", 1, 1) # invalid link |
| 45 | + @test_throws AssertionError MultiScaleTreeGraph.MutableNodeMTG("/", "Plant", 1, -1) # scale < 0 |
| 46 | + @test_throws AssertionError MultiScaleTreeGraph.MutableNodeMTG("invalid", "Plant", 1, 1) # invalid link |
| 47 | +end |
| 48 | + |
4 | 49 | @testset "Create node" begin |
5 | 50 | mtg_code = MultiScaleTreeGraph.NodeMTG("/", "Plant", 1, 1) |
6 | 51 | mtg = MultiScaleTreeGraph.Node(mtg_code) |
|
0 commit comments