Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the std test suite. #498

Merged
merged 3 commits into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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