Files
lix/tests/unit/libutil/fmt.cc
T
Jade Lovelace 6d8e4337e2 tests: fix the fmt.cc test
Yikes!! I wonder if we have any other ones of these that just .. didn't
get added to a meson file?

Change-Id: I19480ab03cdbecf608e523d5b6c3980233f4f445
2025-04-03 18:40:06 -07:00

24 lines
618 B
C++

#include "lix/libutil/fmt.hh"
#include "lix/libutil/ansicolor.hh"
#include <gtest/gtest.h>
namespace nix {
TEST(HintFmt, arg_count)
{
// Single arg is treated as a literal string.
ASSERT_EQ(HintFmt("%s").str(), "%s");
// Other strings format as expected:
ASSERT_EQ(HintFmt("%s", 1).str(), ANSI_MAGENTA "1" ANSI_NORMAL);
ASSERT_EQ(HintFmt("%1%", "hello").str(), ANSI_MAGENTA "hello" ANSI_NORMAL);
// Argument counts are detected at construction.
ASSERT_DEATH(HintFmt("%s %s", 1), "HintFmt received incorrect");
ASSERT_DEATH(HintFmt("%s", 1, 2), "HintFmt received incorrect");
}
}