test_tc_config.cpp 942 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include "util/tc_config.h"
  2. #include "util/tc_common.h"
  3. #include <cmath>
  4. #include "gtest/gtest.h"
  5. #include <iostream>
  6. #include <vector>
  7. using namespace std;
  8. using namespace tars;
  9. class UtilConfigTest : public testing::Test
  10. {
  11. public:
  12. //添加日志
  13. static void SetUpTestCase()
  14. {
  15. }
  16. static void TearDownTestCase()
  17. {
  18. }
  19. virtual void SetUp() //TEST跑之前会执行SetUp
  20. {
  21. }
  22. virtual void TearDown() //TEST跑完之后会执行TearDown
  23. {
  24. }
  25. };
  26. #define CONFIG "<root>\r\n</root>"
  27. TEST_F(UtilConfigTest, config_test)
  28. {
  29. TC_Config conf;
  30. conf.parseString(CONFIG);
  31. conf.set("/root<abc>", "def");
  32. ASSERT_TRUE(conf.get("/root<abc>") == "def");
  33. conf.set("/root/test<abc>", "defdef");
  34. ASSERT_TRUE(conf.get("/root/test<abc>") == "defdef");
  35. conf.erase("/root/test<abc>");
  36. ASSERT_TRUE(conf.get("/root/test<abc>") == "");
  37. conf.eraseDomain("/root/test");
  38. auto v =conf.getDomainVector("/root");
  39. ASSERT_TRUE(v.empty());
  40. }