refactor: replace UInt16 with uint16_t

This commit is contained in:
sithlord48
2025-01-10 19:58:26 -05:00
committed by Nick Bolton
parent 1ed49e7487
commit 7487eeaa3a
21 changed files with 88 additions and 89 deletions

View File

@ -25,12 +25,12 @@
// local utility functions
//
inline static UInt16 decode16(const uint8_t *n, bool byteSwapped)
inline static uint16_t decode16(const uint8_t *n, bool byteSwapped)
{
union x16
{
uint8_t n8[2];
UInt16 n16;
uint16_t n16;
} c;
if (byteSwapped) {
c.n8[0] = n[1];
@ -116,7 +116,7 @@ std::string Unicode::UTF8ToUCS2(const std::string &src, bool *errors)
setError(errors);
c = s_replacement;
}
UInt16 ucs2 = static_cast<UInt16>(c);
uint16_t ucs2 = static_cast<uint16_t>(c);
dst.append(reinterpret_cast<const char *>(&ucs2), 2);
}
@ -167,12 +167,12 @@ std::string Unicode::UTF8ToUTF16(const std::string &src, bool *errors)
c = s_replacement;
}
if (c < 0x00010000) {
UInt16 ucs2 = static_cast<UInt16>(c);
uint16_t ucs2 = static_cast<uint16_t>(c);
dst.append(reinterpret_cast<const char *>(&ucs2), 2);
} else {
c -= 0x00010000;
UInt16 utf16h = static_cast<UInt16>((c >> 10) + 0xd800);
UInt16 utf16l = static_cast<UInt16>((c & 0x03ff) + 0xdc00);
uint16_t utf16h = static_cast<uint16_t>((c >> 10) + 0xd800);
uint16_t utf16l = static_cast<uint16_t>((c & 0x03ff) + 0xdc00);
dst.append(reinterpret_cast<const char *>(&utf16h), 2);
dst.append(reinterpret_cast<const char *>(&utf16l), 2);
}

View File

