mirror of
https://github.com/NVIDIA/nvbench.git
synced 2026-04-19 22:38:52 +00:00
Fix usages of ASSERT_MSG that creates empty __VA_ARGS__.
Invoking a variadic macro with zero variadic args is illegal until C++20. The extra calls to fmt::format were unnecessary, anyway.
This commit is contained in:
@@ -72,14 +72,15 @@ Axis: Other
|
||||
std::mismatch(ref.cbegin(), ref.cend(), test.cbegin(), test.cend());
|
||||
const auto idx = diff.second - test.cbegin();
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Differs at character {}.\n"
|
||||
"Expected:\n\"{}\"\n\n"
|
||||
"Actual:\n\"{}\"\n-- ERROR --\n\"{}\"",
|
||||
idx,
|
||||
ref,
|
||||
std::string_view(test.c_str(), idx),
|
||||
std::string_view(test.c_str() + idx,
|
||||
test.size() - idx)));
|
||||
"Differs at character {}.\n"
|
||||
"Expected:\n\"{}\"\n\n"
|
||||
"Actual:\n\"{}\"\n"
|
||||
"-- ERROR --\n"
|
||||
"\"{}\"",
|
||||
idx,
|
||||
ref,
|
||||
std::string_view(test.c_str(), idx),
|
||||
std::string_view(test.c_str() + idx, test.size() - idx));
|
||||
}
|
||||
|
||||
void test_float64_axes()
|
||||
|
||||
@@ -112,8 +112,7 @@ Axis: Other
|
||||
)expected";
|
||||
|
||||
const std::string test = fmt::to_string(buffer);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
void test_type_configs()
|
||||
@@ -158,8 +157,7 @@ type_configs[15] = <I64, F64, void>
|
||||
)type_config_ref";
|
||||
|
||||
const std::string test = fmt::to_string(buffer);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
void test_float64_axes()
|
||||
|
||||
@@ -23,10 +23,9 @@ void test_basic(cudaStream_t time_stream,
|
||||
NVBENCH_CUDA_CALL(cudaDeviceSynchronize());
|
||||
const bool captured = timer.get_duration() > 0.25;
|
||||
ASSERT_MSG(captured == expected,
|
||||
fmt::format("Unexpected result from timer: {} seconds "
|
||||
" (expected {})",
|
||||
timer.get_duration(),
|
||||
(expected ? "> 0.25s" : "< 0.25s")));
|
||||
"Unexpected result from timer: {} seconds (expected {})",
|
||||
timer.get_duration(),
|
||||
(expected ? "> 0.25s" : "< 0.25s"));
|
||||
}
|
||||
|
||||
void test_basic()
|
||||
|
||||
@@ -156,8 +156,7 @@ void test_benchmark_long() // --benchmark
|
||||
nvbench::option_parser parser;
|
||||
parser.parse({"--benchmark", "TestBench"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
void test_benchmark_short() // -b
|
||||
@@ -179,8 +178,7 @@ void test_benchmark_short() // -b
|
||||
nvbench::option_parser parser;
|
||||
parser.parse({"-b", "TestBench"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
void test_int64_axis()
|
||||
@@ -213,16 +211,14 @@ void test_int64_axis()
|
||||
parser.parse(
|
||||
{"--benchmark", "TestBench", "--axis", " Ints [ ] : { 2 , 7 } "});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
nvbench::option_parser parser;
|
||||
parser.parse({"--benchmark", "TestBench", "--axis", "Ints:{2,7}"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -230,16 +226,14 @@ void test_int64_axis()
|
||||
parser.parse(
|
||||
{"--benchmark", "TestBench", "--axis", " Ints [ ] : ( 2 : 7 : 5 ) "});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
nvbench::option_parser parser;
|
||||
parser.parse({"--benchmark", "TestBench", "--axis", "Ints:(2:7:5)"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,16 +267,14 @@ void test_int64_axis_pow2()
|
||||
parser.parse(
|
||||
{"--benchmark", "TestBench", "--axis", " PO2s [ pow2 ] : { 2 , 7 } "});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
nvbench::option_parser parser;
|
||||
parser.parse({"--benchmark", "TestBench", "--axis", "PO2s[pow2]:{2,7}"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -290,16 +282,14 @@ void test_int64_axis_pow2()
|
||||
parser.parse(
|
||||
{"--benchmark", "TestBench", "--axis", " PO2s [ pow2 ] : ( 2 : 7 : 5 ) "});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
nvbench::option_parser parser;
|
||||
parser.parse({"--benchmark", "TestBench", "--axis", "PO2s[pow2]:(2:7:5)"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,16 +323,14 @@ void test_int64_axis_none_to_pow2()
|
||||
parser.parse(
|
||||
{"--benchmark", "TestBench", "--axis", " Ints [ pow2 ] : { 2 , 7 } "});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
nvbench::option_parser parser;
|
||||
parser.parse({"--benchmark", "TestBench", "--axis", "Ints[pow2]:{2,7}"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -350,16 +338,14 @@ void test_int64_axis_none_to_pow2()
|
||||
parser.parse(
|
||||
{"--benchmark", "TestBench", "--axis", " Ints [ pow2 ] : ( 2 : 7 : 5 ) "});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
nvbench::option_parser parser;
|
||||
parser.parse({"--benchmark", "TestBench", "--axis", "Ints[pow2]:(2:7:5)"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,16 +379,14 @@ void test_int64_axis_pow2_to_none()
|
||||
parser.parse(
|
||||
{"--benchmark", "TestBench", "--axis", " PO2s [ ] : { 2 , 7 } "});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
nvbench::option_parser parser;
|
||||
parser.parse({"--benchmark", "TestBench", "--axis", "PO2s:{2,7}"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -410,16 +394,14 @@ void test_int64_axis_pow2_to_none()
|
||||
parser.parse(
|
||||
{"--benchmark", "TestBench", "--axis", " PO2s [ ] : ( 2 : 7 : 5 ) "});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
nvbench::option_parser parser;
|
||||
parser.parse({"--benchmark", "TestBench", "--axis", "PO2s:(2:7:5)"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,16 +435,14 @@ void test_float64_axis()
|
||||
parser.parse(
|
||||
{"--benchmark", "TestBench", "--axis", " Floats [ ] : { 3.5 , 4.1 } "});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
nvbench::option_parser parser;
|
||||
parser.parse({"--benchmark", "TestBench", "--axis", "Floats:{3.5,4.1}"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -472,8 +452,7 @@ void test_float64_axis()
|
||||
"--axis",
|
||||
" Floats [ ] : ( 3.5 : 4.2 : 0.6 ) "});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -481,8 +460,7 @@ void test_float64_axis()
|
||||
parser.parse(
|
||||
{"--benchmark", "TestBench", "--axis", "Floats:(3.5:4.2:0.6)"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -516,16 +494,14 @@ void test_string_axis()
|
||||
parser.parse(
|
||||
{"--benchmark", "TestBench", "--axis", " Strings [ ] : { fo br , baz } "});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
nvbench::option_parser parser;
|
||||
parser.parse({"--benchmark", "TestBench", "--axis", "Strings:{fo br,baz}"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,16 +523,14 @@ void test_type_axis()
|
||||
parser.parse(
|
||||
{"--benchmark", "TestBench", "--axis", " T [ ] : { U8, void } "});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
nvbench::option_parser parser;
|
||||
parser.parse({"--benchmark", "TestBench", "--axis", "T:{void,U8}"});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -726,8 +700,7 @@ void test_multi_axis()
|
||||
// clang-format on
|
||||
});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -744,8 +717,7 @@ void test_multi_axis()
|
||||
// clang-format on
|
||||
});
|
||||
const auto test = parser_to_state_string(parser);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -141,8 +141,7 @@ Params: Float: 13 Int: 3 String: Three
|
||||
)expected";
|
||||
|
||||
const std::string test = fmt::to_string(buffer);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
void test_types()
|
||||
@@ -190,8 +189,7 @@ Params: FloatT: F64 IntT: I64 MiscT: void
|
||||
)expected";
|
||||
|
||||
const std::string test = fmt::to_string(buffer);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
void test_both()
|
||||
@@ -451,8 +449,7 @@ Params: Float: 13 FloatT: F64 Int: 3 IntT: I64 MiscT: void String: Three
|
||||
)expected";
|
||||
|
||||
const std::string test = fmt::to_string(buffer);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
||||
@@ -134,8 +134,7 @@ void test_basic()
|
||||
)expected";
|
||||
|
||||
const std::string test = fmt::to_string(buffer);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
void test_create()
|
||||
@@ -236,8 +235,7 @@ void test_create()
|
||||
)expected";
|
||||
|
||||
const std::string test = fmt::to_string(buffer);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
void test_create_with_types()
|
||||
@@ -597,8 +595,7 @@ void test_create_with_types()
|
||||
)expected";
|
||||
|
||||
const std::string test = fmt::to_string(buffer);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
void test_create_with_masked_types()
|
||||
@@ -735,8 +732,7 @@ void test_create_with_masked_types()
|
||||
)expected";
|
||||
|
||||
const std::string test = fmt::to_string(buffer);
|
||||
ASSERT_MSG(test == ref,
|
||||
fmt::format("Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test));
|
||||
ASSERT_MSG(test == ref, "Expected:\n\"{}\"\n\nActual:\n\"{}\"", ref, test);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
||||
@@ -146,8 +146,7 @@ struct test_foreach
|
||||
using T = typename decltype(wrapped_type)::type;
|
||||
test_vals.push_back(nvbench::type_strings<T>::input_string());
|
||||
});
|
||||
ASSERT_MSG(test_vals == ref_vals,
|
||||
fmt::format("{} != {}", test_vals, ref_vals));
|
||||
ASSERT_MSG(test_vals == ref_vals, "{} != {}", test_vals, ref_vals);
|
||||
}
|
||||
|
||||
static void run()
|
||||
|
||||
Reference in New Issue
Block a user