too few, too many args
This commit is contained in:
parent
cdddf24f25
commit
db475f9e7e
|
@ -70,9 +70,9 @@ namespace nix {
|
|||
testing::internal::CaptureStderr();
|
||||
|
||||
logger->logEI({ .level = lvlInfo,
|
||||
.name = "Info name",
|
||||
.description = "Info description",
|
||||
});
|
||||
.name = "Info name",
|
||||
.description = "Info description",
|
||||
});
|
||||
|
||||
auto str = testing::internal::GetCapturedStderr();
|
||||
ASSERT_STREQ(str.c_str(), "\x1B[32;1minfo:\x1B[0m\x1B[34;1m --- Info name --- error-unit-test\x1B[0m\nInfo description\n");
|
||||
|
@ -86,7 +86,7 @@ namespace nix {
|
|||
logger->logEI({ .level = lvlTalkative,
|
||||
.name = "Talkative name",
|
||||
.description = "Talkative description",
|
||||
});
|
||||
});
|
||||
|
||||
auto str = testing::internal::GetCapturedStderr();
|
||||
ASSERT_STREQ(str.c_str(), "\x1B[32;1mtalk:\x1B[0m\x1B[34;1m --- Talkative name --- error-unit-test\x1B[0m\nTalkative description\n");
|
||||
|
@ -100,7 +100,7 @@ namespace nix {
|
|||
logger->logEI({ .level = lvlChatty,
|
||||
.name = "Chatty name",
|
||||
.description = "Talkative description",
|
||||
});
|
||||
});
|
||||
|
||||
auto str = testing::internal::GetCapturedStderr();
|
||||
ASSERT_STREQ(str.c_str(), "\x1B[32;1mchat:\x1B[0m\x1B[34;1m --- Chatty name --- error-unit-test\x1B[0m\nTalkative description\n");
|
||||
|
@ -114,7 +114,7 @@ namespace nix {
|
|||
logger->logEI({ .level = lvlDebug,
|
||||
.name = "Debug name",
|
||||
.description = "Debug description",
|
||||
});
|
||||
});
|
||||
|
||||
auto str = testing::internal::GetCapturedStderr();
|
||||
ASSERT_STREQ(str.c_str(), "\x1B[33;1mdebug:\x1B[0m\x1B[34;1m --- Debug name --- error-unit-test\x1B[0m\nDebug description\n");
|
||||
|
@ -128,7 +128,7 @@ namespace nix {
|
|||
logger->logEI({ .level = lvlVomit,
|
||||
.name = "Vomit name",
|
||||
.description = "Vomit description",
|
||||
});
|
||||
});
|
||||
|
||||
auto str = testing::internal::GetCapturedStderr();
|
||||
ASSERT_STREQ(str.c_str(), "\x1B[32;1mvomit:\x1B[0m\x1B[34;1m --- Vomit name --- error-unit-test\x1B[0m\nVomit description\n");
|
||||
|
@ -145,7 +145,7 @@ namespace nix {
|
|||
logError({
|
||||
.name = "name",
|
||||
.description = "error description",
|
||||
});
|
||||
});
|
||||
|
||||
auto str = testing::internal::GetCapturedStderr();
|
||||
ASSERT_STREQ(str.c_str(), "\x1B[31;1merror:\x1B[0m\x1B[34;1m --- name --- error-unit-test\x1B[0m\nerror description\n");
|
||||
|
@ -161,13 +161,13 @@ namespace nix {
|
|||
.name = "error name",
|
||||
.description = "error with code lines",
|
||||
.hint = hintfmt("this hint has %1% templated %2%!!",
|
||||
"yellow",
|
||||
"values"),
|
||||
"yellow",
|
||||
"values"),
|
||||
.nixCode = NixCode {
|
||||
.errPos = Pos(problem_file, 40, 13),
|
||||
.prevLineOfCode = "previous line of code",
|
||||
.errLineOfCode = "this is the problem line of code",
|
||||
.nextLineOfCode = "next line of code",
|
||||
.errPos = Pos(problem_file, 40, 13),
|
||||
.prevLineOfCode = "previous line of code",
|
||||
.errLineOfCode = "this is the problem line of code",
|
||||
.nextLineOfCode = "next line of code",
|
||||
}});
|
||||
|
||||
|
||||
|
@ -184,10 +184,10 @@ namespace nix {
|
|||
.name = "error name",
|
||||
.description = "error without any code lines.",
|
||||
.hint = hintfmt("this hint has %1% templated %2%!!",
|
||||
"yellow",
|
||||
"values"),
|
||||
"yellow",
|
||||
"values"),
|
||||
.nixCode = NixCode {
|
||||
.errPos = Pos(problem_file, 40, 13)
|
||||
.errPos = Pos(problem_file, 40, 13)
|
||||
}});
|
||||
|
||||
auto str = testing::internal::GetCapturedStderr();
|
||||
|
@ -203,7 +203,7 @@ namespace nix {
|
|||
.name = "error name",
|
||||
.hint = hintfmt("hint %1%", "only"),
|
||||
.nixCode = NixCode {
|
||||
.errPos = Pos(problem_file, 40, 13)
|
||||
.errPos = Pos(problem_file, 40, 13)
|
||||
}});
|
||||
|
||||
auto str = testing::internal::GetCapturedStderr();
|
||||
|
@ -219,10 +219,10 @@ namespace nix {
|
|||
testing::internal::CaptureStderr();
|
||||
|
||||
logWarning({
|
||||
.name = "name",
|
||||
.description = "error description",
|
||||
.hint = hintfmt("there was a %1%", "warning"),
|
||||
});
|
||||
.name = "name",
|
||||
.description = "error description",
|
||||
.hint = hintfmt("there was a %1%", "warning"),
|
||||
});
|
||||
|
||||
auto str = testing::internal::GetCapturedStderr();
|
||||
ASSERT_STREQ(str.c_str(), "\x1B[33;1mwarning:\x1B[0m\x1B[34;1m --- name --- error-unit-test\x1B[0m\nerror description\n\nthere was a \x1B[33;1mwarning\x1B[0m\n");
|
||||
|
@ -239,13 +239,13 @@ namespace nix {
|
|||
.name = "warning name",
|
||||
.description = "warning description",
|
||||
.hint = hintfmt("this hint has %1% templated %2%!!",
|
||||
"yellow",
|
||||
"values"),
|
||||
"yellow",
|
||||
"values"),
|
||||
.nixCode = NixCode {
|
||||
.errPos = Pos(problem_file, 40, 13),
|
||||
.prevLineOfCode = std::nullopt,
|
||||
.errLineOfCode = "this is the problem line of code",
|
||||
.nextLineOfCode = std::nullopt
|
||||
.errPos = Pos(problem_file, 40, 13),
|
||||
.prevLineOfCode = std::nullopt,
|
||||
.errLineOfCode = "this is the problem line of code",
|
||||
.nextLineOfCode = std::nullopt
|
||||
}});
|
||||
|
||||
|
||||
|
@ -257,17 +257,28 @@ namespace nix {
|
|||
* hintfmt
|
||||
* --------------------------------------------------------------------------*/
|
||||
|
||||
TEST(hintfmt, withstandsPercentString) {
|
||||
TEST(hintfmt, percentStringWithoutArgs) {
|
||||
|
||||
const char *teststr = "this is 100%s correct!";
|
||||
auto hint = hintfmt(teststr);
|
||||
const char *teststr = "this is 100%s correct!";
|
||||
auto hint = hintfmt(teststr);
|
||||
|
||||
std::ofstream meh("meh.txt");
|
||||
meh << hint.str() << std::endl;
|
||||
ASSERT_STREQ(hint.str().c_str(), teststr);
|
||||
|
||||
ASSERT_STREQ(hint.str().c_str(), teststr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST(hintfmt, tooFewArguments) {
|
||||
|
||||
ASSERT_STREQ(
|
||||
hintfmt("only one arg %1% %2%", "fulfilled").str().c_str(),
|
||||
"only one arg " ANSI_YELLOW "fulfilled" ANSI_NORMAL " ");
|
||||
|
||||
}
|
||||
|
||||
TEST(hintfmt, tooManyArguments) {
|
||||
|
||||
ASSERT_STREQ(
|
||||
hintfmt("what about this %1% %2%", "%3%", "one", "two").str().c_str(),
|
||||
"what about this " ANSI_YELLOW "%3%" ANSI_NORMAL " " ANSI_YELLOW "one" ANSI_NORMAL);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue