blob: abd867e9928f182baefe412ad89a94ee9c320412 [file] [log] [blame]
John Park33858a32018-09-28 23:05:48 -07001#include "aos/libc/aos_strerror.h"
Brian Silvermanaf784862014-05-13 08:14:55 -07002
Tyler Chatowbf0609c2021-07-31 16:13:27 -07003#include <cerrno>
Brian Silvermanaf784862014-05-13 08:14:55 -07004
5#include "gtest/gtest.h"
6
7namespace aos {
8namespace libc {
9namespace testing {
10
11// Tries a couple of easy ones.
12TEST(StrerrorTest, Basic) {
13 EXPECT_STREQ("Argument list too long", aos_strerror(E2BIG));
14 EXPECT_STREQ("Bad file descriptor", aos_strerror(EBADF));
15 EXPECT_STREQ("Unknown error 4021", aos_strerror(4021));
16}
17
18// Runs through all errno values and makes sure it gives the same result as
19// strerror(3).
20TEST(StrerrorTest, All) {
21 for (int i = 0; i < 4095; ++i) {
22 SCOPED_TRACE("iteration " + ::std::to_string(i));
23 EXPECT_STREQ(strerror(i), aos_strerror(i));
24 }
25}
26
27} // namespace testing
28} // namespace libc
29} // namespace aos