From 9b24232f2eb246d194ed6ecd45121c2c3ab1f853 Mon Sep 17 00:00:00 2001 From: Zero Fanker Date: Sat, 2 Nov 2024 18:11:58 -0400 Subject: [PATCH] Fix/overlay refactor mismatch (#101) * fixed overlay encoding result differs from original . * some type adjustments to silence compile warning, UT case added . * escape Chinese comments . * added compile dependency of UT on MissionPackLib . --- 3rdParty/xcc/misc/shp_decode.cpp | 82 +++++++------ 3rdParty/xcc/misc/shp_decode.h | 4 +- MissionEditor.sln | 3 + MissionEditor/MapData.cpp | 42 +++---- MissionEditor/MapData.h | 7 +- MissionEditor/PropertySheets/Debug.props | 1 + .../PropertySheets/Distribution.props | 6 +- MissionEditor/PropertySheets/Release.props | 1 + MissionEditorPackLib/MissionEditorPackLib.cpp | 16 +-- MissionEditorPackLib/MissionEditorPackLib.h | 6 +- UnitTest/Serde_Test.cpp | 112 ++++++++++++++++++ UnitTest/UnitTest.vcxproj | 7 +- UnitTest/UnitTest.vcxproj.filters | 3 + 13 files changed, 214 insertions(+), 76 deletions(-) create mode 100644 UnitTest/Serde_Test.cpp diff --git a/3rdParty/xcc/misc/shp_decode.cpp b/3rdParty/xcc/misc/shp_decode.cpp index f001226..7ba1956 100644 --- a/3rdParty/xcc/misc/shp_decode.cpp +++ b/3rdParty/xcc/misc/shp_decode.cpp @@ -198,32 +198,32 @@ static void write_v80(byte v, int count, byte*& d) } } -void get_same(const byte* s, const byte* r, const byte* s_end, const byte*& p, int& cb_p) +void get_same(const byte* src_start, const byte* src_pos, const byte* src_end, const byte*& p_same_content_beg, int& same_content_len) { // init - p = nullptr; - cb_p = 0; + p_same_content_beg = nullptr; + same_content_len = 0; - while (s++ < s_end) { + while (src_start++ < src_end) { // reset round int counted = 0; // early safe check - if (s >= r) { + if (src_start >= src_pos) { break; } - while (s[counted] == r[counted]) { + while (src_start[counted] == src_pos[counted]) { // match begins, early safe check - if (s + counted >= s_end) { + if (src_start + counted >= src_end) { break; } - if (r + counted >= s_end) { + if (src_pos + counted >= src_end) { break; } counted++; } - if (counted > cb_p) { - cb_p = counted; - p = s; + if (counted >= same_content_len) { + same_content_len = counted; + p_same_content_beg = src_start; } } } @@ -274,41 +274,47 @@ static void flush_c1(byte*& w, const byte* r, const byte*& copy_from) } } -int encode80(const byte* s, byte* d, int cb_s) +int encode80(const byte* src, byte* dst, const size_t src_len) { + //using std::cout; + //using std::endl; // full compression - const byte* s_end = s + cb_s; - const byte* r = s; - byte* w = d; + const byte* src_end = src + src_len; + const byte* src_pos = src; + byte* w = dst; const byte* copy_from = NULL; - while (r < s_end) { - const byte* p; - int cb_p; - int t = get_run_length(r, s_end); - get_same(s, r, s_end, p, cb_p); - if (t < cb_p && cb_p > 2) { - flush_c1(w, r, copy_from); - if (cb_p - 3 < 8 && r - p < 0x1000) - write80_c0(w, cb_p, r - p); - else if (cb_p - 3 < 0x3e) - write80_c2(w, cb_p, p - s); + while (src_pos < src_end) { + const byte* p_block_begin; + int block_len; + int same_data_len = get_run_length(src_pos, src_end); + get_same(src, src_pos, src_end, p_block_begin, block_len); + + //cout << "p_block_begin:" << std::showbase << std::hex << (std::uintptr_t)p_block_begin << ", block_len:" << block_len << endl; + if (same_data_len < block_len && block_len > 2) { + flush_c1(w, src_pos, copy_from); + if (block_len - 3 < 8 && src_pos - p_block_begin < 0x1000) + write80_c0(w, block_len, src_pos - p_block_begin); + else if (block_len - 3 < 0x3e) + write80_c2(w, block_len, p_block_begin - src); else - write80_c4(w, cb_p, p - s); - r += cb_p; - } else { - if (t < 3) { + write80_c4(w, block_len, p_block_begin - src); + src_pos += block_len; + } + else { + if (same_data_len < 3) { if (!copy_from) - copy_from = r; - } else { - flush_c1(w, r, copy_from); - write80_c3(w, t, *r); + copy_from = src_pos; } - r += t; + else { + flush_c1(w, src_pos, copy_from); + write80_c3(w, same_data_len, *src_pos); + } + src_pos += same_data_len; } } - flush_c1(w, r, copy_from); + flush_c1(w, src_pos, copy_from); write80_c1(w, 0, NULL); - return w - d; + return w - dst; } int decode80(const byte source[], byte dest[]) @@ -683,7 +689,7 @@ int encode5(const byte* s, byte* d, int cb_s, int format) return w - d; } -int decode5(const byte* s, byte* d, int cb_s, int format) +int decode5(const byte* s, byte* d, const size_t cb_s, int format) { const byte* r = s; const byte* r_end = s + cb_s; diff --git a/3rdParty/xcc/misc/shp_decode.h b/3rdParty/xcc/misc/shp_decode.h index e4a4b0a..cca2487 100644 --- a/3rdParty/xcc/misc/shp_decode.h +++ b/3rdParty/xcc/misc/shp_decode.h @@ -21,12 +21,12 @@ #include int decode3(const byte* s, byte* d, int cx, int cy); -int decode5(const byte* s, byte* d, int cb_s, int format); +int decode5(const byte* s, byte* d, const size_t cb_s, int format); int encode5(const byte* s, byte* d, int cb_s, int format); int decode5s(const byte* s, byte* d, int cb_s); int encode5s(const byte* s, byte* d, int cb_s); Cvirtual_binary decode64(data_ref); Cvirtual_binary encode64(data_ref); int decode80(const byte image_in[], byte image_out[]); -int encode80(const byte* s, byte* d, int cb_s); +int encode80(const byte* s, byte* d, const size_t cb_s); int get_run_length(const byte* r, const byte* s_end); diff --git a/MissionEditor.sln b/MissionEditor.sln index 9416224..c62cb4b 100644 --- a/MissionEditor.sln +++ b/MissionEditor.sln @@ -17,6 +17,9 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XCC Library", "3rdParty\xcc\Library\XCC Library.vcxproj", "{5E445578-CB45-4D82-9A1C-FC7D3E8D866A}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTest", "UnitTest\UnitTest.vcxproj", "{75E18879-7564-4A2C-8C00-393A5A17171F}" + ProjectSection(ProjectDependencies) = postProject + {DEB40EF0-E215-4C2F-A0AD-3742E2E01A8C} = {DEB40EF0-E215-4C2F-A0AD-3742E2E01A8C} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CncVxlRenderText", "3rdParty\CncVxlRender\CncVxlRenderText.vcxproj", "{BAE32EF7-4F88-40D8-8984-A2EAF14C0A63}" EndProject diff --git a/MissionEditor/MapData.cpp b/MissionEditor/MapData.cpp index 85ffffc..ad12da7 100644 --- a/MissionEditor/MapData.cpp +++ b/MissionEditor/MapData.cpp @@ -898,8 +898,8 @@ void CMapData::Unpack() ovrl += val; } - //BYTE values[262144]; - const size_t VALUESIZE = 262144; + //BYTE values[overlayDataCapacity]; + const size_t VALUESIZE = overlayDataCapacity; std::vector values(VALUESIZE, 0xFF); int hexlen; @@ -1068,7 +1068,7 @@ void CMapData::Pack(BOOL bCreatePreview, BOOL bCompression) } - BYTE* values = new(BYTE[262144]); + BYTE* values = new(BYTE[overlayDataCapacity]); BYTE* hexpacked = NULL; // must be freed! @@ -1079,11 +1079,11 @@ void CMapData::Pack(BOOL bCreatePreview, BOOL bCompression) errstream << "Packing overlay" << endl; errstream.flush(); - for (i = 0; i < 262144; i++) { + for (i = 0; i < overlayDataCapacity; i++) { values[i] = m_Overlay[i]; } - int hexpackedLen = FSunPackLib::EncodeF80(values, 262144, 32, &hexpacked); + int hexpackedLen = FSunPackLib::EncodeF80(values, overlayDataCapacity, 32, &hexpacked); base64 = FSunPackLib::EncodeBase64(hexpacked, hexpackedLen); @@ -1091,6 +1091,9 @@ void CMapData::Pack(BOOL bCreatePreview, BOOL bCompression) i = 0; pos = 0; + + auto const b64StrLen = strlen(reinterpret_cast(base64)); + while (TRUE) { i++; char cLine[50]; @@ -1098,8 +1101,8 @@ void CMapData::Pack(BOOL bCreatePreview, BOOL bCompression) char str[200]; memset(str, 0, 200); WORD cpysize = 70; - if (pos + cpysize > strlen((char*)base64)) { - cpysize = strlen((char*)base64) - pos; + if (pos + cpysize > b64StrLen) { + cpysize = b64StrLen - pos; } memcpy(str, &base64[pos], cpysize); if (strlen(str) > 0) { @@ -1121,16 +1124,14 @@ void CMapData::Pack(BOOL bCreatePreview, BOOL bCompression) errstream << "Pack overlaydata" << endl; errstream.flush(); - for (i = 0; i < 262144; i++) { - values[i] = m_OverlayData[i]; - } + memcpy(values, m_OverlayData, overlayDataCapacity); hexpacked = NULL; errstream << "Format80" << endl; errstream.flush(); - hexpackedLen = FSunPackLib::EncodeF80(values, 262144, 32, &hexpacked); + hexpackedLen = FSunPackLib::EncodeF80(values, overlayDataCapacity, 32, &hexpacked); errstream << "Base64" << endl; @@ -1148,15 +1149,16 @@ void CMapData::Pack(BOOL bCreatePreview, BOOL bCompression) i++; char cLine[50]; itoa(i, cLine, 10); - char str[200]; - memset(str, 0, 200); + WORD cpysize = 70; if (pos + cpysize > strlen((char*)base64)) { cpysize = strlen((char*)base64) - pos; } - memcpy(str, &base64[pos], cpysize); - if (strlen(str) > 0) { - m_mapfile.SetString("OverlayDataPack", cLine, str); + + CString str(reinterpret_cast(base64 + pos), cpysize); + + if (str.GetLength() > 0) { + m_mapfile.SetString("OverlayDataPack", cLine, std::move(str)); } if (cpysize < 70) { break; @@ -1299,13 +1301,13 @@ void CMapData::Pack(BOOL bCreatePreview, BOOL bCompression) void CMapData::ClearOverlayData() { - memset(m_OverlayData, 0x0, 262144); + memset(m_OverlayData, 0x0, overlayDataCapacity); // Pack(); } void CMapData::ClearOverlay() { - memset(m_Overlay, 0xFF, 262144); + memset(m_Overlay, 0xFF, overlayDataCapacity); // Pack(); } @@ -1314,7 +1316,7 @@ void CMapData::SetOverlayAt(DWORD dwPos, BYTE bValue) int y = dwPos / m_IsoSize; int x = dwPos % m_IsoSize; - if (y + x * 512 > 262144 || dwPos > m_IsoSize * m_IsoSize) return; + if (y + x * 512 > overlayDataCapacity || dwPos > m_IsoSize * m_IsoSize) return; BYTE& ovrl = m_Overlay[y + x * 512]; BYTE& ovrld = m_OverlayData[y + x * 512]; @@ -1360,7 +1362,7 @@ void CMapData::SetOverlayDataAt(DWORD dwPos, BYTE bValue) int y = dwPos / m_IsoSize; int x = dwPos % m_IsoSize; - if (y + x * 512 > 262144 || dwPos > m_IsoSize * m_IsoSize) return; + if (y + x * 512 > overlayDataCapacity || dwPos > m_IsoSize * m_IsoSize) return; BYTE& ovrl = m_Overlay[y + x * 512]; BYTE& ovrld = m_OverlayData[y + x * 512]; diff --git a/MissionEditor/MapData.h b/MissionEditor/MapData.h index 4eaa235..1d76ed3 100644 --- a/MissionEditor/MapData.h +++ b/MissionEditor/MapData.h @@ -484,8 +484,11 @@ private: #ifdef SMUDGE_SUPP map smudgeid; #endif - BYTE m_Overlay[262144]; // overlay byte values (extracted) - BYTE m_OverlayData[262144]; // overlay data byte values (extracted) + + static constexpr size_t overlayDataCapacity = 262144; + + BYTE m_Overlay[overlayDataCapacity]; // overlay byte values (extracted) + BYTE m_OverlayData[overlayDataCapacity]; // overlay data byte values (extracted) BYTE* m_mfd; // map field data buffer DWORD dwIsoMapSize; CIniFile m_mapfile; diff --git a/MissionEditor/PropertySheets/Debug.props b/MissionEditor/PropertySheets/Debug.props index a0fb20e..3dd4c0d 100644 --- a/MissionEditor/PropertySheets/Debug.props +++ b/MissionEditor/PropertySheets/Debug.props @@ -7,6 +7,7 @@ $(XccDir)\vcpkg_installed\$(Platform)-windows\$(Platform)-windows $(XccVcpkgDirTriplet)\debug $(SolutionDir)$(Platform)\Debug + Debug diff --git a/MissionEditor/PropertySheets/Distribution.props b/MissionEditor/PropertySheets/Distribution.props index 1d272ee..6c20c12 100644 --- a/MissionEditor/PropertySheets/Distribution.props +++ b/MissionEditor/PropertySheets/Distribution.props @@ -5,7 +5,8 @@ $(MSBuildThisFileDirectory)\..\..\dist\$(DistributionName) - $(DistributionFolder)\ + $(DistributionFolder)\ + $(MSBuildThisFileDirectory)\..\..\$(Platform)\$(SchemaType) @@ -30,6 +31,9 @@ + + + diff --git a/MissionEditor/PropertySheets/Release.props b/MissionEditor/PropertySheets/Release.props index f8f4f0f..b8a68b0 100644 --- a/MissionEditor/PropertySheets/Release.props +++ b/MissionEditor/PropertySheets/Release.props @@ -7,6 +7,7 @@ $(XccDir)\vcpkg_installed\$(Platform)-windows\$(Platform)-windows $(XccVcpkgDirTriplet) $(SolutionDir)$(Platform)\Release + Release diff --git a/MissionEditorPackLib/MissionEditorPackLib.cpp b/MissionEditorPackLib/MissionEditorPackLib.cpp index d1f06b2..7065ea8 100644 --- a/MissionEditorPackLib/MissionEditorPackLib.cpp +++ b/MissionEditorPackLib/MissionEditorPackLib.cpp @@ -171,7 +171,7 @@ namespace FSunPackLib extern "C" int last_succeeded_operation = 0; - BYTE* EncodeBase64(BYTE* sp, UINT len) + BYTE* EncodeBase64(BYTE* sp, const size_t len) { auto encoded = encode64(data_ref(sp, std::size_t(len))); // for now make a copy, we might refactor this @@ -189,13 +189,13 @@ namespace FSunPackLib - INT EncodeF80(BYTE* sp, UINT len, UINT nSections, BYTE** dest) + size_t EncodeF80(BYTE* sp, size_t len, UINT nSections, BYTE** dest) { *dest = new(BYTE[len * 4]); // as large as sp, to make sure it works BYTE* data = *dest; - int length = len / nSections; + auto const length = len / nSections; // each section has this length #ifdef DBG2 @@ -210,11 +210,11 @@ namespace FSunPackLib WriteFile(hOut, out.data(), out.size(), &dw, NULL); #endif - UINT i; - UINT DP = 0; - UINT SP = 0; + size_t i; + size_t DP = 0; + size_t SP = 0; for (i = 0; i < nSections; i++) { - UINT packLen = encode80(&sp[SP], &data[DP + 4], length); //ConvertToF80(&sp[SP], length, &data[DP+4]); + const size_t packLen = encode80(&sp[SP], &data[DP + 4], length); //ConvertToF80(&sp[SP], length, &data[DP+4]); memcpy(&data[DP], &packLen, 3); DP += 3; @@ -255,7 +255,7 @@ namespace FSunPackLib return DP; } - bool DecodeF80(const BYTE* const sp, const UINT SourceLength, std::vector& dp, const std::size_t max_size) + bool DecodeF80(const BYTE* const sp, const size_t SourceLength, std::vector& dp, const std::size_t max_size) { static_assert(4 == sizeof(t_pack_section_header)); diff --git a/MissionEditorPackLib/MissionEditorPackLib.h b/MissionEditorPackLib/MissionEditorPackLib.h index 75ebccb..c80b533 100644 --- a/MissionEditorPackLib/MissionEditorPackLib.h +++ b/MissionEditorPackLib/MissionEditorPackLib.h @@ -116,7 +116,7 @@ namespace FSunPackLib len - length of hex data Returns a poINTer to the base64 data. Caller must free this memory. */ - BYTE* EncodeBase64(BYTE* sp, UINT len); + BYTE* EncodeBase64(BYTE* sp, const size_t len); /* Converts Base64 data to hex data. sp - source poINTer @@ -135,7 +135,7 @@ namespace FSunPackLib dest - poINTer to dest poINTer. Function allocates memory, caller must free this memory. Returns the length of the packed data. */ - INT EncodeF80(BYTE* sp, UINT len, UINT nSections, BYTE** dest); + size_t EncodeF80(BYTE* sp, size_t len, UINT nSections, BYTE** dest); /* Extracts a simple format 80 pack like the Overlay & OverlayData-Pack @@ -146,7 +146,7 @@ namespace FSunPackLib dp - dest buffer max_size - maximum allowed destination size */ - bool DecodeF80(const BYTE* sp, UINT SourceLength, std::vector& dp, std::size_t max_size); + bool DecodeF80(const BYTE* sp, size_t SourceLength, std::vector& dp, std::size_t max_size); // IsoMapPack5 /* diff --git a/UnitTest/Serde_Test.cpp b/UnitTest/Serde_Test.cpp new file mode 100644 index 0000000..c535991 --- /dev/null +++ b/UnitTest/Serde_Test.cpp @@ -0,0 +1,112 @@ + +#include "stdafx.h" +#include "MissionEditorPackLib.h" + +using std::cout; +using std::endl; + +#if 0 +void printBin(const std::span input, const char* fileName) +{ + std::ofstream file(fileName); + std::ostringstream line_stream; + size_t count = 0; + + for (const auto& byte : input) { + // to hex + line_stream << std::setw(2) << std::setfill('0') << std::hex << static_cast(byte) << " "; + count++; + + // switch line every 16 bytes + if (count % 16 == 0) { + file << line_stream.str() << std::endl; + line_stream.str(""); // clear stream + line_stream.clear(); // reset stream + } + } + + // for the rest of bytes + if (count % 16 != 0) { + file << line_stream.str() << std::endl; + } + + file.close(); +} +#endif + + +TEST(SerdeTest, OverlayDataPackSerde) +{ + static const char* rawInput[] = { + R"(1=BQAAIP4AIACAeAAAIP5iDACBBP4EAAeBBv76AQCHBwsLCgoIB/75AQCHBgoLCgAKCv/6AW)", + R"(2=cMgQgEAIMKCwj//AFpDP4DAAsGA//3AWkQMgAyA4EE//YBbw7+CQAL//UBaA6BCEP///gB)", + R"(3=ZhLBYgyBCCwGgQv/+gFoEIEH/gQACv+SAW0YgIkAACD+WgAAgQP+DwAAgQj+BQALgQf+6A)", + R"(4=EAhQQEAAIM/gwAAIEH/+4BawCBBv4DAACBBf/8AV4ChAgGAgnMXgSECggHBP/qAXEEzG4G)", + R"(5=gwQHBxQU/ukBAIMHAAr/6QFwBNJFCIIKCv/9AV0KhAQICgj+/gEAggYGzVoA/usLAMtcAv)", + R"(6=7zAQDKXQT+mQEAgFIAACD+VAAAgQT+BAAAggIJ/vkBAIEF/vsBAIEC/gMACv/6AVoA/v8F)", + R"(7=AIMGCgz+/QEAgwUAAf//AVAM/v4BAP8AAk0QhAMKCgj+DwQAwlQA/5sHUg6AuwAAIP5UAg)", + R"(8=CEBgoKDP78AQCBBSAD//QBYwAz+P/3AVQEEfQh+IQDCgoJ//wBWAb/+gFdAoEC//QBVwj+)", + R"(9=CAAAgwEABP/mAWYE/gMAB4EG1jYK/+MBagT+AwALggoH0zcO/uMBAIEH/gUAC9M3Ev/qAU)", + R"(10=4SUgH+BwAB//IBRxSCCwooBP4HAAL+EQAAgQL/2QFXAlIAgQvbORT/2QFNEIIECBoB/gMA)", + R"(11=C4EI//YBPBqDAAAIyTQYziIcRgD/pwFPDIAVAQAg/icAAIMGCgzJHQD+BgALgQj+FAAAgQ)", + R"(12=X+BAAAgQT+zwEAhAYJAAPIKQCBCP4GAAuCCgbUPgCEAgkGBv/PAVoAggAAyCkCggQINAKB)", + R"(13=B/4TAACCAwoEF4UGCgoIB//JAVYAAf8B0YIKCMkpAP4FAAfWWwSBB9U5BP+4AXECJ9bJKQ)", + R"(14=L+HgAAgQj+AwAK/8kBWgYR/CIA5isIBiCBAP/KAVkIa9YAB4EC4i4KggQHBAH/ywFaCoED)", + R"(15=CdYIABYKgQHiAQ6CCAjUOgL/tAFwBv4GAAoD+YEG51sEwDQA0jwA/7cBdAqBAxAHggYJRg)", + R"(16=biMxD/yQFaBGf7ggoKwSYE/vEBAFIA//UBLRTCTgT+BQAK//gBKhb+3wUAgAUAACD+ACAA)", + R"(17=gAUAACD+ACAAgL4AACD+KAAAgQT+/QEAhAEGBwf+/gEAhggKCAYEAf76AQCHBwsKBwYHBv)", + R"(18=/6AS8EhAgHBgoCBP73AQCDBAAIBAOCCwv/+AEuCIIEB/4DAASCCAoCAYEG//UBLQSBAxwF)", + R"(19=gQACAIILCP/6AS0ECAEEAYEI//kBLgYSAP4EAAr/+gEzEIMICgoGBYMIAQH/+AEvAIEH/g)", + R"(20=MACv/8ATAQggMHGAQMBv//ATcWgQf/+QEyDoIBCCIAHhH/+AE2EAoG/8kBNxqAGQAAIP4y)", + R"(21=AACGAwAEAAgH/vwBAIQBAQQE/sgdAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAA)", + R"(22=Ag/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAF)", + R"(23=AAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAI)", + R"(24=AFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAgAIAFAAAg/gAg)", + R"(25=AIAFAAAg/gAgAIA=)" + }; + + std::stringstream input; + std::string line; + + for (auto const& line : rawInput) { + size_t pos = std::string_view(line).find('='); + if (pos != std::string::npos) { + input << std::string_view(line).substr(pos + 1); + } + } + + const std::string b64Input = input.str(); + + const size_t VALUESIZE = 262144; + std::vector values(VALUESIZE, 0xFF); + + std::vector hex; + auto const hexlen = FSunPackLib::DecodeBase64(b64Input.data(), hex); + FSunPackLib::DecodeF80(hex.data(), hexlen, values, VALUESIZE); + values.resize(VALUESIZE, 0xFF); // fill rest + + + //printBin(values, "output_x64.txt"); + + auto const encoded = [&values] + { + BYTE* hexpacked = nullptr; + const size_t hexpackedLen = FSunPackLib::EncodeF80(values.data(), values.size(), 32, &hexpacked); + + //printBin({ hexpacked , hexpackedLen }, "encoded_bin_x64.txt"); + + + auto const base64 = FSunPackLib::EncodeBase64(hexpacked, hexpackedLen); + cout << endl + << "encoded:" + << endl + << base64 + << endl; + + delete[] hexpacked; + return std::unique_ptr(base64); + } (); + + ASSERT_EQ(b64Input.size(), strlen(reinterpret_cast(encoded.get()))); + ASSERT_TRUE(0 == memcmp(encoded.get(), b64Input.data(), b64Input.size())); +} \ No newline at end of file diff --git a/UnitTest/UnitTest.vcxproj b/UnitTest/UnitTest.vcxproj index eb87e44..de2fade 100644 --- a/UnitTest/UnitTest.vcxproj +++ b/UnitTest/UnitTest.vcxproj @@ -112,7 +112,8 @@ Console true - $(SolutionDir)googletest\x64\lib\$(Configuration)\*.lib;%(AdditionalDependencies) + $(SolutionDir)googletest\x64\lib\$(Configuration)\*.lib;$(SolutionDir)3rdParty\xcc\vcpkg_installed\x64-windows\x64-windows\lib\*.lib;XCC Library.lib;MissionEditorPackLibd.lib + $(SolutionDir)build\output\$(Configuration)-$(Platform)\lib;$(SolutionDir)build\output\$(Configuration)Minimal-$(Platform)\lib;%(AdditionalLibraryDirectories) @@ -131,7 +132,8 @@ true true true - $(SolutionDir)googletest\x64\lib\$(Configuration)\*.lib;%(AdditionalDependencies) + $(SolutionDir)googletest\x64\lib\$(Configuration)\*.lib;$(SolutionDir)3rdParty\xcc\vcpkg_installed\x64-windows\x64-windows\lib\*.lib;XCC Library.lib;MissionEditorPackLib.lib + $(SolutionDir)build\output\$(Configuration)-$(Platform)\lib;$(SolutionDir)build\output\$(Configuration)Minimal-$(Platform)\lib;%(AdditionalLibraryDirectories) @@ -139,6 +141,7 @@ + diff --git a/UnitTest/UnitTest.vcxproj.filters b/UnitTest/UnitTest.vcxproj.filters index 9de5faa..552a0d6 100644 --- a/UnitTest/UnitTest.vcxproj.filters +++ b/UnitTest/UnitTest.vcxproj.filters @@ -30,6 +30,9 @@ 源文件 + + 源文件 +