1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 06:31:14 +02:00

libutil: Add missing format arguments to UsageError ctor

Once again found by an automated migration to `std::format`.
I've tested that boost::format works fine with `std::string_view`
arguments.
This commit is contained in:
Sergei Zimmerman 2025-04-25 13:35:16 +03:00
parent 27047570b5
commit 9fff868e39
No known key found for this signature in database
GPG key ID: A9B0B557CA632325
2 changed files with 13 additions and 6 deletions

View file

@ -1,3 +1,4 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "nix/util/file-content-address.hh"
@ -26,8 +27,11 @@ TEST(FileSerialisationMethod, testRoundTripPrintParse_2) {
}
}
TEST(FileSerialisationMethod, testParseFileSerialisationMethodOptException) {
EXPECT_THROW(parseFileSerialisationMethod("narwhal"), UsageError);
TEST(FileSerialisationMethod, testParseFileSerialisationMethodOptException)
{
EXPECT_THAT(
[]() { parseFileSerialisationMethod("narwhal"); },
testing::ThrowsMessage<UsageError>(testing::HasSubstr("narwhal")));
}
/* ----------------------------------------------------------------------------
@ -54,8 +58,11 @@ TEST(FileIngestionMethod, testRoundTripPrintParse_2) {
}
}
TEST(FileIngestionMethod, testParseFileIngestionMethodOptException) {
EXPECT_THROW(parseFileIngestionMethod("narwhal"), UsageError);
TEST(FileIngestionMethod, testParseFileIngestionMethodOptException)
{
EXPECT_THAT(
[]() { parseFileIngestionMethod("narwhal"); },
testing::ThrowsMessage<UsageError>(testing::HasSubstr("narwhal")));
}
}

View file

@ -22,7 +22,7 @@ FileSerialisationMethod parseFileSerialisationMethod(std::string_view input)
if (ret)
return *ret;
else
throw UsageError("Unknown file serialiation method '%s', expect `flat` or `nar`");
throw UsageError("Unknown file serialiation method '%s', expect `flat` or `nar`", input);
}
@ -35,7 +35,7 @@ FileIngestionMethod parseFileIngestionMethod(std::string_view input)
if (ret)
return static_cast<FileIngestionMethod>(*ret);
else
throw UsageError("Unknown file ingestion method '%s', expect `flat`, `nar`, or `git`");
throw UsageError("Unknown file ingestion method '%s', expect `flat`, `nar`, or `git`", input);
}
}