Adding Simple Objest test. Fixes some bugs
This commit is contained in:
parent
edf0548046
commit
63029e6083
10 changed files with 74 additions and 15 deletions
|
|
@ -23,7 +23,7 @@ target_link_libraries(${PROJECT_NAME} PUBLIC Strings Math Tokenizer CommandLine
|
|||
|
||||
### -------------------------- Tests -------------------------- ###
|
||||
enable_testing()
|
||||
file(GLOB TEST_SOURCES "./tests/*.cpp")
|
||||
file(GLOB TEST_SOURCES "./tests/*.cpp" "./tests/*/*.cpp")
|
||||
add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES})
|
||||
target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} Utils)
|
||||
add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests)
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ static tp::ModuleManifest* sModuleDependencies[] = {
|
|||
&tp::gModuleMath,
|
||||
&tp::gModuleStrings,
|
||||
&tp::gModuleTokenizer,
|
||||
&tp::gModuleConnection,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -46,14 +46,18 @@ namespace obj {
|
|||
|
||||
public:
|
||||
Archiver() = default;
|
||||
explicit Archiver(const char* location) {};
|
||||
explicit Archiver(const char* location) {
|
||||
mConnection.connect(tp::LocalConnection::Location(location), tp::LocalConnection::Type(tRead));
|
||||
};
|
||||
|
||||
void writeBytes(const tp::int1* val, tp::ualni size) override {
|
||||
mConnection.setPointer(mAddress);
|
||||
mConnection.writeBytes(val, size);
|
||||
incrementAddresses(size);
|
||||
}
|
||||
|
||||
void readBytes(tp::int1* val, tp::ualni size) override {
|
||||
mConnection.setPointer(mAddress);
|
||||
mConnection.readBytes(val, size);
|
||||
incrementAddresses(size);
|
||||
}
|
||||
|
|
@ -68,7 +72,7 @@ namespace obj {
|
|||
|
||||
bool isOpened() { return mConnection.getConnectionStatus().isOpened(); }
|
||||
|
||||
bool getSize() { return mConnection.size(); }
|
||||
tp::ualni getSize() { return mConnection.size(); }
|
||||
|
||||
private:
|
||||
void incrementAddresses(tp::ualni size) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,22 @@
|
|||
|
||||
#include "primitives/primitives.h"
|
||||
|
||||
using namespace tp;
|
||||
using namespace obj;
|
||||
|
||||
|
||||
void testCore();
|
||||
|
||||
int main() {
|
||||
|
||||
tp::ModuleManifest* deps[] = { &gModuleObjects, nullptr };
|
||||
tp::ModuleManifest module("ObjectsTests", nullptr, nullptr, deps);
|
||||
|
||||
if (module.initialize()) {
|
||||
|
||||
testCore();
|
||||
|
||||
module.deinitialize();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
31
Objects/tests/core/TestCore.cpp
Normal file
31
Objects/tests/core/TestCore.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "Testing.hpp"
|
||||
|
||||
#include "core/object.h"
|
||||
|
||||
#include "primitives/intobject.h"
|
||||
|
||||
using namespace tp;
|
||||
using namespace obj;
|
||||
|
||||
TEST_DEF_STATIC(BasicAPI) {
|
||||
auto integer = NDO_CAST(IntObject, NDO->create("int"));
|
||||
|
||||
integer->val = 10;
|
||||
|
||||
printf("%s\n", NDO->toString(integer).read());
|
||||
|
||||
NDO->save(integer, "tmp.o");
|
||||
auto savedInt = NDO->load("tmp.o");
|
||||
|
||||
printf("%s\n", NDO->toString(savedInt).read());
|
||||
|
||||
NDO->destroy(integer);
|
||||
NDO->destroy(savedInt);
|
||||
}
|
||||
|
||||
TEST_DEF(Core) {
|
||||
testBasicAPI();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue