M Starch b76d8c9a0c
Update/types refactor as constants (#1623)
* lestarch: adding logical types implementation into Linux/StandardTypes.hpp

* lestarch: removing VxWorks StandardTypes from repository

* updated fprime types for correct compilation with vxworks and baremetal

* lestarch: refactoring types and configuration header w.r.t type design

* lestarch: replacing usages of AssertArg with FwAssertArgType

* lestarch: missspelled configuration

* lestarch: minor compilation fixes

* lestarch: renaming StandardTypes.hpp -> PlatformTypes.hpp

* lestarch: updating PRI tokens

* lestarch: replacing BasicTypes.hpp includes with FpConfig.hpp

* lestarch: UT and compilation fixes for types refactor

* lestarch: sp

* lestarch: fixing RPI issues in PassiveConsoleTextLogger

* lestarch: converting RPI build to debug

* lestarch: removing duplicate config imports

* lestarch: fixing documentation

* lestarch: fixing up multiple definitions and RPI compilation problems

* lestarch: reverting debug build

* lestarch: reverting platform types to class-based constants

* lestarch: reworking basic types

* lestarch: configured types refactor into classes

* lestarch: fixing bugs with static constants in classes

* lestarch: fixing platform types spelling and documentation

* lestarch: adding include guards to types headers

Co-authored-by: Kevin F Ortega <kevin.f.ortega@jpl.nasa.gov>
2022-08-18 13:25:56 -07:00

62 lines
1.8 KiB
C++

// ----------------------------------------------------------------------
// Main.cpp
// ----------------------------------------------------------------------
#include <cstring>
#include <cstdio>
#include <FpConfig.hpp>
#include <Fw/Types/Assert.hpp>
#include <Fw/Types/MallocAllocator.hpp>
#include <Fw/SerializableFile/SerializableFile.hpp>
#include <Fw/SerializableFile/test/TestSerializable/TestSerializableAc.hpp>
using namespace Fw;
int main(int argc, char **argv) {
// Create local serializable:
U32 element1 = 4294967284U;
I8 element2 = -18;
F64 element3 = 3.14159;
U32 size = Test::SERIALIZED_SIZE;
Test config(element1, element2, element3);
// Create the serializable file:
MallocAllocator theMallocator;
SerializableFile configFile(&theMallocator, size);
SerializableFile::Status status;
// Save the serializable to a file:
printf("Testing save... ");
status = configFile.save("test.ser", config);
FW_ASSERT(SerializableFile::OP_OK == status, status);
printf("Passed\n");
// Load the serializable from a file:
printf("Testing load... ");
Test config2;
status = configFile.load("test.ser", config2);
FW_ASSERT(SerializableFile::OP_OK == status, status);
printf("Passed\n");
// Compare the results:
printf("Testing compare... ");
FW_ASSERT(config == config2);
printf("Passed\n");
// Test saving to impossible file:
printf("Testing bad save... ");
status = configFile.save("this/file/does/not/exist", config);
FW_ASSERT(SerializableFile::FILE_OPEN_ERROR == status, status);
printf("Passed\n");
// Test reading from nonexistent file:
printf("Testing bad load... ");
Test config3;
status = configFile.load("thisfiledoesnotexist.ser", config3);
FW_ASSERT(SerializableFile::FILE_OPEN_ERROR == status, status);
printf("Passed\n");
return 0;
}