2021-04-23 22:26:53 -07:00
|
|
|
/*
|
2021-05-30 07:28:59 -06:00
|
|
|
* Copyright (c) 2021, Andrew Kaster <akaster@serenityos.org>
|
2021-04-23 22:26:53 -07:00
|
|
|
* Copyright (c) 2021, Brian Gianforcaro <bgianf@serenityos.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
2021-04-24 23:53:23 -06:00
|
|
|
#include <LibTest/TestCase.h>
|
|
|
|
|
|
2021-04-23 22:26:53 -07:00
|
|
|
#include <AK/SourceLocation.h>
|
|
|
|
|
#include <AK/StringView.h>
|
|
|
|
|
|
|
|
|
|
TEST_CASE(basic_scenario)
|
|
|
|
|
{
|
|
|
|
|
auto location = SourceLocation::current();
|
|
|
|
|
EXPECT_EQ(StringView(__FUNCTION__), location.function_name());
|
2021-07-27 11:03:24 +02:00
|
|
|
EXPECT_EQ(__LINE__ - 2u, location.line_number());
|
|
|
|
|
EXPECT_EQ(StringView(__FILE__), location.filename());
|
2021-04-23 22:26:53 -07:00
|
|
|
}
|
|
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
static StringView test_default_arg(SourceLocation const& loc = SourceLocation::current())
|
2021-04-23 22:26:53 -07:00
|
|
|
{
|
|
|
|
|
return loc.function_name();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_CASE(default_arg_scenario)
|
|
|
|
|
{
|
|
|
|
|
auto actual_calling_function = test_default_arg();
|
|
|
|
|
auto expected_calling_function = StringView(__FUNCTION__);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(expected_calling_function, actual_calling_function);
|
|
|
|
|
}
|