mirror of
https://github.com/PCSX2/pcsx2.git
synced 2026-07-11 01:34:17 +02:00
SmallString: Improve self-assignment behaviour
This commit is contained in:
@@ -392,7 +392,8 @@ void SmallStringBase::vsprintf(const char* format, va_list ap)
|
||||
|
||||
void SmallStringBase::assign(const SmallStringBase& copy)
|
||||
{
|
||||
assign(copy.c_str(), copy.length());
|
||||
if (this != ©)
|
||||
assign(copy.c_str(), copy.length());
|
||||
}
|
||||
|
||||
void SmallStringBase::assign(const char* str)
|
||||
|
||||
@@ -2,6 +2,7 @@ add_pcsx2_test(common_test
|
||||
byteswap_tests.cpp
|
||||
filesystem_tests.cpp
|
||||
path_tests.cpp
|
||||
small_string_tests.cpp
|
||||
string_util_tests.cpp
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// SPDX-FileCopyrightText: 2002-2026 PCSX2 Dev Team
|
||||
// SPDX-License-Identifier: GPL-3.0+
|
||||
|
||||
#include "common/SmallString.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(StackString, SelfAssignment)
|
||||
{
|
||||
SmallStackString<6> string("Hello");
|
||||
string = string;
|
||||
ASSERT_STREQ(string.c_str(), "Hello");
|
||||
}
|
||||
Reference in New Issue
Block a user