Skip to content

Commit

Permalink
More test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Jun 20, 2024
1 parent f820c05 commit c30cb0e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 38 deletions.
1 change: 1 addition & 0 deletions .jenkins/lsu/env-hipcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ configure_extra_options+=" -DHPX_WITH_COMPILER_WARNINGS=ON"
configure_extra_options+=" -DHPX_WITH_COMPILER_WARNINGS_AS_ERRORS=OFF"

ctest_extra_args+=" -E tests.unit.modules.algorithms.detail "
ctest_extra_args+=" -E tests.regressions.modules.coroutines.coroutine_function_destructor_yield_4800"
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <hpx/algorithm.hpp>
#include <hpx/execution.hpp>
#include <hpx/modules/testing.hpp>
#include <hpx/numeric.hpp>

#include <cstddef>
#include <iostream>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <hpx/algorithm.hpp>
#include <hpx/init.hpp>
#include <hpx/modules/testing.hpp>
#include <hpx/numeric.hpp>

#include <cstddef>
#include <iostream>
Expand Down
3 changes: 1 addition & 2 deletions libs/core/format/include/hpx/modules/format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ namespace hpx::util {
os << value.delim;
first = false;

using value_type = std::decay_t<decltype(elem)>;
detail::formatter<value_type>::call(os, spec, &elem);
detail::formatter<Range>::call(os, spec, &elem);
}
}
};
Expand Down
64 changes: 33 additions & 31 deletions libs/core/format/tests/unit/format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,64 +15,66 @@

