Skip to content

Commit

Permalink
Add the std test suite. (#498)
Browse files Browse the repository at this point in the history
* Add tests/std.

* Update other files.

NOTICE.txt
Mention the LLVM Project, as its code appears
in tests/std/tests/P0220R1_optional/test.cpp and elsewhere.

azure-devops/enforce-clang-format.cmd
Process everything within tests. This includes libcxx, std, and tr1.

docs/cgmanifest.json
Update this file for Microsoft-internal purposes. (It records the commit
hashes of repos whose source code we've incorporated into our own repo.
For llvm-project, this is distinct from the submodule's current commit.)

tests/tr1/run.pl
Mention runbe.pl in lowercase, to match the file itself.

* Improve run.pl and runbe.pl comments.
  • Loading branch information
StephanTLavavej authored Feb 14, 2020
1 parent ed3cbf3 commit 2b2746d
Show file tree
Hide file tree
Showing 710 changed files with 165,285 additions and 8 deletions.
10 changes: 10 additions & 0 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,13 @@ In addition, certain files include the notices provided below.
// Recipient is granted the right to make copies in any form for
// internal distribution and to freely use the information supplied
// in the creation of products supporting Unicode.

----------------------

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
2 changes: 1 addition & 1 deletion azure-devops/enforce-clang-format.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"%1" "clang-format.exe -style=file -i" ^
stl/inc ^
stl/src ^
tests/tr1 ^
tests ^
tools
@echo If your build fails here, you need to format the following files with:
@clang-format.exe --version
Expand Down
13 changes: 11 additions & 2 deletions docs/cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"component": {
"type": "git",
"git": {
"repositoryUrl": "https://github.com/ulfjack/ryu.git",
"commitHash": "59661c3f883dfd39cef6dc8eaf2fcbaae53597e8"
"repositoryUrl": "https://github.com/llvm/llvm-project.git",
"commitHash": "6f0768f64da398d5103d39e83bdc66a5ffd6f0f6"
}
}
},
Expand All @@ -17,6 +17,15 @@
"commitHash": "07e85d10c051a0a53d522a28affb1fbc43fc24f0"
}
}
},
{
"component": {
"type": "git",
"git": {
"repositoryUrl": "https://github.com/ulfjack/ryu.git",
"commitHash": "59661c3f883dfd39cef6dc8eaf2fcbaae53597e8"
}
}
}
],
"Version": 1
Expand Down
111 changes: 111 additions & 0 deletions tests/std/include/constexpr_char_traits.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#pragma once
#include <stdio.h>
#include <wchar.h>

struct constexpr_char_traits {
typedef char char_type;
typedef long int_type;
typedef long pos_type;
typedef long off_type;
typedef mbstate_t state_type;

static constexpr int compare(const char* first1, const char* first2, size_t count) {
for (; 0 < count; --count, ++first1, ++first2) {
if (!eq(*first1, *first2)) {
return lt(*first1, *first2) ? -1 : +1;
}
}

return 0;
}

static constexpr size_t length(const char* first) {
size_t count = 0;
for (; !eq(*first, char()); ++first) {
++count;
}

return count;
}

static constexpr char* copy(char* first1, const char* first2, size_t count) {
char* next = first1;
for (; 0 < count; --count, ++next, ++first2) {
assign(*next, *first2);
}
return first1;
}

static constexpr char* _Copy_s(char* first1, size_t, const char* first2, size_t count) {
// let's just pretend :)
return copy(first1, first2, count);
}

static constexpr const char* find(const char* first, size_t count, const char ch) {
for (; 0 < count; --count, ++first) {
if (eq(*first, ch)) {
return first;
}
}

return nullptr;
}

static constexpr char* move(char* first1, const char* first2, size_t count) {
char* next = first1;
if (first2 < next && next < first2 + count) {
for (next += count, first2 += count; 0 < count; --count) {
assign(*--next, *--first2);
}
} else {
for (; 0 < count; --count, ++next, ++first2) {
assign(*next, *first2);
}
}
return first1;
}

static constexpr char* assign(char* first, size_t count, const char ch) {
char* next = first;
for (; 0 < count; --count, ++next) {
assign(*next, ch);
}

return first;
}

static constexpr void assign(char& left, const char right) noexcept {
left = right;
}

static constexpr bool eq(const char left, const char right) noexcept {
return left == right;
}

static constexpr bool lt(const char left, const char right) noexcept {
return left < right;
}

static constexpr char to_char_type(const int_type meta) noexcept {
return static_cast<char>(meta);
}

static constexpr int_type to_int_type(const char ch) noexcept {
return ch;
}

static constexpr bool eq_int_type(const int_type left, const int_type right) noexcept {
return left == right;
}

static constexpr int_type not_eof(const int_type meta) noexcept {
return meta != eof() ? meta : !eof();
}

static constexpr int_type eof() noexcept {
return EOF;
}
};
Loading

0 comments on commit 2b2746d

Please sign in to comment.