Skip to content

Commit 0305fd6

Browse files
Avoid disable all tests for fast_io::vector
- fix test vector/reserve.cc
1 parent 55e49a0 commit 0305fd6

9 files changed

Lines changed: 45 additions & 21 deletions

File tree

tests/0026.container/.test_prop.toml

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/0026.container/0001.vector/append_range.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ using namespace fast_io::mnp;
88

99
int main()
1010
{
11+
#if 0
1112
auto head = fast_io::vector<int>{1, 2, 3, 4};
1213
auto const tail = std::list{-5, -6, -7};
1314
head.append_range(tail);
1415
assert(std::ranges::equal(head, fast_io::vector<int>{1, 2, 3, 4, -5, -6, -7}));
16+
#endif
1517
}

tests/0026.container/0001.vector/assign.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ int main()
2020
characters.assign(5, 'a');
2121
print_vector();
2222

23+
#if 0
2324
std::string const extra(6, 'b');
2425
characters.assign(extra.begin(), extra.end());
2526
print_vector();
2627

2728
characters.assign({'C', '+', '+', '1', '1'});
2829
print_vector();
29-
}
30+
#endif
31+
}

tests/0026.container/0001.vector/assign_range.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
int main()
88
{
9+
#if 0
910
auto const source = std::list{2, 7, 1};
1011
auto destination = fast_io::vector{3, 1, 4};
1112
destination.assign_range(source);
1213
assert(std::ranges::equal(source, destination));
14+
#endif
1315
}

tests/0026.container/0001.vector/insert.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ int main()
1717
auto it = c1.begin();
1818
it = c1.insert(it, 200);
1919
print_info(2, c1);
20-
20+
#if 0
2121
c1.insert(it, 2, 300);
2222
print_info(3, c1);
2323

@@ -34,4 +34,5 @@ int main()
3434

3535
c1.insert(c1.end(), {601, 602, 603});
3636
print_info(6, c1);
37+
#endif
3738
}

tests/0026.container/0001.vector/insert_range.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ using namespace fast_io::mnp;
99

1010
int main()
1111
{
12+
#if 0
1213
auto container = fast_io::vector{1, 2, 3, 4};
1314
auto pos = std::next(container.begin(), 2);
1415
assert(*pos == 3);
1516
auto const rg = std::list{-1, -2, -3};
1617

1718
container.insert_range(pos, rg);
1819
assert(std::ranges::equal(container, fast_io::vector{1, 2, -1, -2, -3, 3, 4}));
20+
#endif
1921
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#include <fast_io.h>
2-
#include <fast_io_i18n.h>
2+
// #include <fast_io_i18n.h>
33
#include <fast_io_dsal/vector.h>
44
using namespace fast_io::io;
55
using namespace fast_io::mnp;
66

77
int main()
88
{
9+
#if 0
910
fast_io::vector<char> q;
1011
fast_io::native_l10n l10n{"en_US.UTF-8"};
1112
println(imbue(l10n, fast_io::c_stdout()), "Maximum size of a std::vector is ", q.max_size());
13+
#endif
1214
}

tests/0026.container/0001.vector/reserve.cc

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,57 @@ struct NAlloc
1111
static void *allocate(std::size_t n)
1212
{
1313
void *p = ::operator new(n);
14-
println("allocating ", n, " bytes @ ", pointervw(p));
1514
return p;
1615
}
17-
static void deallocate_n(void *p, std::size_t n)
16+
static void deallocate_n(void *p, std::size_t)
1817
{
19-
print("deallocating ", n, " bytes @ ", pointervw(p), "\n\n");
2018
::operator delete(p);
2119
}
22-
constexpr bool operator==(NAlloc const &) const noexcept = default;
20+
static void deallocate(void *p)
21+
{
22+
::operator delete(p);
23+
}
24+
constexpr bool operator==(::NAlloc const &) const noexcept = default;
2325
};
2426

27+
using NAllocAdapter = fast_io::generic_allocator_adapter<NAlloc>;
28+
2529
int main()
2630
{
2731
constexpr int max_elements = 32;
2832

29-
print("using reserve: \n");
33+
// using reserve
3034
{
31-
fast_io::vector<int, NAlloc> v1;
35+
fast_io::vector<int, ::NAllocAdapter> v1;
3236
v1.reserve(max_elements); // reserves at least max_elements * sizeof(int) bytes
3337

3438
for (int n = 0; n < max_elements; ++n)
3539
{
3640
v1.push_back(n);
3741
}
42+
for (int n = 0; n < max_elements; ++n)
43+
{
44+
int v{v1[n]};
45+
if (v != n) {
46+
::fast_io::fast_terminate();
47+
}
48+
}
3849
}
3950

40-
print("not using reserve: \n");
51+
// not using reserve
4152
{
42-
fast_io::vector<int, NAlloc> v1;
53+
fast_io::vector<int, ::NAllocAdapter> v1;
4354

4455
for (int n = 0; n < max_elements; ++n)
4556
{
46-
if (v1.size() == v1.capacity())
47-
{
48-
println("size() == capacity() == ", v1.size());
49-
}
5057
v1.push_back(n);
5158
}
59+
for (int n = 0; n < max_elements; ++n)
60+
{
61+
int v{v1[n]};
62+
if (v != n) {
63+
::fast_io::fast_terminate();
64+
}
65+
}
5266
}
53-
}
67+
}

tests/0026.container/0001.vector/vector.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,21 @@ int main()
99
// C++11 initializer list syntax:
1010
fast_io::vector<std::string> words1{"the", "frogurt", "is", "also", "cursed"};
1111
print("1: {", rgvw(words1, ", "), "}\n");
12-
12+
#if 0
1313
// words2 == words1
1414
fast_io::vector<std::string> words2(::std::from_range, words1);
1515
print("2: {", rgvw(words2, ", "), "}\n");
16-
16+
#endif
1717
// words3 == words1
1818
fast_io::vector<std::string> words3(words1);
1919
print("3: {", rgvw(words3, ", "), "}\n");
2020

2121
// words4 is {"Mo", "Mo", "Mo", "Mo", "Mo"}
2222
fast_io::vector<std::string> words4(5, "Mo");
2323
print("4: {", rgvw(words4, ", "), "}\n");
24-
24+
#if 0
2525
auto const rg = {"cat", "cow", "crow"};
2626
fast_io::vector<std::string> words5(::std::from_range, rg); // overload (11)
2727
print("5: {", rgvw(words5, ", "), "}\n");
28+
#endif
2829
}

0 commit comments

Comments
 (0)