st_utest.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* SPDX-License-Identifier: MIT */
  2. /* Copyright (c) 2013-2024 The SRS Authors */
  3. #include <st_utest.hpp>
  4. #include <st.h>
  5. #include <assert.h>
  6. std::ostream& operator<<(std::ostream& out, const ErrorObject* err) {
  7. if (!err) return out;
  8. if (err->r0_) out << "r0=" << err->r0_;
  9. if (err->errno_) out << ", errno=" << err->errno_;
  10. if (!err->message_.empty()) out << ", msg=" << err->message_;
  11. return out;
  12. }
  13. // We could do something in the main of utest.
  14. // Copy from gtest-1.6.0/src/gtest_main.cc
  15. GTEST_API_ int main(int argc, char **argv) {
  16. // Select the best event system available on the OS. In Linux this is
  17. // epoll(). On BSD it will be kqueue. On Cygwin it will be select.
  18. #if __CYGWIN__
  19. assert(st_set_eventsys(ST_EVENTSYS_SELECT) != -1);
  20. #else
  21. assert(st_set_eventsys(ST_EVENTSYS_ALT) != -1);
  22. #endif
  23. // Initialize state-threads, create idle coroutine.
  24. assert(st_init() == 0);
  25. testing::InitGoogleTest(&argc, argv);
  26. return RUN_ALL_TESTS();
  27. }
  28. // basic test and samples.
  29. VOID TEST(SampleTest, ExampleIntSizeTest)
  30. {
  31. EXPECT_EQ(1, (int)sizeof(int8_t));
  32. EXPECT_EQ(2, (int)sizeof(int16_t));
  33. EXPECT_EQ(4, (int)sizeof(int32_t));
  34. EXPECT_EQ(8, (int)sizeof(int64_t));
  35. }