test_node_test.cpp 712 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright (C) 2015 Pavel Kirienko <pavel.kirienko@gmail.com>
  3. */
  4. #include <gtest/gtest.h>
  5. #include "test_node.hpp"
  6. TEST(TestNode, TestNetwork)
  7. {
  8. TestNetwork<4> nwk;
  9. uavcan::CanFrame frame;
  10. for (uint8_t i = 0; i < 8; i++)
  11. {
  12. frame.data[i] = i;
  13. }
  14. frame.id = 1234U;
  15. ASSERT_EQ(1, nwk.nodes[0]->can_driver.send(frame, uavcan::MonotonicTime(), uavcan::CanIOFlags()));
  16. for (int i = 1; i < 4; i++)
  17. {
  18. uavcan::CanFrame rx;
  19. uavcan::MonotonicTime ts_mono;
  20. uavcan::UtcTime ts_utc;
  21. uavcan::CanIOFlags flags = 0;
  22. ASSERT_EQ(1, nwk.nodes[i]->can_driver.receive(rx, ts_mono, ts_utc, flags));
  23. ASSERT_TRUE(rx == frame);
  24. }
  25. }