backup
This commit is contained in:
@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include <IACore/BinaryReader.hpp>
|
||||
#include <IACore/BinaryStreamReader.hpp>
|
||||
|
||||
#include <IACore/IATest.hpp>
|
||||
|
||||
@ -24,7 +24,7 @@ using namespace IACore;
|
||||
// Test Block Definition
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
IAT_BEGIN_BLOCK(Core, BinaryReader)
|
||||
IAT_BEGIN_BLOCK(Core, BinaryStreamReader)
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// 1. Basic Primitive Reading (UINT8)
|
||||
@ -32,7 +32,7 @@ IAT_BEGIN_BLOCK(Core, BinaryReader)
|
||||
BOOL TestReadUint8()
|
||||
{
|
||||
UINT8 data[] = { 0xAA, 0xBB, 0xCC };
|
||||
BinaryReader reader(data);
|
||||
BinaryStreamReader reader(data);
|
||||
|
||||
// Read First Byte
|
||||
auto val1 = reader.Read<UINT8>();
|
||||
@ -54,7 +54,7 @@ IAT_BEGIN_BLOCK(Core, BinaryReader)
|
||||
{
|
||||
// 0x04030201 in Little Endian memory layout
|
||||
UINT8 data[] = { 0x01, 0x02, 0x03, 0x04 };
|
||||
BinaryReader reader(data);
|
||||
BinaryStreamReader reader(data);
|
||||
|
||||
auto val = reader.Read<UINT32>();
|
||||
IAT_CHECK(val.has_value());
|
||||
@ -79,7 +79,7 @@ IAT_BEGIN_BLOCK(Core, BinaryReader)
|
||||
UINT8 data[4];
|
||||
std::memcpy(data, &pi, 4);
|
||||
|
||||
BinaryReader reader(data);
|
||||
BinaryStreamReader reader(data);
|
||||
auto val = reader.Read<FLOAT32>();
|
||||
|
||||
IAT_CHECK(val.has_value());
|
||||
@ -94,7 +94,7 @@ IAT_BEGIN_BLOCK(Core, BinaryReader)
|
||||
BOOL TestReadString()
|
||||
{
|
||||
const char* raw = "HelloIA";
|
||||
BinaryReader reader(std::span<const UINT8>((const UINT8*)raw, 7));
|
||||
BinaryStreamReader reader(std::span<const UINT8>((const UINT8*)raw, 7));
|
||||
|
||||
// Read "Hello" (5 bytes)
|
||||
auto str = reader.ReadString(5);
|
||||
@ -116,7 +116,7 @@ IAT_BEGIN_BLOCK(Core, BinaryReader)
|
||||
{
|
||||
UINT8 src[] = { 1, 2, 3, 4, 5 };
|
||||
UINT8 dst[3] = { 0 };
|
||||
BinaryReader reader(src);
|
||||
BinaryStreamReader reader(src);
|
||||
|
||||
// Read 3 bytes into dst
|
||||
auto res = reader.Read(dst, 3);
|
||||
@ -139,7 +139,7 @@ IAT_BEGIN_BLOCK(Core, BinaryReader)
|
||||
BOOL TestNavigation()
|
||||
{
|
||||
UINT8 data[10] = { 0 }; // Zero init
|
||||
BinaryReader reader(data);
|
||||
BinaryStreamReader reader(data);
|
||||
|
||||
IAT_CHECK_EQ(reader.Remaining(), (SIZE_T)10);
|
||||
|
||||
@ -168,7 +168,7 @@ IAT_BEGIN_BLOCK(Core, BinaryReader)
|
||||
BOOL TestBoundaryChecks()
|
||||
{
|
||||
UINT8 data[] = { 0x00, 0x00 };
|
||||
BinaryReader reader(data);
|
||||
BinaryStreamReader reader(data);
|
||||
|
||||
// Valid read
|
||||
UNUSED(reader.Read<UINT16>());
|
||||
@ -213,7 +213,7 @@ int main(int argc, char* argv[])
|
||||
// Define runner (StopOnFail=false, Verbose=true)
|
||||
ia::iatest::runner<false, true> testRunner;
|
||||
|
||||
// Run the BinaryReader block
|
||||
// Run the BinaryStreamReader block
|
||||
testRunner.testBlock<Core_BinaryReader>();
|
||||
|
||||
return 0;
|
||||
@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include <IACore/BinaryWriter.hpp>
|
||||
#include <IACore/BinaryStreamWriter.hpp>
|
||||
|
||||
#include <IACore/IATest.hpp>
|
||||
|
||||
@ -24,7 +24,7 @@ using namespace IACore;
|
||||
// Test Block Definition
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
IAT_BEGIN_BLOCK(Core, BinaryWriter)
|
||||
IAT_BEGIN_BLOCK(Core, BinaryStreamWriter)
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// 1. Vector Mode (Dynamic Growth)
|
||||
@ -33,7 +33,7 @@ IAT_BEGIN_BLOCK(Core, BinaryWriter)
|
||||
{
|
||||
std::vector<UINT8> buffer;
|
||||
// Start empty
|
||||
BinaryWriter writer(buffer);
|
||||
BinaryStreamWriter writer(buffer);
|
||||
|
||||
// Write 1 Byte
|
||||
writer.Write<UINT8>(0xAA);
|
||||
@ -62,7 +62,7 @@ IAT_BEGIN_BLOCK(Core, BinaryWriter)
|
||||
{
|
||||
// Vector starts with existing data
|
||||
std::vector<UINT8> buffer = { 0x01, 0x02 };
|
||||
BinaryWriter writer(buffer);
|
||||
BinaryStreamWriter writer(buffer);
|
||||
|
||||
// Should append to end, not overwrite 0x01
|
||||
writer.Write<UINT8>(0x03);
|
||||
@ -83,7 +83,7 @@ IAT_BEGIN_BLOCK(Core, BinaryWriter)
|
||||
// Initialize with zeros
|
||||
std::memset(rawData, 0, 10);
|
||||
|
||||
BinaryWriter writer(rawData); // Implicit conversion to span
|
||||
BinaryStreamWriter writer(rawData); // Implicit conversion to span
|
||||
|
||||
// Write UINT8
|
||||
writer.Write<UINT8>(0xFF);
|
||||
@ -106,7 +106,7 @@ IAT_BEGIN_BLOCK(Core, BinaryWriter)
|
||||
BOOL TestWriteBytes()
|
||||
{
|
||||
std::vector<UINT8> buffer;
|
||||
BinaryWriter writer(buffer);
|
||||
BinaryStreamWriter writer(buffer);
|
||||
|
||||
const char* msg = "IA";
|
||||
writer.WriteBytes((PVOID)msg, 2);
|
||||
@ -126,7 +126,7 @@ IAT_BEGIN_BLOCK(Core, BinaryWriter)
|
||||
BOOL TestRandomAccess()
|
||||
{
|
||||
std::vector<UINT8> buffer;
|
||||
BinaryWriter writer(buffer);
|
||||
BinaryStreamWriter writer(buffer);
|
||||
|
||||
// Fill with placeholders
|
||||
writer.Write<UINT32>(0xFFFFFFFF);
|
||||
@ -152,7 +152,7 @@ IAT_BEGIN_BLOCK(Core, BinaryWriter)
|
||||
BOOL TestWriteFloat()
|
||||
{
|
||||
std::vector<UINT8> buffer;
|
||||
BinaryWriter writer(buffer);
|
||||
BinaryStreamWriter writer(buffer);
|
||||
|
||||
FLOAT32 val = 1.234f;
|
||||
writer.Write<FLOAT32>(val);
|
||||
@ -174,7 +174,7 @@ IAT_BEGIN_BLOCK(Core, BinaryWriter)
|
||||
BOOL TestGetPtr()
|
||||
{
|
||||
std::vector<UINT8> buffer = { 0x10, 0x20, 0x30 };
|
||||
BinaryWriter writer(buffer);
|
||||
BinaryStreamWriter writer(buffer);
|
||||
|
||||
PUINT8 p1 = writer.GetPtrAt(1);
|
||||
IAT_CHECK(p1 != nullptr);
|
||||
@ -216,7 +216,7 @@ int main(int argc, char* argv[])
|
||||
ia::iatest::runner<false, true> testRunner;
|
||||
|
||||
// Run the BinaryReader block
|
||||
testRunner.testBlock<Core_BinaryWriter>();
|
||||
testRunner.testBlock<Core_BinaryStreamWriter>();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -13,21 +13,21 @@ set_target_properties(${TEST_NAME_PREFIX}CCompile PROPERTIES
|
||||
|
||||
target_link_libraries(${TEST_NAME_PREFIX}CCompile PRIVATE IACore)
|
||||
|
||||
# ------------------------------------------------
|
||||
# Unit: BinaryReader
|
||||
# ------------------------------------------------
|
||||
add_executable(${TEST_NAME_PREFIX}BinaryReader "BinaryReader.cpp")
|
||||
target_link_libraries(${TEST_NAME_PREFIX}BinaryReader PRIVATE IACore)
|
||||
target_compile_options(${TEST_NAME_PREFIX}BinaryReader PRIVATE -fexceptions)
|
||||
set_target_properties(${TEST_NAME_PREFIX}BinaryReader PROPERTIES USE_EXCEPTIONS ON)
|
||||
|
||||
# ------------------------------------------------
|
||||
# Unit: BinaryWriter
|
||||
# ------------------------------------------------
|
||||
add_executable(${TEST_NAME_PREFIX}BinaryWriter "BinaryWriter.cpp")
|
||||
target_link_libraries(${TEST_NAME_PREFIX}BinaryWriter PRIVATE IACore)
|
||||
target_compile_options(${TEST_NAME_PREFIX}BinaryWriter PRIVATE -fexceptions)
|
||||
set_target_properties(${TEST_NAME_PREFIX}BinaryWriter PROPERTIES USE_EXCEPTIONS ON)
|
||||
## ------------------------------------------------
|
||||
## Unit: BinaryReader
|
||||
## ------------------------------------------------
|
||||
#add_executable(${TEST_NAME_PREFIX}BinaryReader "BinaryReader.cpp")
|
||||
#target_link_libraries(${TEST_NAME_PREFIX}BinaryReader PRIVATE IACore)
|
||||
#target_compile_options(${TEST_NAME_PREFIX}BinaryReader PRIVATE -fexceptions)
|
||||
#set_target_properties(${TEST_NAME_PREFIX}BinaryReader PROPERTIES USE_EXCEPTIONS ON)
|
||||
#
|
||||
## ------------------------------------------------
|
||||
## Unit: BinaryWriter
|
||||
## ------------------------------------------------
|
||||
#add_executable(${TEST_NAME_PREFIX}BinaryWriter "BinaryWriter.cpp")
|
||||
#target_link_libraries(${TEST_NAME_PREFIX}BinaryWriter PRIVATE IACore)
|
||||
#target_compile_options(${TEST_NAME_PREFIX}BinaryWriter PRIVATE -fexceptions)
|
||||
#set_target_properties(${TEST_NAME_PREFIX}BinaryWriter PROPERTIES USE_EXCEPTIONS ON)
|
||||
|
||||
# ------------------------------------------------
|
||||
# Unit: Environment
|
||||
|
||||
Reference in New Issue
Block a user