summaryrefslogtreecommitdiff
path: root/test/libapt
diff options
context:
space:
mode:
Diffstat (limited to 'test/libapt')
-rw-r--r--test/libapt/getlanguages_test.cc71
-rw-r--r--test/libapt/globalerror_test.cc32
-rwxr-xr-xtest/libapt/run-tests7
3 files changed, 78 insertions, 32 deletions
diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc
index 3559aae0c..707142aef 100644
--- a/test/libapt/getlanguages_test.cc
+++ b/test/libapt/getlanguages_test.cc
@@ -26,16 +26,18 @@ int main(int argc,char *argv[])
env[1] = "";
std::vector<std::string> vec = APT::Configuration::getLanguages(false, false, env);
- equals(vec.size(), 2);
- equals(vec[0], "de");
- equals(vec[1], "en");
+ equals(vec.size(), 3);
+ equals(vec[0], "de_DE");
+ equals(vec[1], "de");
+ equals(vec[2], "en");
// Special: Check if the cache is actually in use
env[0] = "en_GB.UTF-8";
vec = APT::Configuration::getLanguages(false, true, env);
- equals(vec.size(), 2);
- equals(vec[0], "de");
- equals(vec[1], "en");
+ equals(vec.size(), 3);
+ equals(vec[0], "de_DE");
+ equals(vec[1], "de");
+ equals(vec[2], "en");
env[0] = "en_GB.UTF-8";
vec = APT::Configuration::getLanguages(false, false, env);
@@ -52,19 +54,21 @@ int main(int argc,char *argv[])
env[0] = "tr_DE@euro";
vec = APT::Configuration::getLanguages(false, false, env);
- equals(vec.size(), 2);
- equals(vec[0], "tr");
- equals(vec[1], "en");
+ equals(vec.size(), 3);
+ equals(vec[0], "tr_DE");
+ equals(vec[1], "tr");
+ equals(vec[2], "en");
env[0] = "de_NO";
- env[1] = "se_NO:en_GB:nb_NO:nb:no_NO:no:nn_NO:nn:da:sv:en";
+ env[1] = "de_NO:en_GB:nb_NO:nb:no_NO:no:nn_NO:nn:da:sv:en";
vec = APT::Configuration::getLanguages(false, false, env);
- equals(vec.size(), 5);
- equals(vec[0], "de");
- equals(vec[1], "en_GB");
- equals(vec[2], "nb");
- equals(vec[3], "no");
- equals(vec[4], "en");
+ equals(vec.size(), 6);
+ equals(vec[0], "de_NO");
+ equals(vec[1], "de");
+ equals(vec[2], "en_GB");
+ equals(vec[3], "nb_NO");
+ equals(vec[4], "nb");
+ equals(vec[5], "en");
env[0] = "pt_PR.UTF-8";
env[1] = "";
@@ -76,9 +80,10 @@ int main(int argc,char *argv[])
env[0] = "ast_DE.UTF-8";
vec = APT::Configuration::getLanguages(false, false, env); // bogus, but syntactical correct
- equals(vec.size(), 2);
- equals(vec[0], "ast");
- equals(vec[1], "en");
+ equals(vec.size(), 3);
+ equals(vec[0], "ast_DE");
+ equals(vec[1], "ast");
+ equals(vec[2], "en");
env[0] = "C";
vec = APT::Configuration::getLanguages(false, false, env);
@@ -113,25 +118,28 @@ int main(int argc,char *argv[])
_config->Set("Acquire::Languages::2", "en");
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(false, false, env);
- equals(vec.size(), 2);
- equals(vec[0], "de");
- equals(vec[1], "en");
+ equals(vec.size(), 3);
+ equals(vec[0], "de_DE");
+ equals(vec[1], "de");
+ equals(vec[2], "en");
_config->Set("Acquire::Languages::3", "de");
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(false, false, env);
- equals(vec.size(), 2);
- equals(vec[0], "de");
- equals(vec[1], "en");
+ equals(vec.size(), 3);
+ equals(vec[0], "de_DE");
+ equals(vec[1], "de");
+ equals(vec[2], "en");
_config->Set("Dir::State::lists", argv[1]);
vec = APT::Configuration::getLanguages(true, false, env);
- equals(vec.size(), 5);
- equals(vec[0], "de");
- equals(vec[1], "en");
- equals(vec[2], "none");
- equals(vec[3], "pt");
- equals(vec[4], "tr");
+ equals(vec.size(), 6);
+ equals(vec[0], "de_DE");
+ equals(vec[1], "de");
+ equals(vec[2], "en");
+ equals(vec[3], "none");
+ equals(vec[4], "pt");
+ equals(vec[5], "tr");
_config->Set("Dir::State::lists", "/non-existing-dir");
_config->Set("Acquire::Languages::1", "none");
@@ -140,6 +148,7 @@ int main(int argc,char *argv[])
equals(vec.size(), 0);
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(true, false, env);
+ equals(vec.size(), 2);
equals(vec[0], "en");
equals(vec[1], "de");
diff --git a/test/libapt/globalerror_test.cc b/test/libapt/globalerror_test.cc
index b2752255f..7d933f5a8 100644
--- a/test/libapt/globalerror_test.cc
+++ b/test/libapt/globalerror_test.cc
@@ -2,6 +2,7 @@
#include "assert.h"
#include <string>
+#include <errno.h>
int main(int argc,char *argv[])
{
@@ -73,5 +74,36 @@ int main(int argc,char *argv[])
equals(text, "A Warning");
equals(_error->empty(), true);
+ errno = 0;
+ equals(_error->Errno("errno", "%s horrible %s %d times", "Something", "happend", 2), false);
+ equals(_error->empty(), false);
+ equals(_error->PendingError(), true);
+ equals(_error->PopMessage(text), true);
+ equals(_error->PendingError(), false);
+ equals(text, "Something horrible happend 2 times - errno (0: Success)");
+ equals(_error->empty(), true);
+
+ std::string longText;
+ for (size_t i = 0; i < 500; ++i)
+ longText.append("a");
+ equals(_error->Error("%s horrible %s %d times", longText.c_str(), "happend", 2), false);
+ equals(_error->PopMessage(text), true);
+ equals(text, std::string(longText).append(" horrible happend 2 times"));
+
+ equals(_error->Errno("errno", "%s horrible %s %d times", longText.c_str(), "happend", 2), false);
+ equals(_error->PopMessage(text), true);
+ equals(text, std::string(longText).append(" horrible happend 2 times - errno (0: Success)"));
+
+ equals(_error->Warning("Репозиторий не обновлён и будут %d %s", 4, "test"), false);
+ equals(_error->PopMessage(text), false);
+ equals(text, "Репозиторий не обновлён и будут 4 test");
+
+ longText.clear();
+ for (size_t i = 0; i < 50; ++i)
+ longText.append("РезийбёбAZ");
+ equals(_error->Warning(longText.c_str()), false);
+ equals(_error->PopMessage(text), false);
+ equals(text, longText);
+
return 0;
}
diff --git a/test/libapt/run-tests b/test/libapt/run-tests
index f5fc03446..4b71c2097 100755
--- a/test/libapt/run-tests
+++ b/test/libapt/run-tests
@@ -1,7 +1,7 @@
#!/bin/sh
set -e
-local DIR=$(readlink -f $(dirname $0))
+DIR=$(readlink -f $(dirname $0))
echo "Compiling the tests …"
test -d "$DIR/../../build/obj/test/libapt/" || mkdir -p "$DIR/../../build/obj/test/libapt/"
(cd $DIR && make)
@@ -39,6 +39,11 @@ do
"${tmppath}/invälid.conf" \
"${tmppath}/invalíd" \
"${tmppath}/01invalíd"
+ mkdir "${tmppath}/invaliddir" \
+ "${tmppath}/directory.conf" \
+ "${tmppath}/directory.list" \
+ "${tmppath}/directory.wron" \
+ "${tmppath}/directory.list.disabled"
ln -s "${tmppath}/anormalfile" "${tmppath}/linkedfile.list"
ln -s "${tmppath}/non-existing-file" "${tmppath}/brokenlink.list"
elif [ $name = "getLanguages${EXT}" ]; then