2021-10-02 00:54:53 +00:00
|
|
|
/* SPDX-License-Identifier: MIT */
|
2023-01-01 00:45:39 +00:00
|
|
|
/* Copyright (c) 2013-2023 Winlin */
|
2021-03-03 02:26:30 +00:00
|
|
|
|
|
|
|
#include <st_utest.hpp>
|
|
|
|
|
|
|
|
#include <st.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
2022-08-06 05:03:45 +00:00
|
|
|
std::ostream& operator<<(std::ostream& out, const ErrorObject* err) {
|
|
|
|
if (!err) return out;
|
|
|
|
if (err->r0_) out << "r0=" << err->r0_;
|
|
|
|
if (err->errno_) out << ", errno=" << err->errno_;
|
|
|
|
if (!err->message_.empty()) out << ", msg=" << err->message_;
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2021-03-03 02:26:30 +00:00
|
|
|
// We could do something in the main of utest.
|
|
|
|
// Copy from gtest-1.6.0/src/gtest_main.cc
|
|
|
|
GTEST_API_ int main(int argc, char **argv) {
|
|
|
|
// Select the best event system available on the OS. In Linux this is
|
2021-10-02 00:54:53 +00:00
|
|
|
// epoll(). On BSD it will be kqueue. On Cygwin it will be select.
|
|
|
|
#if __CYGWIN__
|
|
|
|
assert(st_set_eventsys(ST_EVENTSYS_SELECT) != -1);
|
|
|
|
#else
|
2021-03-03 02:26:30 +00:00
|
|
|
assert(st_set_eventsys(ST_EVENTSYS_ALT) != -1);
|
2021-10-02 00:54:53 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Initialize state-threads, create idle coroutine.
|
2021-03-03 02:26:30 +00:00
|
|
|
assert(st_init() == 0);
|
|
|
|
|
|
|
|
testing::InitGoogleTest(&argc, argv);
|
|
|
|
return RUN_ALL_TESTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
// basic test and samples.
|
2022-08-06 05:03:45 +00:00
|
|
|
VOID TEST(SampleTest, ExampleIntSizeTest)
|
2021-03-03 02:26:30 +00:00
|
|
|
{
|
|
|
|
EXPECT_EQ(1, (int)sizeof(int8_t));
|
|
|
|
EXPECT_EQ(2, (int)sizeof(int16_t));
|
|
|
|
EXPECT_EQ(4, (int)sizeof(int32_t));
|
|
|
|
EXPECT_EQ(8, (int)sizeof(int64_t));
|
|
|
|
}
|
|
|
|
|