mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-03 19:33:49 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -54,9 +54,9 @@ bool MakeDiffVersion0(FileReader & oldReader, FileReader & newReader, FileWriter
|
||||
return true;
|
||||
}
|
||||
|
||||
generator::mwm_diff::DiffApplicationResult ApplyDiffVersion0(
|
||||
FileReader & oldReader, FileWriter & newWriter, ReaderSource<FileReader> & diffFileSource,
|
||||
base::Cancellable const & cancellable)
|
||||
generator::mwm_diff::DiffApplicationResult ApplyDiffVersion0(FileReader & oldReader, FileWriter & newWriter,
|
||||
ReaderSource<FileReader> & diffFileSource,
|
||||
base::Cancellable const & cancellable)
|
||||
{
|
||||
using generator::mwm_diff::DiffApplicationResult;
|
||||
|
||||
@@ -108,9 +108,7 @@ bool MakeDiff(std::string const & oldMwmPath, std::string const & newMwmPath, st
|
||||
switch (VERSION_LATEST)
|
||||
{
|
||||
case VERSION_V0: return MakeDiffVersion0(oldReader, newReader, diffFileWriter);
|
||||
default:
|
||||
LOG(LERROR,
|
||||
("Making mwm diffs with diff format version", VERSION_LATEST, "is not implemented"));
|
||||
default: LOG(LERROR, ("Making mwm diffs with diff format version", VERSION_LATEST, "is not implemented"));
|
||||
}
|
||||
}
|
||||
catch (Reader::Exception const & e)
|
||||
@@ -141,11 +139,8 @@ DiffApplicationResult ApplyDiff(std::string const & oldMwmPath, std::string cons
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case VERSION_V0:
|
||||
return ApplyDiffVersion0(oldReader, newWriter, diffFileSource, cancellable);
|
||||
default:
|
||||
LOG(LERROR, ("Unknown version format of mwm diff:", version));
|
||||
return DiffApplicationResult::Failed;
|
||||
case VERSION_V0: return ApplyDiffVersion0(oldReader, newWriter, diffFileSource, cancellable);
|
||||
default: LOG(LERROR, ("Unknown version format of mwm diff:", version)); return DiffApplicationResult::Failed;
|
||||
}
|
||||
}
|
||||
catch (Reader::Exception const & e)
|
||||
@@ -157,8 +152,7 @@ DiffApplicationResult ApplyDiff(std::string const & oldMwmPath, std::string cons
|
||||
LOG(LERROR, ("Could not open file for writing when applying a patch:", e.Msg()));
|
||||
}
|
||||
|
||||
return cancellable.IsCancelled() ? DiffApplicationResult::Cancelled
|
||||
: DiffApplicationResult::Failed;
|
||||
return cancellable.IsCancelled() ? DiffApplicationResult::Cancelled : DiffApplicationResult::Failed;
|
||||
}
|
||||
|
||||
std::string DebugPrint(DiffApplicationResult const & result)
|
||||
|
||||
@@ -22,8 +22,7 @@ enum class DiffApplicationResult
|
||||
// result in the mwm at |newMwmPath|. The diff is stored at |diffPath|.
|
||||
// It is assumed that the files at |oldMwmPath| and |newMwmPath| are valid mwms.
|
||||
// Returns true on success and false on failure.
|
||||
bool MakeDiff(std::string const & oldMwmPath, std::string const & newMwmPath,
|
||||
std::string const & diffPath);
|
||||
bool MakeDiff(std::string const & oldMwmPath, std::string const & newMwmPath, std::string const & diffPath);
|
||||
|
||||
// Applies the diff at |diffPath| to the mwm at |oldMwmPath|. The resulting
|
||||
// mwm is stored at |newMwmPath|.
|
||||
@@ -32,8 +31,7 @@ bool MakeDiff(std::string const & oldMwmPath, std::string const & newMwmPath,
|
||||
// The application process can be stopped via |cancellable| in which case
|
||||
// it is up to the caller to clean the partially written file at |diffPath|.
|
||||
DiffApplicationResult ApplyDiff(std::string const & oldMwmPath, std::string const & newMwmPath,
|
||||
std::string const & diffPath,
|
||||
base::Cancellable const & cancellable);
|
||||
std::string const & diffPath, base::Cancellable const & cancellable);
|
||||
|
||||
std::string DebugPrint(DiffApplicationResult const & result);
|
||||
} // namespace mwm_diff
|
||||
|
||||
@@ -27,7 +27,8 @@ UNIT_TEST(IncrementalUpdates_Smoke)
|
||||
string const newMwmPath2 = base::JoinPath(GetPlatform().WritableDir(), "minsk-pass-new2.mwm");
|
||||
string const diffPath = base::JoinPath(GetPlatform().WritableDir(), "minsk-pass.mwmdiff");
|
||||
|
||||
SCOPE_GUARD(cleanup, [&] {
|
||||
SCOPE_GUARD(cleanup, [&]
|
||||
{
|
||||
FileWriter::DeleteFileX(newMwmPath1);
|
||||
FileWriter::DeleteFileX(newMwmPath2);
|
||||
FileWriter::DeleteFileX(diffPath);
|
||||
@@ -40,8 +41,7 @@ UNIT_TEST(IncrementalUpdates_Smoke)
|
||||
|
||||
base::Cancellable cancellable;
|
||||
TEST(MakeDiff(oldMwmPath, newMwmPath1, diffPath), ());
|
||||
TEST_EQUAL(ApplyDiff(oldMwmPath, newMwmPath2, diffPath, cancellable), DiffApplicationResult::Ok,
|
||||
());
|
||||
TEST_EQUAL(ApplyDiff(oldMwmPath, newMwmPath2, diffPath, cancellable), DiffApplicationResult::Ok, ());
|
||||
|
||||
{
|
||||
// Alter the old mwm slightly.
|
||||
@@ -55,14 +55,12 @@ UNIT_TEST(IncrementalUpdates_Smoke)
|
||||
}
|
||||
|
||||
TEST(MakeDiff(oldMwmPath, newMwmPath1, diffPath), ());
|
||||
TEST_EQUAL(ApplyDiff(oldMwmPath, newMwmPath2, diffPath, cancellable), DiffApplicationResult::Ok,
|
||||
());
|
||||
TEST_EQUAL(ApplyDiff(oldMwmPath, newMwmPath2, diffPath, cancellable), DiffApplicationResult::Ok, ());
|
||||
|
||||
TEST(base::IsEqualFiles(newMwmPath1, newMwmPath2), ());
|
||||
|
||||
cancellable.Cancel();
|
||||
TEST_EQUAL(ApplyDiff(oldMwmPath, newMwmPath2, diffPath, cancellable),
|
||||
DiffApplicationResult::Cancelled, ());
|
||||
TEST_EQUAL(ApplyDiff(oldMwmPath, newMwmPath2, diffPath, cancellable), DiffApplicationResult::Cancelled, ());
|
||||
cancellable.Reset();
|
||||
|
||||
{
|
||||
@@ -77,15 +75,13 @@ UNIT_TEST(IncrementalUpdates_Smoke)
|
||||
writer.Write(diffContents.data(), diffContents.size());
|
||||
}
|
||||
|
||||
TEST_EQUAL(ApplyDiff(oldMwmPath, newMwmPath2, diffPath, cancellable),
|
||||
DiffApplicationResult::Failed, ());
|
||||
TEST_EQUAL(ApplyDiff(oldMwmPath, newMwmPath2, diffPath, cancellable), DiffApplicationResult::Failed, ());
|
||||
|
||||
{
|
||||
// Reset the diff file contents.
|
||||
FileWriter writer(diffPath);
|
||||
}
|
||||
|
||||
TEST_EQUAL(ApplyDiff(oldMwmPath, newMwmPath2, diffPath, cancellable),
|
||||
DiffApplicationResult::Failed, ());
|
||||
TEST_EQUAL(ApplyDiff(oldMwmPath, newMwmPath2, diffPath, cancellable), DiffApplicationResult::Failed, ());
|
||||
}
|
||||
} // namespace generator::diff_tests
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
|
||||
#include "base/cancellable.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
auto const ShowUsage = [argv]()
|
||||
{
|
||||
std::cout <<
|
||||
"Usage: " << argv[0] << " make|apply olderMWMPath newerMWMPath diffPath\n"
|
||||
"make\n"
|
||||
" Creates the diff between newer and older MWMs at `diffPath`\n"
|
||||
"apply\n"
|
||||
" Applies the diff at `diffPath` to the mwm at `olderMWMPath` and stores result at `newerMWMPath`.\n"
|
||||
"WARNING: THERE IS NO MWM VALIDITY CHECK!\n";
|
||||
std::cout << "Usage: " << argv[0]
|
||||
<< " make|apply olderMWMPath newerMWMPath diffPath\n"
|
||||
"make\n"
|
||||
" Creates the diff between newer and older MWMs at `diffPath`\n"
|
||||
"apply\n"
|
||||
" Applies the diff at `diffPath` to the mwm at `olderMWMPath` and stores result at `newerMWMPath`.\n"
|
||||
"WARNING: THERE IS NO MWM VALIDITY CHECK!\n";
|
||||
};
|
||||
|
||||
if (argc < 5)
|
||||
@@ -25,7 +25,7 @@ int main(int argc, char ** argv)
|
||||
}
|
||||
|
||||
auto const IsEqualUsage = [argv](char const * s) { return 0 == std::strcmp(argv[1], s); };
|
||||
char const * olderMWMPath{argv[2]}, * newerMWMPath{argv[3]}, * diffPath{argv[4]};
|
||||
char const *olderMWMPath{argv[2]}, *newerMWMPath{argv[3]}, *diffPath{argv[4]};
|
||||
|
||||
if (IsEqualUsage("make"))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user