@@ -1729,6 +1729,61 @@ function test_unsupported_objectives()
17291729 return
17301730end
17311731
1732+ function test_LineToItems ()
1733+ for line in [
1734+ " a" ,
1735+ " a " ,
1736+ " a b" ,
1737+ " a b " ,
1738+ " a b c" ,
1739+ " a b c " ,
1740+ " a b c d" ,
1741+ " a b c d " ,
1742+ " a b c d e" ,
1743+ " a b c d e " ,
1744+ ]
1745+ @test collect (MPS. LineToItems (line)) ==
1746+ split (line, ' ' ; keepempty = false )
1747+ end
1748+ items = MPS. LineToItems (" a b c d e f g" )
1749+ @test length (items) == 7
1750+ @test_throws BoundsError items[0 ]
1751+ @test items[1 ] == " a"
1752+ @test_throws BoundsError items[6 ]
1753+ items = MPS. LineToItems (" a b" )
1754+ @test length (items) == 2
1755+ @test_throws BoundsError items[3 ]
1756+ return
1757+ end
1758+
1759+ function test_parse_header ()
1760+ for (line, header) in [
1761+ " OBJSENSE" => MPS. HEADER_OBJSENSE,
1762+ " OBJSENSE MAX" => MPS. HEADER_OBJSENSE,
1763+ " ROWS" => MPS. HEADER_ROWS,
1764+ " COLUMNS" => MPS. HEADER_COLUMNS,
1765+ " RHS" => MPS. HEADER_RHS,
1766+ " RANGES" => MPS. HEADER_RANGES,
1767+ " BOUNDS" => MPS. HEADER_BOUNDS,
1768+ " SOS" => MPS. HEADER_SOS,
1769+ " ENDATA" => MPS. HEADER_ENDATA,
1770+ " QUADOBJ" => MPS. HEADER_QUADOBJ,
1771+ " QMATRIX" => MPS. HEADER_QMATRIX,
1772+ " QCMATRIX c" => MPS. HEADER_QCMATRIX,
1773+ " QSECTION c" => MPS. HEADER_QSECTION,
1774+ " INDICATORS" => MPS. HEADER_INDICATORS,
1775+ " " => MPS. HEADER_UNKNOWN,
1776+ " Foo" => MPS. HEADER_UNKNOWN,
1777+ " rhs x" => MPS. HEADER_UNKNOWN,
1778+ ]
1779+ items = MPS. LineToItems (line)
1780+ @test header == MPS. parse_header (items)
1781+ items = MPS. LineToItems (lowercase (line))
1782+ @test header == MPS. parse_header (items)
1783+ end
1784+ return
1785+ end
1786+
17321787end # TestMPS
17331788
17341789TestMPS. runtests ()
0 commit comments