@ -240,9 +240,9 @@ ServerProxy::EResult ServerProxy::parseMessage(const uint8_t *code)
}
else if (memcmp(code, kMsgDKeyDown, 4) == 0) {
UInt16 id = 0;
UInt16 mask = 0;
UInt16 button = 0;
uint16_t id = 0;
uint16_t mask = 0;
uint16_t button = 0;
ProtocolUtil::readf(m_stream, kMsgDKeyDown + 4, &id, &mask, &button);
LOG((CLOG_DEBUG1 "recv key down id=0x%08x, mask=0x%04x, button=0x%04x", id, mask, button));
@ -251,9 +251,9 @@ ServerProxy::EResult ServerProxy::parseMessage(const uint8_t *code)
else if (memcmp(code, kMsgDKeyDownLang, 4) == 0) {
std::string lang;
UInt16 id = 0;
UInt16 mask = 0;
UInt16 button = 0;
uint16_t id = 0;
uint16_t mask = 0;
uint16_t button = 0;
ProtocolUtil::readf(m_stream, kMsgDKeyDownLang + 4, &id, &mask, &button, &lang);
LOG((CLOG_DEBUG1 "recv key down id=0x%08x, mask=0x%04x, button=0x%04x, lang=\"%s\"", id, mask, button, lang.c_str())
@ -514,7 +514,7 @@ void ServerProxy::enter()
{
// parse
int16_t x, y;
UInt16 mask;
uint16_t mask;
UInt32 seqNum;
ProtocolUtil::readf(m_stream, kMsgCEnter + 4, &x, &y, &seqNum, &mask);
LOG((CLOG_DEBUG1 "recv enter, %d,%d %d %04x", x, y, seqNum, mask));
@ -585,7 +585,7 @@ void ServerProxy::grabClipboard()
m_client->grabClipboard(id);
}
void ServerProxy::keyDown(UInt16 id, UInt16 mask, UInt16 button, const std::string &lang)
void ServerProxy::keyDown(uint16_t id, uint16_t mask, uint16_t button, const std::string &lang)
{
// get mouse up to date
flushCompressedMouse();
@ -607,7 +607,7 @@ void ServerProxy::keyRepeat()
flushCompressedMouse();
// parse
UInt16 id, mask, count, button;
uint16_t id, mask, count, button;
std::string lang;
ProtocolUtil::readf(m_stream, kMsgDKeyRepeat + 4, &id, &mask, &count, &button, &lang);
LOG(
@ -632,7 +632,7 @@ void ServerProxy::keyUp()
flushCompressedMouse();
// parse
UInt16 id, mask, button;
uint16_t id, mask, button;
ProtocolUtil::readf(m_stream, kMsgDKeyUp + 4, &id, &mask, &button);
LOG((CLOG_DEBUG1 "recv key up id=0x%08x, mask=0x%04x, button=0x%04x", id, mask, button));

View File

@ -107,7 +107,7 @@ private:
void leave();
void setClipboard();
void grabClipboard();
void keyDown(UInt16 id, UInt16 mask, UInt16 button, const std::string &lang);
void keyDown(uint16_t id, uint16_t mask, uint16_t button, const std::string &lang);
void keyRepeat();
void keyUp();
void mouseDown();

View File

@ -85,7 +85,6 @@
#include <CoreServices/CoreServices.h>
#else
using SInt32 = signed TYPE_OF_SIZE_4;
using UInt16 = unsigned TYPE_OF_SIZE_2;
using UInt32 = unsigned TYPE_OF_SIZE_4;
#endif
#endif

View File

@ -24,7 +24,7 @@
#include "deskflow/protocol_types.h"
#include "io/IStream.h"
static const UInt16 kIntervalThreshold = 1;
static const uint16_t kIntervalThreshold = 1;
FileChunk::FileChunk(size_t size) : Chunk(size)
{

View File

@ -160,7 +160,7 @@ void ProtocolUtil::vreadf(deskflow::IStream *stream, const char *fmt, va_list ar
break;
case 2:
// 2 byte integer
*static_cast<UInt16 *>(destination) = read2BytesInt(stream);
*static_cast<uint16_t *>(destination) = read2BytesInt(stream);
break;
case 4:
// 4 byte integer
@ -184,7 +184,7 @@ void ProtocolUtil::vreadf(deskflow::IStream *stream, const char *fmt, va_list ar
break;
case 2:
// 2 byte integer
readVector2BytesInt(stream, *static_cast<std::vector<UInt16> *>(destination));
readVector2BytesInt(stream, *static_cast<std::vector<uint16_t> *>(destination));
break;
case 4:
// 4 byte integer
@ -260,7 +260,7 @@ UInt32 ProtocolUtil::getLength(const char *fmt, va_list args)
break;
case 2:
len = 2 * (UInt32)(va_arg(args, std::vector<UInt16> *))->size() + 4;
len = 2 * (UInt32)(va_arg(args, std::vector<uint16_t> *))->size() + 4;
break;
case 4:
@ -325,7 +325,7 @@ void ProtocolUtil::writef(std::vector<uint8_t> &buffer, const char *fmt, va_list
case 2: {
// 2 byte integers
const std::vector<UInt16> *list = va_arg(args, const std::vector<UInt16> *);
const std::vector<uint16_t> *list = va_arg(args, const std::vector<uint16_t> *);
writeVectorInt(list, buffer);
break;
}
@ -458,13 +458,13 @@ uint8_t ProtocolUtil::read1ByteInt(deskflow::IStream *stream)
return Result;
}
UInt16 ProtocolUtil::read2BytesInt(deskflow::IStream *stream)
uint16_t ProtocolUtil::read2BytesInt(deskflow::IStream *stream)
{
const UInt32 BufferSize = 2;
std::array<uint8_t, BufferSize> buffer = {};
read(stream, buffer.data(), BufferSize);
UInt16 Result = static_cast<UInt16>((static_cast<UInt16>(buffer[0]) << 8) | static_cast<UInt16>(buffer[1]));
uint16_t Result = static_cast<uint16_t>((static_cast<uint16_t>(buffer[0]) << 8) | static_cast<uint16_t>(buffer[1]));
LOG((CLOG_DEBUG2 "readf: read 2 byte integer: %d (0x%x)", Result, Result));
return Result;
@ -492,7 +492,7 @@ void ProtocolUtil::readVector1ByteInt(deskflow::IStream *stream, std::vector<uin
}
}
void ProtocolUtil::readVector2BytesInt(deskflow::IStream *stream, std::vector<UInt16> &destination)
void ProtocolUtil::readVector2BytesInt(deskflow::IStream *stream, std::vector<uint16_t> &destination)
{
UInt32 size = readVectorSize(stream);
for (UInt32 i = 0; i < size; ++i) {

View File

@ -49,7 +49,7 @@ public:
- \%2i -- converts integer argument to 2 byte integer in NBO
- \%4i -- converts integer argument to 4 byte integer in NBO
- \%1I -- converts std::vector<uint8_t>* to 1 byte integers
- \%2I -- converts std::vector<UInt16>* to 2 byte integers in NBO
- \%2I -- converts std::vector<uint16_t>* to 2 byte integers in NBO
- \%4I -- converts std::vector<UInt32>* to 4 byte integers in NBO
- \%s -- converts std::string* to stream of bytes
- \%S -- converts integer N and const uint8_t* to stream of N bytes
@ -68,7 +68,7 @@ public:
- \%2i -- reads an NBO 2 byte integer; arg is SInt32* or UInt32*
- \%4i -- reads an NBO 4 byte integer; arg is SInt32* or UInt32*
- \%1I -- reads 1 byte integers; arg is std::vector<uint8_t>*
- \%2I -- reads NBO 2 byte integers; arg is std::vector<UInt16>*
- \%2I -- reads NBO 2 byte integers; arg is std::vector<uint16_t>*
- \%4I -- reads NBO 4 byte integers; arg is std::vector<UInt32>*
- \%s -- reads bytes; argument must be a std::string*, \b not a char*
*/
@ -87,14 +87,14 @@ private:
* @brief Handles 1,2, or 4 byte Integers
*/
static uint8_t read1ByteInt(deskflow::IStream *stream);
static UInt16 read2BytesInt(deskflow::IStream *stream);
static uint16_t read2BytesInt(deskflow::IStream *stream);
static UInt32 read4BytesInt(deskflow::IStream *stream);
/**
* @brief Handles a Vector of integers
*/
static void readVector1ByteInt(deskflow::IStream *, std::vector<uint8_t> &);
static void readVector2BytesInt(deskflow::IStream *, std::vector<UInt16> &);
static void readVector2BytesInt(deskflow::IStream *, std::vector<uint16_t> &);
static void readVector4BytesInt(deskflow::IStream *, std::vector<UInt32> &);
static UInt32 readVectorSize(deskflow::IStream *stream);

View File

@ -41,9 +41,9 @@ invalid key; platforms that use 0 as a physical key identifier
will have to remap that value to some arbitrary unused id.
*/
#if __APPLE__
typedef UInt16 KeyButton;
typedef uint16_t KeyButton;
#else
using KeyButton = UInt16;
using KeyButton = uint16_t;
#endif
//! Modifier key mask

View File

@ -38,7 +38,7 @@ static const int16_t kProtocolMajorVersion = 1;
static const int16_t kProtocolMinorVersion = 8;
// default contact port number
static const UInt16 kDefaultPort = 24800;
static const uint16_t kDefaultPort = 24800;
// maximum total length for greeting returned by client
static const UInt32 kMaxHelloLength = 1024;

View File

@ -195,17 +195,17 @@ void IpcLogOutputter::sendBuffer()
m_sending = false;
}
void IpcLogOutputter::bufferMaxSize(UInt16 bufferMaxSize)
void IpcLogOutputter::bufferMaxSize(uint16_t bufferMaxSize)
{
m_bufferMaxSize = bufferMaxSize;
}
UInt16 IpcLogOutputter::bufferMaxSize() const
uint16_t IpcLogOutputter::bufferMaxSize() const
{
return m_bufferMaxSize;
}
void IpcLogOutputter::bufferRateLimit(UInt16 writeLimit, double timeLimit)
void IpcLogOutputter::bufferRateLimit(uint16_t writeLimit, double timeLimit)
{
m_bufferRateWriteLimit = writeLimit;
m_bufferRateTimeLimit = timeLimit;

View File

@ -62,13 +62,13 @@ public:
Set the maximum size of the buffer to protect memory
from runaway logging.
*/
void bufferMaxSize(UInt16 bufferMaxSize);
void bufferMaxSize(uint16_t bufferMaxSize);
//! Set the rate limit
/*!
Set the maximum number of \p writeRate for every \p timeRate in seconds.
*/
void bufferRateLimit(UInt16 writeLimit, double timeLimit);
void bufferRateLimit(uint16_t writeLimit, double timeLimit);
//! Send the buffer
/*!
@ -86,7 +86,7 @@ public:
/*!
Returns the maximum size of the buffer.
*/
UInt16 bufferMaxSize() const;
uint16_t bufferMaxSize() const;
//@}
@ -110,10 +110,10 @@ private:
ArchMutex m_notifyMutex;
bool m_bufferWaiting;
IArchMultithread::ThreadID m_bufferThreadId;
UInt16 m_bufferMaxSize;
UInt16 m_bufferRateWriteLimit;
uint16_t m_bufferMaxSize;
uint16_t m_bufferRateWriteLimit;
double m_bufferRateTimeLimit;
UInt16 m_bufferWriteCount;
uint16_t m_bufferWriteCount;
double m_bufferRateStart;
IpcClientType m_clientType;
ArchMutex m_runningMutex;

View File

@ -23,10 +23,10 @@
struct CBMPHeader
{
public:
UInt16 type;
uint16_t type;
UInt32 size;
UInt16 reserved1;
UInt16 reserved2;
uint16_t reserved1;
uint16_t reserved2;
UInt32 offset;
};
@ -43,7 +43,7 @@ static void toLE(uint8_t *&dst, char src)
dst += 1;
}
static void toLE(uint8_t *&dst, UInt16 src)
static void toLE(uint8_t *&dst, uint16_t src)
{
dst[0] = static_cast<uint8_t>(src & 0xffu);
dst[1] = static_cast<uint8_t>((src >> 8) & 0xffu);
@ -89,8 +89,8 @@ std::string OSXClipboardBMPConverter::fromIClipboard(const std::string &bmp) con
toLE(dst, 'B');
toLE(dst, 'M');
toLE(dst, static_cast<UInt32>(14 + bmp.size()));
toLE(dst, static_cast<UInt16>(0));
toLE(dst, static_cast<UInt16>(0));
toLE(dst, static_cast<uint16_t>(0));
toLE(dst, static_cast<uint16_t>(0));
toLE(dst, static_cast<UInt32>(14 + 40));
return std::string(reinterpret_cast<const char *>(header), 14) + bmp;
}

View File

@ -330,7 +330,7 @@ KeyButton OSXKeyState::mapKeyFromEvent(KeyIDs &ids, KeyModifierMask *maskOut, CG
//}
// choose action
UInt16 action;
uint16_t action;
if (eventKind == kCGEventKeyDown) {
action = kUCKeyActionDown;
} else if (CGEventGetIntegerValueField(event, kCGKeyboardEventAutorepeat) == 1) {

View File

@ -134,7 +134,7 @@ private:
// mouse button handler. pressed is true if this is a mousedown
// event, false if it is a mouseup event. macButton is the index
// of the button pressed using the mac button mapping.
bool onMouseButton(bool pressed, UInt16 macButton);
bool onMouseButton(bool pressed, uint16_t macButton);
bool onMouseWheel(SInt32 xDelta, SInt32 yDelta) const;
void constructMouseButtonEventMap();
@ -150,10 +150,10 @@ private:
void hideCursor();
// map deskflow mouse button to mac buttons
ButtonID mapDeskflowButtonToMac(UInt16) const;
ButtonID mapDeskflowButtonToMac(uint16_t) const;
// map mac mouse button to deskflow buttons
ButtonID mapMacButtonToDeskflow(UInt16) const;
ButtonID mapMacButtonToDeskflow(uint16_t) const;
// map mac scroll wheel value to a deskflow scroll wheel value
SInt32 mapScrollWheelToDeskflow(SInt32) const;
@ -272,7 +272,7 @@ private:
Evil, and this should be moved to a place where it need not
be mutable as soon as possible. */
mutable MouseButtonState m_buttonState;
using MouseButtonEventMapType = std::map<UInt16, CGEventType>;
using MouseButtonEventMapType = std::map<uint16_t, CGEventType>;
std::vector<MouseButtonEventMapType> MouseButtonEventMap;
bool m_cursorHidden;

View File

@ -429,9 +429,9 @@ void OSXScreen::constructMouseButtonEventMap()
{kCGEventOtherMouseUp, kCGEventOtherMouseDragged, kCGEventOtherMouseDown}
};
for (UInt16 button = 0; button < NumButtonIDs; button++) {
for (uint16_t button = 0; button < NumButtonIDs; button++) {
MouseButtonEventMapType new_map;
for (UInt16 state = (UInt32)kMouseButtonUp; state < kMouseButtonStateMax; state++) {
for (uint16_t state = (UInt32)kMouseButtonUp; state < kMouseButtonStateMax; state++) {
CGEventType curEvent = source[button][state];
new_map[state] = curEvent;
}
@ -1073,7 +1073,7 @@ bool OSXScreen::onMouseMove(CGFloat mx, CGFloat my)
return true;
}
bool OSXScreen::onMouseButton(bool pressed, UInt16 macButton)
bool OSXScreen::onMouseButton(bool pressed, uint16_t macButton)
{
// Buttons 2 and 3 are inverted on the mac
ButtonID button = mapMacButtonToDeskflow(macButton);
@ -1312,7 +1312,7 @@ bool OSXScreen::onHotKey(EventRef event) const
return true;
}
ButtonID OSXScreen::mapDeskflowButtonToMac(UInt16 button) const
ButtonID OSXScreen::mapDeskflowButtonToMac(uint16_t button) const
{
switch (button) {
case 1:
@ -1326,7 +1326,7 @@ ButtonID OSXScreen::mapDeskflowButtonToMac(UInt16 button) const
return static_cast<ButtonID>(button);
}
ButtonID OSXScreen::mapMacButtonToDeskflow(UInt16 macButton) const
ButtonID OSXScreen::mapMacButtonToDeskflow(uint16_t macButton) const
{
switch (macButton) {
case 1:

View File

@ -147,14 +147,14 @@ KeyID OSXUchrKeyResource::getKey(UInt32 table, UInt32 button) const
return keys.front();
}
bool OSXUchrKeyResource::getDeadKey(KeySequence &keys, UInt16 index) const
bool OSXUchrKeyResource::getDeadKey(KeySequence &keys, uint16_t index) const
{
if (m_sri == NULL || index >= m_sri->keyStateRecordCount) {
// XXX -- should we be using some other fallback?
return false;
}
UInt16 state = 0;
uint16_t state = 0;
if (!getKeyRecord(keys, index, state)) {
return false;
}
@ -188,13 +188,13 @@ bool OSXUchrKeyResource::getDeadKey(KeySequence &keys, UInt16 index) const
return true;
}
bool OSXUchrKeyResource::getKeyRecord(KeySequence &keys, UInt16 index, UInt16 &state) const
bool OSXUchrKeyResource::getKeyRecord(KeySequence &keys, uint16_t index, uint16_t &state) const
{
const uint8_t *const base = reinterpret_cast<const uint8_t *>(m_resource);
const UCKeyStateRecord *sr = reinterpret_cast<const UCKeyStateRecord *>(base + m_sri->keyStateRecordOffsets[index]);
const UCKeyStateEntryTerminal *kset = reinterpret_cast<const UCKeyStateEntryTerminal *>(sr->stateEntryData);
UInt16 nextState = 0;
uint16_t nextState = 0;
bool found = false;
if (state == 0) {
found = true;
@ -206,7 +206,7 @@ bool OSXUchrKeyResource::getKeyRecord(KeySequence &keys, UInt16 index, UInt16 &s
// we have a next entry
switch (sr->stateEntryFormat) {
case kUCKeyStateEntryTerminalFormat:
for (UInt16 j = 0; j < sr->stateEntryCount; ++j) {
for (uint16_t j = 0; j < sr->stateEntryCount; ++j) {
if (kset[j].curState == state) {
if (!addSequence(keys, kset[j].charData)) {
return false;
@ -249,7 +249,7 @@ bool OSXUchrKeyResource::getKeyRecord(KeySequence &keys, UInt16 index, UInt16 &s
bool OSXUchrKeyResource::addSequence(KeySequence &keys, UCKeyCharSeq c) const
{
if ((c & kUCKeyOutputTestForIndexMask) == kUCKeyOutputSequenceIndexMask) {
UInt16 index = (c & kUCKeyOutputGetIndexMask);
uint16_t index = (c & kUCKeyOutputGetIndexMask);
if (index < m_sdi->charSequenceCount &&
m_sdi->charSequenceOffsets[index] != m_sdi->charSequenceOffsets[index + 1]) {
// XXX -- sequences not supported yet

View File

@ -40,8 +40,8 @@ public:
private:
using KeySequence = std::vector<KeyID>;
bool getDeadKey(KeySequence &keys, UInt16 index) const;
bool getKeyRecord(KeySequence &keys, UInt16 index, UInt16 &state) const;
bool getDeadKey(KeySequence &keys, uint16_t index) const;
bool getKeyRecord(KeySequence &keys, uint16_t index, uint16_t &state) const;
bool addSequence(KeySequence &keys, UCKeyCharSeq c) const;
private:
@ -51,5 +51,5 @@ private:
const UCKeySequenceDataIndex *m_sdi;
const UCKeyStateRecordsIndex *m_sri;
const UCKeyStateTerminators *m_st;
UInt16 m_spaceOutput;
uint16_t m_spaceOutput;
};

View File

@ -25,8 +25,8 @@ public:
UInt32 biSize;
SInt32 biWidth;
SInt32 biHeight;
UInt16 biPlanes;
UInt16 biBitCount;
uint16_t biPlanes;
uint16_t biBitCount;
UInt32 biCompression;
UInt32 biSizeImage;
SInt32 biXPelsPerMeter;
@ -37,7 +37,7 @@ public:
// BMP is little-endian
static void toLE(uint8_t *&dst, UInt16 src)
static void toLE(uint8_t *&dst, uint16_t src)
{
dst[0] = static_cast<uint8_t>(src & 0xffu);
dst[1] = static_cast<uint8_t>((src >> 8) & 0xffu);
@ -62,9 +62,9 @@ static void toLE(uint8_t *&dst, UInt32 src)
dst += 4;
}
static inline UInt16 fromLEU16(const uint8_t *data)
static inline uint16_t fromLEU16(const uint8_t *data)
{
return static_cast<UInt16>(data[0]) | (static_cast<UInt16>(data[1]) << 8);
return static_cast<uint16_t>(data[0]) | (static_cast<uint16_t>(data[1]) << 8);
}
static inline SInt32 fromLES32(const uint8_t *data)
@ -152,8 +152,8 @@ std::string XWindowsClipboardAnyBitmapConverter::toIClipboard(const std::string
toLE(dst, static_cast<UInt32>(40));
toLE(dst, static_cast<SInt32>(w));
toLE(dst, static_cast<SInt32>(h));
toLE(dst, static_cast<UInt16>(1));
toLE(dst, static_cast<UInt16>(depth));
toLE(dst, static_cast<uint16_t>(1));
toLE(dst, static_cast<uint16_t>(depth));
toLE(dst, static_cast<UInt32>(0)); // BI_RGB
toLE(dst, static_cast<UInt32>(image.size()));
toLE(dst, static_cast<SInt32>(2834)); // 72 dpi

View File

@ -22,10 +22,10 @@
struct CBMPHeader
{
public:
UInt16 type;
uint16_t type;
UInt32 size;
UInt16 reserved1;
UInt16 reserved2;
uint16_t reserved1;
uint16_t reserved2;
UInt32 offset;
};
@ -42,7 +42,7 @@ static void toLE(uint8_t *&dst, char src)
dst += 1;
}
static void toLE(uint8_t *&dst, UInt16 src)
static void toLE(uint8_t *&dst, uint16_t src)
{
dst[0] = static_cast<uint8_t>(src & 0xffu);
dst[1] = static_cast<uint8_t>((src >> 8) & 0xffu);
@ -96,8 +96,8 @@ std::string XWindowsClipboardBMPConverter::fromIClipboard(const std::string &bmp
toLE(dst, 'B');
toLE(dst, 'M');
toLE(dst, static_cast<UInt32>(14 + bmp.size()));
toLE(dst, static_cast<UInt16>(0));
toLE(dst, static_cast<UInt16>(0));
toLE(dst, static_cast<uint16_t>(0));
toLE(dst, static_cast<uint16_t>(0));
toLE(dst, static_cast<UInt32>(14 + 40));
return std::string(reinterpret_cast<const char *>(header), 14) + bmp;
}

View File

@ -55,7 +55,7 @@ using ::testing::Return;
#define TEST_HOST "localhost"
const size_t kMockDataSize = 1024 * 1024 * 10; // 10MB
const UInt16 kMockDataChunkIncrement = 1024; // 1KB
const uint16_t kMockDataChunkIncrement = 1024; // 1KB
const char *kMockFilename = "tmp/test/NetworkTests.mock";
const size_t kMockFileSize = 1024 * 1024 * 10; // 10MB

View File

@ -44,7 +44,7 @@ MATCHER_P(EqVoidPointeeInt8, expected, "")
MATCHER_P(EqVoidPointeeInt16, expected, "")
{
const UInt16 Actual16 = (*static_cast<const UInt16 *>(arg));
const uint16_t Actual16 = (*static_cast<const uint16_t *>(arg));
return (expected == (Actual16 >> 8));
}
@ -77,7 +77,7 @@ MATCHER_P(EqVoidVectorInt1byte, expected, "")
MATCHER_P(EqVoidVectorInt2bytes, expected, "")
{
bool Result = true;
const UInt16 *Actual = (static_cast<const UInt16 *>(arg)) + 2;
const uint16_t *Actual = (static_cast<const uint16_t *>(arg)) + 2;
const size_t Size = *(Actual - 1) >> 8;
if (Size == expected.size()) {
@ -139,7 +139,7 @@ class ProtocolUtilTests : public ::testing::Test
public:
MockStream stream;
uint8_t ActualInt8 = 0;
UInt16 ActualInt16 = 0;
uint16_t ActualInt16 = 0;
UInt32 ActualInt32 = 0;
std::string ActualString;
};
@ -253,11 +253,11 @@ class ReadfIntVectorTestFixture : public ReadfIntTestFixture {};
TEST_P(ReadfIntVectorTestFixture, readf_int_vector) {
std::vector<uint8_t> Actual1Byte = {};
std::vector<UInt16> Actual2Bytes = {};
std::vector<uint16_t> Actual2Bytes = {};
std::vector<UInt32> Actual4Bytes = {};
const std::vector<uint8_t> Expected1Byte = {10, 10};
const std::vector<UInt16> Expected2Bytes = {10, 10};
const std::vector<uint16_t> Expected2Bytes = {10, 10};
const std::vector<UInt32> Expected4Bytes = {10, 10};
std::array<uint8_t, 4> StreamVectorSize{{0, 0, 0, 2}};
@ -298,7 +298,7 @@ INSTANTIATE_TEST_SUITE_P(ReadfIntVectorTests, ReadfIntVectorTestFixture,
class ReadfIntAndStringTest : public ReadfIntTestFixture {
public:
uint8_t ActualInt8 = 0;
UInt16 ActualInt16 = 0;
uint16_t ActualInt16 = 0;
UInt32 ActualInt32 = 32;
std::string ActualString;
};
@ -436,7 +436,7 @@ class WriteIntTest
public:
MockStream stream;
uint8_t Expected1Byte = 5;
UInt16 Expected2Bytes = 10;
uint16_t Expected2Bytes = 10;
UInt32 Expected4Bytes = 15;
};
@ -471,7 +471,7 @@ class WriteIntVectorTest
public:
MockStream stream;
const std::vector<uint8_t> Expected1Byte = {10, 20, 30};
const std::vector<UInt16> Expected2Byte = {40, 50, 60};
const std::vector<uint16_t> Expected2Byte = {40, 50, 60};
const std::vector<UInt32> Expected4Byte = {70, 80, 90};
};