forked from lix-project/lix
too few, too many args
This commit is contained in:
parent
cdddf24f25
commit
db475f9e7e
|
@ -70,9 +70,9 @@ namespace nix {
|
||||||
testing::internal::CaptureStderr();
|
testing::internal::CaptureStderr();
|
||||||
|
|
||||||
logger->logEI({ .level = lvlInfo,
|
logger->logEI({ .level = lvlInfo,
|
||||||
.name = "Info name",
|
.name = "Info name",
|
||||||
.description = "Info description",
|
.description = "Info description",
|
||||||
});
|
});
|
||||||
|
|
||||||
auto str = testing::internal::GetCapturedStderr();
|
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");
|
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,
|
logger->logEI({ .level = lvlTalkative,
|
||||||
.name = "Talkative name",
|
.name = "Talkative name",
|
||||||
.description = "Talkative description",
|
.description = "Talkative description",
|
||||||
});
|
});
|
||||||
|
|
||||||
auto str = testing::internal::GetCapturedStderr();
|
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");
|
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,
|
logger->logEI({ .level = lvlChatty,
|
||||||
.name = "Chatty name",
|
.name = "Chatty name",
|
||||||
.description = "Talkative description",
|
.description = "Talkative description",
|
||||||
});
|
});
|
||||||
|
|
||||||
auto str = testing::internal::GetCapturedStderr();
|
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");
|
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,
|
logger->logEI({ .level = lvlDebug,
|
||||||
.name = "Debug name",
|
.name = "Debug name",
|
||||||
.description = "Debug description",
|
.description = "Debug description",
|
||||||
});
|
});
|
||||||
|
|
||||||
auto str = testing::internal::GetCapturedStderr();
|
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");
|
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,
|
logger->logEI({ .level = lvlVomit,
|
||||||
.name = "Vomit name",
|
.name = "Vomit name",
|
||||||
.description = "Vomit description",
|
.description = "Vomit description",
|
||||||
});
|
});
|
||||||
|
|
||||||
auto str = testing::internal::GetCapturedStderr();
|
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");
|
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({
|
logError({
|
||||||
.name = "name",
|
.name = "name",
|
||||||
.description = "error description",
|
.description = "error description",
|
||||||
});
|
});
|
||||||
|
|
||||||
auto str = testing::internal::GetCapturedStderr();
|
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");
|
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",
|
.name = "error name",
|
||||||
.description = "error with code lines",
|
.description = "error with code lines",
|
||||||
.hint = hintfmt("this hint has %1% templated %2%!!",
|
.hint = hintfmt("this hint has %1% templated %2%!!",
|
||||||
"yellow",
|
"yellow",
|
||||||
"values"),
|
"values"),
|
||||||
.nixCode = NixCode {
|
.nixCode = NixCode {
|
||||||
.errPos = Pos(problem_file, 40, 13),
|
.errPos = Pos(problem_file, 40, 13),
|
||||||
.prevLineOfCode = "previous line of code",
|
.prevLineOfCode = "previous line of code",
|
||||||
.errLineOfCode = "this is the problem line of code",
|
.errLineOfCode = "this is the problem line of code",
|
||||||
.nextLineOfCode = "next line of code",
|
.nextLineOfCode = "next line of code",
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
|
||||||
|
@ -184,10 +184,10 @@ namespace nix {
|
||||||
.name = "error name",
|
.name = "error name",
|
||||||
.description = "error without any code lines.",
|
.description = "error without any code lines.",
|
||||||
.hint = hintfmt("this hint has %1% templated %2%!!",
|
.hint = hintfmt("this hint has %1% templated %2%!!",
|
||||||
"yellow",
|
"yellow",
|
||||||
"values"),
|
"values"),
|
||||||
.nixCode = NixCode {
|
.nixCode = NixCode {
|
||||||
.errPos = Pos(problem_file, 40, 13)
|
.errPos = Pos(problem_file, 40, 13)
|
||||||
}});
|
}});
|
||||||
|
|
||||||
auto str = testing::internal::GetCapturedStderr();
|
auto str = testing::internal::GetCapturedStderr();
|
||||||
|
@ -203,7 +203,7 @@ namespace nix {
|
||||||
.name = "error name",
|
.name = "error name",
|
||||||
.hint = hintfmt("hint %1%", "only"),
|
.hint = hintfmt("hint %1%", "only"),
|
||||||
.nixCode = NixCode {
|
.nixCode = NixCode {
|
||||||
.errPos = Pos(problem_file, 40, 13)
|
.errPos = Pos(problem_file, 40, 13)
|
||||||
}});
|
}});
|
||||||
|
|
||||||
auto str = testing::internal::GetCapturedStderr();
|
auto str = testing::internal::GetCapturedStderr();
|
||||||
|
@ -219,10 +219,10 @@ namespace nix {
|
||||||
testing::internal::CaptureStderr();
|
testing::internal::CaptureStderr();
|
||||||
|
|
||||||
logWarning({
|
logWarning({
|
||||||
.name = "name",
|
.name = "name",
|
||||||
.description = "error description",
|
.description = "error description",
|
||||||
.hint = hintfmt("there was a %1%", "warning"),
|
.hint = hintfmt("there was a %1%", "warning"),
|
||||||
});
|
});
|
||||||
|
|
||||||
auto str = testing::internal::GetCapturedStderr();
|
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");
|
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",
|
.name = "warning name",
|
||||||
.description = "warning description",
|
.description = "warning description",
|
||||||
.hint = hintfmt("this hint has %1% templated %2%!!",
|
.hint = hintfmt("this hint has %1% templated %2%!!",
|
||||||
"yellow",
|
"yellow",
|
||||||
"values"),
|
"values"),
|
||||||
.nixCode = NixCode {
|
.nixCode = NixCode {
|
||||||
.errPos = Pos(problem_file, 40, 13),
|
.errPos = Pos(problem_file, 40, 13),
|
||||||
.prevLineOfCode = std::nullopt,
|
.prevLineOfCode = std::nullopt,
|
||||||
.errLineOfCode = "this is the problem line of code",
|
.errLineOfCode = "this is the problem line of code",
|
||||||
.nextLineOfCode = std::nullopt
|
.nextLineOfCode = std::nullopt
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
|
||||||
|
@ -257,17 +257,28 @@ namespace nix {
|
||||||
* hintfmt
|
* hintfmt
|
||||||
* --------------------------------------------------------------------------*/
|
* --------------------------------------------------------------------------*/
|
||||||
|
|
||||||
TEST(hintfmt, withstandsPercentString) {
|
TEST(hintfmt, percentStringWithoutArgs) {
|
||||||
|
|
||||||
const char *teststr = "this is 100%s correct!";
|
const char *teststr = "this is 100%s correct!";
|
||||||
auto hint = hintfmt(teststr);
|
auto hint = hintfmt(teststr);
|
||||||
|
|
||||||
std::ofstream meh("meh.txt");
|
ASSERT_STREQ(hint.str().c_str(), teststr);
|
||||||
meh << hint.str() << std::endl;
|
|
||||||
|
|
||||||
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