xref: /llvm-project/libc/test/src/string/strcoll_test.cpp (revision b6bc9d72f65a5086f310f321e969d96e9a559e75)
1f418f888SMichael Jones //===-- Unittests for strcoll ---------------------------------------------===//
2f418f888SMichael Jones //
3f418f888SMichael Jones // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4f418f888SMichael Jones // See https://llvm.org/LICENSE.txt for license information.
5f418f888SMichael Jones // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6f418f888SMichael Jones //
7f418f888SMichael Jones //===----------------------------------------------------------------------===//
8f418f888SMichael Jones 
9f418f888SMichael Jones #include "src/string/strcoll.h"
10af1315c2SSiva Chandra Reddy #include "test/UnitTest/Test.h"
11f418f888SMichael Jones 
12f418f888SMichael Jones // TODO: Add more comprehensive tests once locale support is added.
13f418f888SMichael Jones 
TEST(LlvmLibcStrcollTest,SimpleTest)14f418f888SMichael Jones TEST(LlvmLibcStrcollTest, SimpleTest) {
15f418f888SMichael Jones   const char *s1 = "abc";
16f418f888SMichael Jones   const char *s2 = "abc";
17f418f888SMichael Jones   const char *s3 = "def";
18*b6bc9d72SGuillaume Chatelet   int result = LIBC_NAMESPACE::strcoll(s1, s2);
19f418f888SMichael Jones   ASSERT_EQ(result, 0);
20f418f888SMichael Jones 
21f418f888SMichael Jones   // Verify operands reversed.
22*b6bc9d72SGuillaume Chatelet   result = LIBC_NAMESPACE::strcoll(s2, s1);
23f418f888SMichael Jones   ASSERT_EQ(result, 0);
24f418f888SMichael Jones 
25*b6bc9d72SGuillaume Chatelet   result = LIBC_NAMESPACE::strcoll(s1, s3);
26f418f888SMichael Jones   ASSERT_LT(result, 0);
27f418f888SMichael Jones 
28*b6bc9d72SGuillaume Chatelet   result = LIBC_NAMESPACE::strcoll(s3, s1);
29f418f888SMichael Jones   ASSERT_GT(result, 0);
30f418f888SMichael Jones }
31