summaryrefslogtreecommitdiff
path: root/test/main.cpp
diff options
context:
space:
mode:
authorDylan <boss@tehbox.org>2026-06-06 19:42:16 +1200
committerDylan <boss@tehbox.org>2026-06-06 19:42:16 +1200
commit1330868dd540da7b51e6dafb1a39af14678589d6 (patch)
treedb1069613247c9692613b8aab539b5c6bbac70f8 /test/main.cpp
parent1d379a5cf34475f66f2ab9359f77dac162c0a40e (diff)
downloadtehjson-1330868dd540da7b51e6dafb1a39af14678589d6.tar.gz
tehjson-1330868dd540da7b51e6dafb1a39af14678589d6.zip
feat: Moved serializers for basic types to json.cppHEADmain
Also removed `TestClass`
Diffstat (limited to 'test/main.cpp')
-rw-r--r--test/main.cpp78
1 files changed, 0 insertions, 78 deletions
diff --git a/test/main.cpp b/test/main.cpp
index e86ec06..00fca03 100644
--- a/test/main.cpp
+++ b/test/main.cpp
@@ -6,84 +6,6 @@
using std::cout, std::endl;
-class TestClass {
-private:
- int id;
- // std::string* testData;
-
-public:
- // 1. Default Constructor: Sets initial "empty" state [20, 24]
- TestClass() : id(-1)/*, testData(new std::string("default"))*/ {
- std::cout << "Default Constructor called" << std::endl;
- }
-
- // 2. Parameterized Constructor: For dependency injection/direct testing [24, 25]
- TestClass(int id/*, std::string val*/) : id(id)/*, testData(new std::string(val))*/ {
- std::cout << "Parameterized Constructor (id: " << id << ")" << std::endl;
- }
-
- // 3. Copy Constructor (Rule of 5): Deep copies resource [14, 23]
- TestClass(const TestClass& other) : id(other.id+1)/*, testData(new std::string(*other.testData))*/ {
- std::cout << "Copy Constructor called" << id << std::endl;
- }
-
- // 4. Move Constructor (Rule of 5): Transfers ownership of resource [14, 16]
- TestClass(TestClass&& other) noexcept : id(other.id+1)/*, testData(other.testData)*/ {
- // other.testData = nullptr;
- other.id = -1;
- std::cout << "Move Constructor called" << id << std::endl;
- }
-
- // 5. Destructor: Essential for RAII and preventing memory leaks [14, 29]
- ~TestClass() {
- // delete testData;
- std::cout << "Destructor called" << id << std::endl;
- }
-
- // Assignment Operators (Standard Rule of 5)
- TestClass& operator=(const TestClass& other) {
- if (this == &other) return *this;
- // delete testData;
- id = other.id + 1;
- // testData = new std::string(*other.testData);
- std::cout << "Assignment op 1 called" << id << std::endl;
- return *this;
- }
-
- TestClass& operator=(TestClass&& other) noexcept {
- if (this == &other) return *this;
- // delete testData;
- id = other.id + 1;
- // testData = other.testData;
- // other.testData = nullptr;
- std::cout << "Assignment op 2 called" << id << std::endl;
- return *this;
- }
-
- // Helper for verification [18, 21]
- int getId() const { return id; }
- // std::string getData() const { return testData ? *testData : "null"; }
-};
-
-
-template <> std::string TehJSON::JSON::serializeData<int>(std::shared_ptr<void> data)
-{
- return std::to_string(*static_cast<int*>(data.get()));
-}
-template <> std::string TehJSON::JSON::serializeData<float>(std::shared_ptr<void> data)
-{
- return std::to_string(*static_cast<float*>(data.get()));
-}
-template <> std::string TehJSON::JSON::serializeData<TestClass>(std::shared_ptr<void> data)
-{
- return "test class";
-}
-template <> std::string TehJSON::JSON::serializeData<std::string>(std::shared_ptr<void> data)
-{
- return '"' + *static_cast<std::string*>(data.get()) + '"';
-}
-
-
int main()
{
TehJSON::JSON jsonWriter;