mtest.cpp
Go to the documentation of this file.
1 /*
2  * MAVLink C++11 test runner.
3  *
4  * Run command (ubuntu):
5 
6  g++ -std=c++11 -I mavlink/common -I /usr/src/gtest -pthread mtest.cpp /usr/src/gtest/src/gtest-all.cc && ./a.out
7 
8  * NOTE:
9  * - mavlink is a directory with geterated C and C++ library.
10  * - by changing "common" to other dialect may select another messages
11  */
12 
13 #include <iostream>
14 #include <array>
15 
16 //#define PRINT_MSG(m) print_msg(m)
17 namespace mavlink {
18 struct __mavlink_message;
19 void print_msg(struct __mavlink_message &m);
20 }
21 
22 // Since C++11 do not have things like std::to_array() which needs C++14 features
23 template<size_t _N>
24 std::array<char, _N> to_char_array(const char (&a)[_N])
25 {
26  std::array<char, _N> out{};
27  std::copy(a, a+_N, out.begin());
28  return out;
29 }
30 
31 #define TEST_INTEROP
32 #include "gtestsuite.hpp"
33 
35 {
36  return nullptr;
37 }
38 
40 {
41  std::cout << std::hex << std::setfill('0')
42  << "msgid: " << std::setw(6) << m.msgid
43  << " len: " << std::setw(2) << +m.len
44  << " crc: " << std::setw(4) << m.checksum
45  << " p:";
46  for (size_t i = 0; i < MAVLINK_MAX_PAYLOAD_LEN; i++)
47  std::cout << " " << std::hex << std::setw(2) << std::setfill('0') << +(_MAV_PAYLOAD(&m)[i]);
48 
49  std::cout << std::endl;
50 }
51 
52 int main(int argc, char *argv[])
53 {
54  ::testing::InitGoogleTest(&argc, argv);
55  return RUN_ALL_TESTS();
56 }
std::array< char, _N > to_char_array(const char(&a)[_N])
Definition: mtest.cpp:24
int main(int argc, char *argv[])
Definition: mtest.cpp:52


mavlink
Author(s): Lorenz Meier
autogenerated on Sun Jul 7 2019 03:22:07