int main(int argc, char* argv[])
{
using hpx::util::format;
{
HPX_TEST_EQ((format("Hello")), "Hello");
HPX_TEST_EQ((format("Hello, {}!", "world")), "Hello, world!");
HPX_TEST_EQ((format("The number is {}", 1)), "The number is 1");
HPX_TEST_EQ((hpx::util::format("Hello")), "Hello");
HPX_TEST_EQ(
(hpx::util::format("Hello, {}!", "world")), "Hello, world!");
HPX_TEST_EQ(
(hpx::util::format("The number is {}", 1)), "The number is 1");
}

{
HPX_TEST_EQ((format("{} {}", 1, 2)), "1 2");
HPX_TEST_EQ((format("{} {1}", 1, 2)), "1 1");
HPX_TEST_EQ((format("{2} {}", 1, 2)), "2 2");
HPX_TEST_EQ((format("{2} {1}", 1, 2)), "2 1");
HPX_TEST_EQ((hpx::util::format("{} {}", 1, 2)), "1 2");
HPX_TEST_EQ((hpx::util::format("{} {1}", 1, 2)), "1 1");
HPX_TEST_EQ((hpx::util::format("{2} {}", 1, 2)), "2 2");
HPX_TEST_EQ((hpx::util::format("{2} {1}", 1, 2)), "2 1");

HPX_TEST_EQ((format("{:}", 42)), "42");
HPX_TEST_EQ((format("{:04}", 42)), "0042");
HPX_TEST_EQ((format("{2:04}", 42, 43)), "0043");
HPX_TEST_EQ((hpx::util::format("{:}", 42)), "42");
HPX_TEST_EQ((hpx::util::format("{:04}", 42)), "0042");
HPX_TEST_EQ((hpx::util::format("{2:04}", 42, 43)), "0043");

HPX_TEST_EQ((format("{:x}", 42)), "2a");
HPX_TEST_EQ((format("{:04x}", 42)), "002a");
HPX_TEST_EQ((format("{2:04x}", 42, 43)), "002b");
HPX_TEST_EQ((hpx::util::format("{:x}", 42)), "2a");
HPX_TEST_EQ((hpx::util::format("{:04x}", 42)), "002a");
HPX_TEST_EQ((hpx::util::format("{2:04x}", 42, 43)), "002b");

HPX_TEST_EQ((format("{:#x}", 42)), "0x2a");
HPX_TEST_EQ((format("{:#06x}", 42)), "0x002a");
HPX_TEST_EQ((format("{2:#06x}", 42, 43)), "0x002b");
HPX_TEST_EQ((hpx::util::format("{:#x}", 42)), "0x2a");
HPX_TEST_EQ((hpx::util::format("{:#06x}", 42)), "0x002a");
HPX_TEST_EQ((hpx::util::format("{2:#06x}", 42, 43)), "0x002b");
}

{
HPX_TEST_EQ((format("{} {}", true, false)), "1 0");
HPX_TEST_EQ((hpx::util::format("{} {}", true, false)), "1 0");
}

{
std::time_t t = std::time(nullptr);
std::tm tm = *std::localtime(&t);
char buffer[64] = {};
std::strftime(buffer, 64, "%c", &tm);
HPX_TEST_EQ((format("{}", tm)), buffer);
HPX_TEST_EQ((hpx::util::format("{}", tm)), buffer);

std::strftime(buffer, 64, "%A %c", &tm);
HPX_TEST_EQ((format("{:%A %c}", tm)), buffer);
HPX_TEST_EQ((hpx::util::format("{:%A %c}", tm)), buffer);
}

{
using hpx::util::format_join;
std::vector<int> const vs = {42, 43};
HPX_TEST_EQ((format("{}", format_join(vs, ""))), "4243");
HPX_TEST_EQ((format("{}", format_join(vs, ","))), "42,43");
HPX_TEST_EQ((format("{:x}", format_join(vs, ""))), "2a2b");
HPX_TEST_EQ((format("{:04x}", format_join(vs, ","))), "002a,002b");
HPX_TEST_EQ((hpx::util::format("{}", format_join(vs, ""))), "4243");
HPX_TEST_EQ((hpx::util::format("{}", format_join(vs, ","))), "42,43");
HPX_TEST_EQ((hpx::util::format("{:x}", format_join(vs, ""))), "2a2b");
HPX_TEST_EQ(
(hpx::util::format("{:04x}", format_join(vs, ","))), "002a,002b");
}

{
HPX_TEST_EQ((format("{{ {}", 1)), "{ 1");
HPX_TEST_EQ((format("}} {}", 1)), "} 1");
HPX_TEST_EQ((format("{{}} {}", 1)), "{} 1");
HPX_TEST_EQ((format("{} {{}}", 1)), "1 {}");
HPX_TEST_EQ((format("{} {{", 1)), "1 {");
HPX_TEST_EQ((format("{} }}", 1)), "1 }");
HPX_TEST_EQ((format("{{{1}}}", 2)), "{2}");
HPX_TEST_EQ((hpx::util::format("{{ {}", 1)), "{ 1");
HPX_TEST_EQ((hpx::util::format("}} {}", 1)), "} 1");
HPX_TEST_EQ((hpx::util::format("{{}} {}", 1)), "{} 1");
HPX_TEST_EQ((hpx::util::format("{} {{}}", 1)), "1 {}");
HPX_TEST_EQ((hpx::util::format("{} {{", 1)), "1 {");
HPX_TEST_EQ((hpx::util::format("{} }}", 1)), "1 }");
HPX_TEST_EQ((hpx::util::format("{{{1}}}", 2)), "{2}");
}

return hpx::util::report_errors();
Expand Down
8 changes: 4 additions & 4 deletions libs/core/type_support/tests/unit/generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ namespace tests {
}
};

// gcc V11/V12 are complaining about mismatched-new-delete
#if !defined(HPX_GCC_VERSION) || HPX_GCC_VERSION >= 140000
// gcc V11 and on are complaining about mismatched-new-delete
#if !defined(HPX_GCC_VERSION) || HPX_GCC_VERSION >= 150000
hpx::generator<int, void, std::allocator<std::byte>> stateless_example()
{
co_yield 42;
Expand Down Expand Up @@ -313,8 +313,8 @@ int main()
HPX_TEST_EQ(i, expected.size());
}

// gcc V11/V12 are complaining about mismatched-new-delete
#if !defined(HPX_GCC_VERSION) || HPX_GCC_VERSION >= 140000
// gcc V11 and on are complaining about mismatched-new-delete
#if !defined(HPX_GCC_VERSION) || HPX_GCC_VERSION >= 150000
{
std::vector const expected = {42};
std::size_t i = 0;
Expand Down

0 comments on commit c30cb0e

Please sign in to comment.