diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/functional/meson.build | 3 | ||||
-rw-r--r-- | tests/unit/libutil/fmt.cc | 23 |
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/functional/meson.build b/tests/functional/meson.build index 53dc21af5..0ea0e4df5 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -176,5 +176,8 @@ foreach script : functional_tests_scripts env : { 'MESON_BUILD_ROOT': meson.project_build_root(), }, + # some tests take 15+ seconds even on an otherwise idle machine, on a loaded machine + # this can easily drive them to failure. give them more time, 5min rather than 30sec + timeout : 300, ) endforeach diff --git a/tests/unit/libutil/fmt.cc b/tests/unit/libutil/fmt.cc new file mode 100644 index 000000000..383a688d3 --- /dev/null +++ b/tests/unit/libutil/fmt.cc @@ -0,0 +1,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_THROW(HintFmt("%s %s", 1), boost::io::too_few_args); + + ASSERT_THROW(HintFmt("%s", 1, 2), boost::io::too_many_args); +} + +} |