Skip to content

Commit

Permalink
Skip locale check if std::locale fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc committed Nov 11, 2024
1 parent c88dfb0 commit ac43453
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions tests/test_morphology_readers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <morphio/morphology.h>
#include <morphio/mut/morphology.h>
#include <morphio/soma.h>
#include <stdexcept>

TEST_CASE("LoadH5Morphology", "[morphology]") {
{
Expand Down Expand Up @@ -210,15 +211,31 @@ class LocaleGuard {
std::locale previousLocale;
};

TEST_CASE("LoadSWCMorphologyLocale", "[morphology]") {
{
static std::unique_ptr<LocaleGuard> make_locale() {
#ifdef __APPLE__
const auto locale = LocaleGuard(std::locale("de_CH.UTF-8"));
const std::string locale_name = "de_CH.UTF-8";
#else
const auto locale = LocaleGuard(std::locale("de_CH.UTF8"));
const std::string locale_name = "de_CH.UTF8";
#endif
const morphio::Morphology m("data/simple.swc");
REQUIRE(m.diameters().size() == 12);
try {
return std::make_unique<LocaleGuard>(std::locale(locale_name));
} catch (const std::runtime_error&) {
return nullptr;
}
}


TEST_CASE("LoadSWCMorphologyLocale", "[morphology]") {
{
const auto locale = make_locale();
if (locale) {
const morphio::Morphology m("data/simple.swc");
REQUIRE(m.diameters().size() == 12);
} else {
// With Catch2 v3 this can be modernize using SKIP.
std::cout << "Skipping LoadSWCMorphologyLocale because `std::locale` failed."
<< std::endl;
}
}
}

Expand Down

0 comments on commit ac43453

Please sign in to comment.