blob: 90bcdfbe4271544000d4f42ef2b6f9b458f641c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#include "fmt.hh"
#include "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");
}
}
|