From cccf98e6b02a468da02803348fa366a93108c7c3 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Fri, 7 Dec 2012 00:22:46 +0100 Subject: Add selftests for location queries. --- kconfigtest.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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(): -- cgit v1.2.3