mirror of
https://github.com/debauchee/barrier.git
synced 2024-12-24 19:42:24 +03:00
Added stringToSizeType and its unittest #4601
This commit is contained in:
parent
c032091dd5
commit
2c74a7f5c1
@ -208,13 +208,22 @@ removeChar(String& subject, const char c)
|
||||
}
|
||||
|
||||
String
|
||||
intToString(size_t integer)
|
||||
sizeTypeToString(size_t n)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << integer;
|
||||
ss << n;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
size_t
|
||||
stringToSizeType(String string)
|
||||
{
|
||||
std::istringstream iss(string);
|
||||
size_t value;
|
||||
iss >> value;
|
||||
return value;
|
||||
}
|
||||
|
||||
//
|
||||
// CaselessCmp
|
||||
//
|
||||
|
@ -88,11 +88,17 @@ Remove all specific \c c in \c suject
|
||||
*/
|
||||
void removeChar(String& subject, const char c);
|
||||
|
||||
//! Convert an integer to a string
|
||||
//! Convert a size type to a string
|
||||
/*!
|
||||
Convert an \c integer to a string
|
||||
Convert an size type to a string
|
||||
*/
|
||||
String intToString(size_t integer);
|
||||
String sizeTypeToString(size_t n);
|
||||
|
||||
//! Convert a string to a size type
|
||||
/*!
|
||||
Convert an a \c string to an size type
|
||||
*/
|
||||
size_t stringToSizeType(String string);
|
||||
|
||||
//! Case-insensitive comparisons
|
||||
/*!
|
||||
|
@ -54,7 +54,7 @@ StreamChunker::sendFile(
|
||||
size_t size = (size_t)file.tellg();
|
||||
|
||||
// send first message (file size)
|
||||
String fileSize = synergy::string::intToString(size);
|
||||
String fileSize = synergy::string::sizeTypeToString(size);
|
||||
FileChunk* sizeMessage = FileChunk::start(fileSize);
|
||||
|
||||
events->addEvent(Event(events->forIScreen().fileChunkSending(), eventTarget, sizeMessage));
|
||||
@ -109,7 +109,7 @@ StreamChunker::sendClipboard(
|
||||
void* eventTarget)
|
||||
{
|
||||
// send first message (data size)
|
||||
String dataSize = synergy::string::intToString(size);
|
||||
String dataSize = synergy::string::sizeTypeToString(size);
|
||||
ClipboardChunk* sizeMessage = ClipboardChunk::start(id, sequence, dataSize);
|
||||
|
||||
events->addEvent(Event(events->forClientProxy().clipboardSending(), eventTarget, sizeMessage));
|
||||
|
@ -415,7 +415,7 @@ void
|
||||
NetworkTests::sendMockData(void* eventTarget)
|
||||
{
|
||||
// send first message (file size)
|
||||
String size = synergy::string::intToString(kMockDataSize);
|
||||
String size = synergy::string::sizeTypeToString(kMockDataSize);
|
||||
FileChunk* sizeMessage = FileChunk::start(size);
|
||||
|
||||
m_events.addEvent(Event(m_events.forIScreen().fileChunkSending(), eventTarget, sizeMessage));
|
||||
|
@ -82,3 +82,21 @@ TEST(StringTests, removeChar)
|
||||
|
||||
EXPECT_EQ("fbar", subject);
|
||||
}
|
||||
|
||||
TEST(StringTests, intToString)
|
||||
{
|
||||
size_t value = 123;
|
||||
|
||||
String number = string::sizeTypeToString(value);
|
||||
|
||||
EXPECT_EQ("123", number);
|
||||
}
|
||||
|
||||
TEST(StringTests, stringToUint)
|
||||
{
|
||||
String number = "123";
|
||||
|
||||
size_t value = string::stringToSizeType(number);
|
||||
|
||||
EXPECT_EQ(123, value);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user