@@ -143,6 +143,27 @@ test_that(".ExpandTntRange() handles A.B, A. and A.A", {
143143 expect_equal(TreeTools ::: .ExpandTntRange(" 2.2" , 10L ), 3L )
144144})
145145
146+ test_that(" ReadXgroup() handles xgroup lines without parenthetical label" , {
147+ tmp <- tempfile(fileext = " .tnt" )
148+ on.exit(unlink(tmp ), add = TRUE )
149+ writeLines(c(" xread" , " 6 4" ,
150+ " TaxonA 010101" , " TaxonB 010101" ,
151+ " TaxonC 101010" , " TaxonD 101010" , " ;" ,
152+ " xgroup =0 0.2 ;" ,
153+ " xgroup =1 3. ;" , " ;" , " proc/;" ), tmp )
154+ xg <- ReadXgroup(tmp )
155+ expect_length(xg , 6L )
156+ expect_equal(unname(xg ), c(0L , 0L , 0L , 1L , 1L , 1L ))
157+ expect_equal(unname(names(xg )), c(" 0" , " 0" , " 0" , " 1" , " 1" , " 1" ))
158+ })
159+
160+ test_that(" .TntNChar() returns NULL for malformed dimension line" , {
161+ tmp <- tempfile(fileext = " .tnt" )
162+ on.exit(unlink(tmp ), add = TRUE )
163+ writeLines(c(" xread" , " 6" , " ;" , " proc/;" ), tmp )
164+ expect_null(ReadXgroup(tmp ))
165+ })
166+
146167test_that(" ReadTntTree() NULL return" , {
147168 expect_null(ReadTntTree(TestFile(" ape-tree.nex" )))
148169})
0 commit comments