summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2012-12-07 00:22:46 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2012-12-07 00:22:46 +0100
commitcccf98e6b02a468da02803348fa366a93108c7c3 (patch)
treea6e522e2406f4123ba267ca8075895a292c326fd
parentbf4995adde2f7994fa3443e1f142c609763676ba (diff)
Add selftests for location queries.
-rw-r--r--kconfigtest.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/kconfigtest.py b/kconfigtest.py
index f9cb275..00d06ce 100644
--- a/kconfigtest.py
+++ b/kconfigtest.py
@@ -140,7 +140,7 @@ def run_selftests():
# TODO: Get rid of extra \n's at end of texts?
- print "Testing various text queries..."
+ print "Testing text queries..."
c = kconfiglib.Config("Kconfiglib/tests/Ktext")
assert_equals(c["NO_HELP"].get_help(), None)
assert_equals(c["S"].get_help(), "help for\nS\n")
@@ -148,6 +148,25 @@ def run_selftests():
assert_equals(c.get_comments()[0].get_text(), "a comment")
assert_equals(c.get_menus()[0].get_title(), "a menu")
+ #
+ # Location queries
+ #
+
+ print "Testing location queries..."
+ kl = "Kconfiglib/tests/Klocation"
+ c = kconfiglib.Config(kl)
+ def assert_file_and_locations(filename, linenrs, tuples):
+ for f, l in tuples:
+ assert_true(f == filename, f)
+ assert_true(l == linenrs.pop(0), "!!!")
+ assert_file_and_locations(kl, [2, 14], c["A"].get_def_locations())
+ assert_file_and_locations(kl, [5, 6, 18, 19], c["A"].get_ref_locations())
+ assert_file_and_locations(kl, [7], c.get_choices()[0].get_def_locations())
+ assert_file_and_locations(kl, [4], [c.get_menus()[0].get_location()])
+ assert_file_and_locations(kl, [16], [c.get_comments()[0].get_location()])
+ assert_equals(c["NOT_DEFINED"].get_def_locations(), [])
+ assert_file_and_locations(kl, [6, 15], c["NOT_DEFINED"].get_ref_locations())
+
print
def run_compatibility_tests():