From 224dc038412459a5f64d4e7a16845847b7797a67 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 17 Jun 2014 16:55:19 +0200 Subject: fix SubstVar to be usable as a replace_all method The name suggests that it is supposed to substitute a variable with a value, but we tend to use it in a more liberal replace_all() fashion, but this breaks if either of the parameters is empty or more importantly if two "variable" occurrences follow each other directly. --- test/libapt/strutil_test.cc | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'test') diff --git a/test/libapt/strutil_test.cc b/test/libapt/strutil_test.cc index bc004fd66..e9b778c6b 100644 --- a/test/libapt/strutil_test.cc +++ b/test/libapt/strutil_test.cc @@ -70,3 +70,38 @@ TEST(StrUtilTest,EndsWith) EXPECT_FALSE(Endswith("abcd", "x")); EXPECT_FALSE(Endswith("abcd", "abcndefg")); } +TEST(StrUtilTest,SubstVar) +{ + EXPECT_EQ("", SubstVar("", "fails", "passes")); + EXPECT_EQ("test ", SubstVar("test fails", "fails", "")); + EXPECT_EQ("test passes", SubstVar("test passes", "", "fails")); + + EXPECT_EQ("test passes", SubstVar("test passes", "fails", "passes")); + EXPECT_EQ("test passes", SubstVar("test fails", "fails", "passes")); + + EXPECT_EQ("starts with", SubstVar("beginnt with", "beginnt", "starts")); + EXPECT_EQ("beginnt with", SubstVar("starts with", "starts", "beginnt")); + EXPECT_EQ("is in middle", SubstVar("is in der middle", "in der", "in")); + EXPECT_EQ("is in der middle", SubstVar("is in middle", "in", "in der")); + EXPECT_EQ("does end", SubstVar("does enden", "enden", "end")); + EXPECT_EQ("does enden", SubstVar("does end", "end", "enden")); + + EXPECT_EQ("abc", SubstVar("abc", "d", "a")); + EXPECT_EQ("abc", SubstVar("abd", "d", "c")); + EXPECT_EQ("abc", SubstVar("adc", "d", "b")); + EXPECT_EQ("abc", SubstVar("dbc", "d", "a")); + + EXPECT_EQ("b", SubstVar("b", "aa", "a")); + EXPECT_EQ("bb", SubstVar("bb", "aa", "a")); + EXPECT_EQ("bbb", SubstVar("bbb", "aa", "a")); + + EXPECT_EQ("aa", SubstVar("aaaa", "aa", "a")); + EXPECT_EQ("aaaa", SubstVar("aa", "a", "aa")); + EXPECT_EQ("aaaa", SubstVar("aaaa", "a", "a")); + EXPECT_EQ("a a a a ", SubstVar("aaaa", "a", "a ")); + + EXPECT_EQ(" bb bb bb bb ", SubstVar(" a a a a ", "a", "bb")); + EXPECT_EQ(" bb bb bb bb ", SubstVar(" aaa aaa aaa aaa ", "aaa", "bb")); + EXPECT_EQ(" bb a bb a bb a bb ", SubstVar(" aaa a aaa a aaa a aaa ", "aaa", "bb")); + +} -- cgit v1.2.3 From 172947cd7dc5c88c94c6ad269dc6c6be002ee958 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 17 Jun 2014 19:05:53 +0200 Subject: do not call resolver twice on (dist-)upgrade --- test/integration/test-external-dependency-solver-protocol | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test') diff --git a/test/integration/test-external-dependency-solver-protocol b/test/integration/test-external-dependency-solver-protocol index 09230d383..07d2441b6 100755 --- a/test/integration/test-external-dependency-solver-protocol +++ b/test/integration/test-external-dependency-solver-protocol @@ -51,6 +51,12 @@ rm -f /tmp/dump.edsp testfailure aptget install --solver dump awesomecoolstuff:i386 -s testsuccess test -s /tmp/dump.edsp +testsuccess aptget dist-upgrade -s +testsuccess aptget dist-upgrade -s --solver apt + +testsuccess aptget upgrade -s +testsuccess aptget upgrade -s --solver apt + configarchitecture 'armel' msgtest 'Test direct calling is okay for' 'apt-internal-solver' cat /tmp/dump.edsp | aptinternalsolver > solver.result 2>&1 || true -- cgit v1.2.3