diff --git a/src/tests/testSgfParser.py b/src/tests/testSgfParser.py --- a/src/tests/testSgfParser.py +++ b/src/tests/testSgfParser.py @@ -1,7 +1,9 @@ +from itertools import chain import unittest from unittest import TestCase import os +from sgfParser import strRowCol from sgfParser.collection import Collection from sgfParser.property import Property @@ -9,6 +11,21 @@ from sgfParser.property import Property dataDir=os.path.join(os.path.dirname(__file__), "data") +class TestUtils(TestCase): + def testTextPos(self): + s="abc\ndef\rgh\r\nij\n\rklmn" + rc=[ + [1,2,3,4], + [1,2,3,4], + [1,2,3,4], + [1,2,3], [1], # don't care about LFCR, we unicode now + [1,2,3,4] + ] + res=chain((r+1,c) for (r,row) in enumerate(rc) for c in row) + for (i,(r,c)) in zip(range(len(s)+1), res): + self.assertEqual(strRowCol(s, i), (r, c)) + + class TestProperty(TestCase): def testName(self): with self.assertRaises(AssertionError):