testDebuggerVariablesManager.cxx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include <functional>
  4. #include <memory>
  5. #include <vector>
  6. #include <cm3p/cppdap/protocol.h>
  7. #include <cm3p/cppdap/types.h>
  8. #include <stdint.h>
  9. #include "cmDebuggerVariables.h"
  10. #include "cmDebuggerVariablesManager.h"
  11. #include "testCommon.h"
  12. static bool testVariablesRegistration()
  13. {
  14. auto variablesManager =
  15. std::make_shared<cmDebugger::cmDebuggerVariablesManager>();
  16. int64_t line = 5;
  17. auto local = std::make_shared<cmDebugger::cmDebuggerVariables>(
  18. variablesManager, "Local", true, [=]() {
  19. return std::vector<cmDebugger::cmDebuggerVariableEntry>{ { "CurrentLine",
  20. line } };
  21. });
  22. dap::VariablesRequest variableRequest;
  23. variableRequest.variablesReference = local->GetId();
  24. dap::array<dap::Variable> variables =
  25. variablesManager->HandleVariablesRequest(variableRequest);
  26. ASSERT_TRUE(variables.size() == 1);
  27. local.reset();
  28. variables = variablesManager->HandleVariablesRequest(variableRequest);
  29. ASSERT_TRUE(variables.size() == 0);
  30. return true;
  31. }
  32. int testDebuggerVariablesManager(int, char*[])
  33. {
  34. return runTests(std::vector<std::function<bool()>>{
  35. testVariablesRegistration,
  36. });
  37. }