blob: 5b328d75c99ffc66c866a83dce48441f98d8c29c [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
Stephan Pleines4b02e7b2024-05-30 20:29:39 -07003#include <string.h>
4
Tyler Chatowbf0609c2021-07-31 16:13:27 -07005#include <cerrno>
Stephan Pleines4b02e7b2024-05-30 20:29:39 -07006#include <string>
Brian Silvermanaf784862014-05-13 08:14:55 -07007
8#include "gtest/gtest.h"
9
Stephan Pleinesf63bde82024-01-13 15:59:33 -080010namespace aos::libc::testing {
Brian Silvermanaf784862014-05-13 08:14:55 -070011
12// Tries a couple of easy ones.
13TEST(StrerrorTest, Basic) {
14 EXPECT_STREQ("Argument list too long", aos_strerror(E2BIG));
15 EXPECT_STREQ("Bad file descriptor", aos_strerror(EBADF));
16 EXPECT_STREQ("Unknown error 4021", aos_strerror(4021));
17}
18
19// Runs through all errno values and makes sure it gives the same result as
20// strerror(3).
21TEST(StrerrorTest, All) {
22 for (int i = 0; i < 4095; ++i) {
23 SCOPED_TRACE("iteration " + ::std::to_string(i));
24 EXPECT_STREQ(strerror(i), aos_strerror(i));
25 }
26}
27
Stephan Pleinesf63bde82024-01-13 15:59:33 -080028} // namespace aos::libc::testing