Skip to content

Commit 905d5fe

Browse files
committed
Make test to compare outputs to docs
Compares the online documentation fields to the list generated from the dict in the repo. Does not actually interact with RTDE, so should be robot-version agnostic.
1 parent 9db3034 commit 905d5fe

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

tests/test_rtde_client.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <optional>
3434
#include <unordered_map>
3535
#include <utility>
36+
#include <iostream>
3637
#include "ur_client_library/exceptions.h"
3738

3839
#include <ur_client_library/rtde/rtde_client.h>
@@ -59,6 +60,7 @@ class RTDEClientTest : public ::testing::Test
5960

6061
std::string output_recipe_file_ = "resources/rtde_output_recipe.txt";
6162
std::string exhaustive_output_recipe_file_ = "resources/exhaustive_rtde_output_recipe.txt";
63+
std::string docs_output_recipe_file_ = "resources/docs_rtde_output_recipe.txt";
6264
std::string input_recipe_file_ = "resources/rtde_input_recipe.txt";
6365
comm::INotifier notifier_;
6466
std::unique_ptr<rtde_interface::RTDEClient> client_;
@@ -410,6 +412,51 @@ TEST_F(RTDEClientTest, check_all_rtde_output_variables_exist)
410412
client_->pause();
411413
}
412414

415+
TEST_F(RTDEClientTest, check_rtde_data_fields_match_docs)
416+
{
417+
std::ifstream docs_file(docs_output_recipe_file_);
418+
std::ifstream pkg_file(exhaustive_output_recipe_file_);
419+
std::vector<std::string> docs_outputs;
420+
std::string line;
421+
while (std::getline(docs_file, line))
422+
{
423+
docs_outputs.push_back(line);
424+
}
425+
std::vector<std::string> pkg_outputs;
426+
while (std::getline(pkg_file, line))
427+
{
428+
pkg_outputs.push_back(line);
429+
}
430+
std::sort(docs_outputs.begin(), docs_outputs.end());
431+
std::sort(pkg_outputs.begin(), pkg_outputs.end());
432+
if (!std::is_permutation(docs_outputs.begin(), docs_outputs.end(), pkg_outputs.begin(), pkg_outputs.end()))
433+
{
434+
std::cout << "Data package output fields do not match output fields in documentation" << std::endl;
435+
std::unordered_map<std::string, int> diff;
436+
std::cout << "Differences: " << std::endl;
437+
for (auto name : docs_outputs)
438+
{
439+
diff[name] += 1;
440+
}
441+
for (auto name : pkg_outputs)
442+
{
443+
diff[name] -= 1;
444+
}
445+
for (auto elem : diff)
446+
{
447+
if (elem.second > 0)
448+
{
449+
std::cout << elem.first << " exists in documentation, but not in data package dict." << std::endl;
450+
}
451+
if (elem.second < 0)
452+
{
453+
std::cout << elem.first << " exists in data package dict, but not in documentation." << std::endl;
454+
}
455+
}
456+
GTEST_FAIL();
457+
}
458+
}
459+
413460
TEST_F(RTDEClientTest, check_unknown_rtde_output_variable)
414461
{
415462
client_->init();

0 commit comments

Comments
 (0)