ladybird/Tests/AK/TestSourceLocation.cpp
Daniel Bertalan 7396e4aedc LibDebug: Store 64-bit numbers in AttributeValue
This helps us avoid weird truncation issues and fixes a bug on Clang
builds where truncation while reading caused the DIE offsets following
large LEB128 numbers to be incorrect. This removes the need for the
separate `LongUnsignedNumber` type.
2021-08-08 10:55:36 +02:00

36 lines
987 B
C++

/*
* Copyright (c) 2021, Andrew Kaster <akaster@serenityos.org>
* Copyright (c) 2021, Brian Gianforcaro <bgianf@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibTest/TestCase.h>
#include <AK/SourceLocation.h>
#include <AK/StringView.h>
TEST_CASE(basic_scenario)
{
auto location = SourceLocation::current();
EXPECT_EQ(StringView(__FUNCTION__), location.function_name());
EXPECT_EQ(__LINE__ - 2u, location.line_number());
// FIXME: On Clang, __FILE__ is a relative path, while location.path() is absolute
#ifndef __clang__
EXPECT_EQ(StringView(__FILE__), location.filename());
#endif
}
static StringView test_default_arg(const SourceLocation& loc = SourceLocation::current())
{
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);
}