142bcb35cSMichael Jones //===-- Unittests for strerror --------------------------------------------===// 242bcb35cSMichael Jones // 342bcb35cSMichael Jones // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 442bcb35cSMichael Jones // See https://llvm.org/LICENSE.txt for license information. 542bcb35cSMichael Jones // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 642bcb35cSMichael Jones // 742bcb35cSMichael Jones //===----------------------------------------------------------------------===// 842bcb35cSMichael Jones 9*f7cee44eSJoseph Huber #include "src/__support/StringUtil/platform_errors.h" 10*f7cee44eSJoseph Huber #include "src/__support/macros/properties/architectures.h" 1142bcb35cSMichael Jones #include "src/string/strerror.h" 12af1315c2SSiva Chandra Reddy #include "test/UnitTest/Test.h" 1342bcb35cSMichael Jones 1442bcb35cSMichael Jones TEST(LlvmLibcStrErrorTest, KnownErrors) { 15b6bc9d72SGuillaume Chatelet ASSERT_STREQ(LIBC_NAMESPACE::strerror(0), "Success"); 1642bcb35cSMichael Jones 17*f7cee44eSJoseph Huber for (auto [i, msg] : LIBC_NAMESPACE::PLATFORM_ERRORS) 18*f7cee44eSJoseph Huber EXPECT_STREQ(LIBC_NAMESPACE::strerror(static_cast<int>(i)), msg.begin()); 1942bcb35cSMichael Jones } 2042bcb35cSMichael Jones 2142bcb35cSMichael Jones TEST(LlvmLibcStrErrorTest, UnknownErrors) { 22b6bc9d72SGuillaume Chatelet ASSERT_STREQ(LIBC_NAMESPACE::strerror(-1), "Unknown error -1"); 23b6bc9d72SGuillaume Chatelet ASSERT_STREQ(LIBC_NAMESPACE::strerror(134), "Unknown error 134"); 24b6bc9d72SGuillaume Chatelet ASSERT_STREQ(LIBC_NAMESPACE::strerror(2147483647), 25b6bc9d72SGuillaume Chatelet "Unknown error 2147483647"); 26b6bc9d72SGuillaume Chatelet ASSERT_STREQ(LIBC_NAMESPACE::strerror(-2147483648), 27b6bc9d72SGuillaume Chatelet "Unknown error -2147483648"); 2842bcb35cSMichael Jones } 29