From 10e3f94798b6408db8e9952199bbad88fd3470f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C4=81vis=20Mos=C4=81ns?= <davispuh@gmail.com> Date: Sun, 18 Sep 2016 23:18:07 +0300 Subject: [PATCH] ConsoleBuf: Fix test to compare all bytes of wide character strings std::wstring<>::size() returns characters, not bytes. Change-Id: Iced3d7246d022e3eea582dbd880ff2c71a145f5d --- testConsoleBuf.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/testConsoleBuf.cxx b/testConsoleBuf.cxx index 50368c0..836c27e 100644 --- a/testConsoleBuf.cxx +++ b/testConsoleBuf.cxx @@ -591,14 +591,16 @@ static int testConsole() } std::wstring wideTestString = kwsys::Encoding::ToWide(encodedTestString); std::wstring wideInputTestString = kwsys::Encoding::ToWide(encodedInputTestString); - if (memcmp(outputBuffer, wideTestString.c_str(), wideTestString.size()) == 0 && + if (memcmp(outputBuffer, wideTestString.c_str(), + wideTestString.size() * sizeof(wchar_t)) == 0 && memcmp(outputBuffer + screenBufferInfo.dwSize.X * 1, - wideTestString.c_str(), wideTestString.size()) == 0 && + wideTestString.c_str(), wideTestString.size() * sizeof(wchar_t)) == 0 && memcmp(outputBuffer + screenBufferInfo.dwSize.X * 2, UnicodeInputTestString, sizeof(UnicodeInputTestString) - sizeof(WCHAR)) == 0 && memcmp(outputBuffer + screenBufferInfo.dwSize.X * 3, - wideInputTestString.c_str(), wideInputTestString.size() - 1) == 0 + wideInputTestString.c_str(), + (wideInputTestString.size() - 1) * sizeof(wchar_t)) == 0 ) { didFail = 0; } else { -- GitLab