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

source code of libc/test/src/string/strcoll_test.cpp