You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

78 lines
2.3 KiB

  1. #include <config.h>
  2. #include <apt-pkg/aptconfiguration.h>
  3. #include <apt-pkg/configuration.h>
  4. #include <string>
  5. #include <vector>
  6. #include <gtest/gtest.h>
  7. TEST(ArchitecturesTest,SimpleLists)
  8. {
  9. _config->Clear();
  10. std::vector<std::string> vec;
  11. _config->Set("APT::Architectures::1", "i386");
  12. _config->Set("APT::Architectures::2", "amd64");
  13. vec = APT::Configuration::getArchitectures(false);
  14. ASSERT_EQ(2, vec.size());
  15. EXPECT_EQ("i386", vec[0]);
  16. EXPECT_EQ("amd64", vec[1]);
  17. _config->Set("APT::Architecture", "i386");
  18. vec = APT::Configuration::getArchitectures(false);
  19. ASSERT_EQ(2, vec.size());
  20. EXPECT_EQ("i386", vec[0]);
  21. EXPECT_EQ("amd64", vec[1]);
  22. _config->Set("APT::Architectures::2", "");
  23. vec = APT::Configuration::getArchitectures(false);
  24. ASSERT_EQ(1, vec.size());
  25. EXPECT_EQ("i386", vec[0]);
  26. _config->Set("APT::Architecture", "armel");
  27. vec = APT::Configuration::getArchitectures(false);
  28. ASSERT_EQ(2, vec.size());
  29. EXPECT_EQ("armel", vec[0]);
  30. EXPECT_EQ("i386", vec[1]);
  31. _config->Set("APT::Architectures::2", "armel");
  32. vec = APT::Configuration::getArchitectures(false);
  33. ASSERT_EQ(2, vec.size());
  34. EXPECT_EQ("i386", vec[0]);
  35. EXPECT_EQ("armel", vec[1]);
  36. _config->Set("APT::Architectures", "armel,armhf");
  37. vec = APT::Configuration::getArchitectures(false);
  38. ASSERT_EQ(2, vec.size());
  39. EXPECT_EQ("armel", vec[0]);
  40. EXPECT_EQ("armhf", vec[1]);
  41. _config->Clear();
  42. }
  43. TEST(ArchitecturesTest,Duplicates)
  44. {
  45. _config->Clear();
  46. _config->Set("APT::Architecture", "armel");
  47. _config->Set("APT::Architectures::", "i386");
  48. _config->Set("APT::Architectures::", "amd64");
  49. _config->Set("APT::Architectures::", "i386");
  50. _config->Set("APT::Architectures::", "armel");
  51. _config->Set("APT::Architectures::", "i386");
  52. _config->Set("APT::Architectures::", "amd64");
  53. _config->Set("APT::Architectures::", "armel");
  54. _config->Set("APT::Architectures::", "armel");
  55. _config->Set("APT::Architectures::", "amd64");
  56. _config->Set("APT::Architectures::", "amd64");
  57. std::vector<std::string> vec = _config->FindVector("APT::Architectures");
  58. ASSERT_EQ(10, vec.size());
  59. vec = APT::Configuration::getArchitectures(false);
  60. ASSERT_EQ(3, vec.size());
  61. EXPECT_EQ("i386", vec[0]);
  62. EXPECT_EQ("amd64", vec[1]);
  63. EXPECT_EQ("armel", vec[2]);
  64. _config->Clear();
  65. }