Fix some unit tests on Windows

Signed-off-by: Osyotr <Osyotr@users.noreply.github.com>
This commit is contained in:
Osyotr 2025-02-14 00:33:06 +03:00
parent a7bec677f0
commit 7962e0a0af
5 changed files with 41 additions and 18 deletions

View file

@ -32,7 +32,7 @@ void Smoke()
vector<double> expected;
for (size_t i = 0; i < kCapacity; ++i)
expected.emplace_back(kTotal - 1 - i);
expected.emplace_back(static_cast<double>(kTotal - 1 - i));
vector<double> actual;
actual.reserve(kCapacity);

View file

@ -10,12 +10,12 @@ endif()
# TestServer fixture configuration
add_test(
NAME OmimStartTestServer
COMMAND start_server.py
COMMAND Python3::Interpreter start_server.py
WORKING_DIRECTORY ${OMIM_ROOT}/tools/python/test_server
)
add_test(
NAME OmimStopTestServer
COMMAND stop_server.py
COMMAND Python3::Interpreter stop_server.py
WORKING_DIRECTORY ${OMIM_ROOT}/tools/python/test_server
)
set_tests_properties(OmimStartTestServer PROPERTIES FIXTURES_SETUP TestServer)

View file

@ -66,25 +66,27 @@ UNIT_CLASS_TEST(GenerateTest, GenerateDeprecatedTypes)
MakeFeature(builder, {{"leisure", "playground"}, {"sport", "tennis"}}, {1.0, 1.0});
}
FrozenDataSource dataSource;
TEST_EQUAL(dataSource.Register(file).second, MwmSet::RegResult::Success, ());
{
FrozenDataSource dataSource;
TEST_EQUAL(dataSource.Register(file).second, MwmSet::RegResult::Success, ());
// New types.
base::StringIL arr[] = {{"leisure", "dog_park"}, {"leisure", "playground"}, {"sport", "tennis"}};
// New types.
base::StringIL arr[] = {{"leisure", "dog_park"}, {"leisure", "playground"}, {"sport", "tennis"}};
Classificator const & cl = classif();
set<uint32_t> types;
for (auto const & s : arr)
types.insert(cl.GetTypeByPath(s));
Classificator const & cl = classif();
set<uint32_t> types;
for (auto const & s : arr)
types.insert(cl.GetTypeByPath(s));
int count = 0;
auto const fn = [&](FeatureType & ft) {
++count;
ft.ForEachType([&](uint32_t t) { TEST(types.count(t) > 0, (cl.GetReadableObjectName(t))); });
};
dataSource.ForEachInScale(fn, scales::GetUpperScale());
int count = 0;
auto const fn = [&](FeatureType & ft) {
++count;
ft.ForEachType([&](uint32_t t) { TEST(types.count(t) > 0, (cl.GetReadableObjectName(t))); });
};
dataSource.ForEachInScale(fn, scales::GetUpperScale());
TEST_EQUAL(count, 2, ());
TEST_EQUAL(count, 2, ());
}
file.DeleteFromDisk(MapFileType::Map);
}

View file

@ -122,6 +122,8 @@ void FakeMapFilesDownloader::OnFileDownloaded(QueuedCountry const & queuedCountr
auto const country = queuedCountry;
m_queue.PopFront();
m_writer.reset();
m_taskRunner.PostTask([country, status]() { country.OnDownloadFinished(status); });
if (!m_queue.IsEmpty())

View file

@ -25,6 +25,10 @@
# include <CoreFoundation/CoreFoundation.h>
#endif
#ifdef OMIM_OS_WINDOWS
# include <windows.h>
#endif
#ifndef OMIM_UNIT_TEST_DISABLE_PLATFORM_INIT
# include "platform/platform.hpp"
#endif
@ -164,6 +168,21 @@ int main(int argc, char * argv[])
UNUSED_VALUE(argv);
#endif
#if defined(OMIM_OS_WINDOWS)
if (!IsDebuggerPresent())
{
DWORD const dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
SetErrorMode(dwMode | SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
_set_error_mode(_OUT_TO_STDERR);
_set_abort_behavior(0x0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
(void)_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
(void)_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
}
#endif
base::ScopedLogLevelChanger const infoLogLevel(LINFO);
#if defined(OMIM_OS_DESKTOP) || defined(OMIM_OS_IPHONE)
base::SetLogMessageFn(base::LogMessageTests);