Skip to content

Commit c041eb6

Browse files
committed
Clean up tests + fix gcc failure
1 parent f0a0fe0 commit c041eb6

File tree

6 files changed

+27
-31
lines changed

6 files changed

+27
-31
lines changed

libcxx/test/std/utilities/text_encoding/test_text_encoding.h

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,13 @@
99
#ifndef SUPPORT_TEST_TEXT_ENCODING_H
1010
#define SUPPORT_TEST_TEXT_ENCODING_H
1111

12-
#include <algorithm>
13-
#include <cassert>
14-
#include <clocale>
15-
#include <concepts>
16-
#include <cstdio>
17-
#include <cstdlib>
18-
#include <iostream>
19-
#include <print>
20-
#include <ranges>
21-
#include <string_view>
22-
#include <text_encoding>
23-
#include <type_traits>
24-
25-
#include "platform_support.h"
26-
#include "test_macros.h"
27-
2812
struct encoding_data {
2913
const char* name;
3014
int mib;
3115
int size;
3216
};
3317

34-
constexpr const encoding_data unique_encoding_data[]{
18+
constexpr encoding_data unique_encoding_data[]{
3519
{"US-ASCII", 3, 8},
3620
{"ISO_8859-1:1987", 4, 15},
3721
{"ISO_8859-2:1987", 5, 15},

libcxx/test/std/utilities/text_encoding/text_encoding.ctor/id.pass.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@
1414

1515
// text_encoding::text_encoding(id) noexcept
1616

17-
// Concerns:
18-
// 1. text_encoding(id) must be nothrow
19-
// 2. Constructing an object with a valid id must set mib() and the name to the corresponding value.
20-
// 3. Constructing an object using id::unknown must set mib() to id::unknown and the name to an empty string.
21-
// 4. Constructing an object using id::other must set mib() to id::other and the name to an empty string.
22-
17+
#include <algorithm>
2318
#include <cassert>
19+
#include <ranges>
20+
#include <text_encoding>
21+
#include <type_traits>
2422

2523
#include "../test_text_encoding.h"
2624

@@ -79,21 +77,25 @@ constexpr bool test_other() {
7977

8078
int main(int, char**) {
8179
{
80+
// 1. text_encoding(id) must be nothrow
8281
static_assert(std::is_nothrow_constructible<std::text_encoding, std::text_encoding::id>::value,
8382
"Must be nothrow constructible with id");
8483
}
8584

8685
{
86+
// 2. Constructing an object with a valid id must set mib() and the name to the corresponding value.
8787
static_assert(id_ctors());
8888
assert(id_ctors());
8989
}
9090

9191
{
92+
// 3. Constructing an object using id::unknown must set mib() to id::unknown and the name to an empty string.
9293
static_assert(test_unknown());
9394
assert(test_unknown());
9495
}
9596

9697
{
98+
// 4. Constructing an object using id::other must set mib() to id::other and the name to an empty string.
9799
static_assert(test_other());
98100
assert(test_other());
99101
}

libcxx/test/std/utilities/text_encoding/text_encoding.ctor/string_view.pass.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010

1111
// REQUIRES: std-at-least-c++26
1212
// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=20000000
13-
// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-ops-limit): -fconstexpr-ops-limit=80000000
14-
13+
// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-ops-limit): -fconstexpr-ops-limit=90000000
1514
// class text_encoding
1615

1716
// text_encoding::text_encoding(string_view) noexcept
1817

1918
#include <cassert>
19+
#include <string_view>
20+
#include <text_encoding>
21+
#include <type_traits>
2022

2123
#include "../test_text_encoding.h"
2224

@@ -25,21 +27,27 @@ constexpr bool test_ctor(std::string_view str, std::string_view expect, std::tex
2527
bool success = true;
2628

2729
assert(te.mib() == expect_id);
28-
assert(expect.compare(te.name()) == 0);
30+
assert(te.name() == expect);
2931

3032
return success;
3133
}
3234

3335
constexpr bool test_primary_encoding_spellings() {
34-
for (auto& pair : unique_encoding_data) {
35-
assert(test_ctor(pair.name, pair.name, std::text_encoding::id{pair.mib}));
36+
for (auto& data : unique_encoding_data) {
37+
auto te = std::text_encoding(std::string_view(data.name));
38+
39+
assert(te.mib() == std::text_encoding::id(data.mib));
40+
assert(te.name() == std::string_view(data.name));
3641
}
3742
return true;
3843
}
3944

4045
constexpr bool test_others() {
4146
for (auto& name : other_names) {
42-
assert(test_ctor(name, name, std::text_encoding::other));
47+
auto te = std::text_encoding(std::string_view(name));
48+
49+
assert(te.mib() == std::text_encoding::other);
50+
assert(te.name() == std::string_view(name));
4351
}
4452
return true;
4553
}

libcxx/test/std/utilities/text_encoding/text_encoding.eq/equal.id.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
// text_encoding operator==(const text_encoding&, id) _NOEXCEPT
1616

1717
#include <cassert>
18+
#include <text_encoding>
1819

20+
#include "test_macros.h"
1921
#include "../test_text_encoding.h"
2022

2123
using id = std::text_encoding::id;

libcxx/test/std/utilities/text_encoding/text_encoding.members/environment.nodiscard.verify.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010

1111
// REQUIRES: std-at-least-c++26
1212
// UNSUPPORTED: no-localization
13+
// UNSUPPORTED: android
1314

1415
// class text_encoding
15-
// UNSUPPORTED: no-localization
16-
// UNSUPPORTED: android
1716

1817
// Concerns:
1918
// 1. Verify that text_encoding member functions are nodiscard

libcxx/test/std/utilities/text_encoding/text_encoding.members/text_encoding.aliases_view/empty.pass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// struct text_encoding::aliases_view
1515

1616
#include <cassert>
17+
#include <ranges>
1718
#include <text_encoding>
1819

1920
#include "../../test_text_encoding.h"

0 commit comments

Comments
 (0)