aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/logging/unittests/static_analysis_ut.cpp
blob: 7fb4c0150c939b478d80454558a7f8280f052c69 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <library/cpp/testing/gtest/gtest.h>

#include <library/cpp/yt/logging/logger.h>

namespace NYT::NLogging {
namespace {

////////////////////////////////////////////////////////////////////////////////

const TLogger Logger{};

TEST(TStaticAnalysisTest, ValidFormats)
{
    YT_LOG_INFO("Hello");
    YT_LOG_INFO("Hello %v", "World!");
    YT_LOG_INFO("Hello %qv", "World!");
    YT_LOG_INFO(42);
    YT_LOG_INFO("Hello %%");
    YT_LOG_INFO("Hello %" PRIu64, 42);

    TStringBuf msg = "Hello";
    YT_LOG_INFO(msg);
}

// Uncomment this test to see that we don't have false negatives!
// TEST(TStaticAnalysisTest, InvalidFormats)
// {
//     YT_LOG_INFO("Hello", 1);
//     YT_LOG_INFO("Hello %");
//     YT_LOG_INFO("Hello %false");
//     YT_LOG_INFO("Hello ", "World");
//     YT_LOG_INFO("Hello ", "(World: %v)", 42);
//     YT_LOG_INFO("Hello %lbov", 42); // There is no 'b' flag.
// }

////////////////////////////////////////////////////////////////////////////////

} // namespace
} // namespace NYT::NLogging