-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
223 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (C) 2023 Dominik Drexler | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* 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 "../../../include/loki/common/pddl/garbage_collected_factory.hpp" | ||
#include "../../../include/loki/domain/pddl/object.hpp" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <string> | ||
|
||
|
||
namespace loki::domain::tests { | ||
/* | ||
class Object { | ||
private: | ||
int m_identifier; | ||
std::string m_name; | ||
Object(int identifier, std::string name) : m_identifier(identifier), m_name(std::move(name)) { } | ||
template<typename... Ts> | ||
friend class GarbageCollectedFactory; | ||
public: | ||
int get_identifier() const { return m_identifier; } | ||
const std::string& get_name() const { return m_name; } | ||
}; | ||
TEST(LokiTests, GarbageCollectedFactoryTest) { | ||
GarbageCollectedFactory<Object> factory; | ||
EXPECT_EQ(factory.size<Object>(), 0); | ||
{ | ||
const auto object_0 = factory.get_or_create<Object>("object_0"); | ||
EXPECT_EQ(factory.size<Object>(), 1); | ||
EXPECT_EQ(object_0->get_name(), "object_0"); | ||
// destructor is called | ||
} | ||
EXPECT_EQ(factory.size<Object>(), 0); | ||
} | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (C) 2023 Dominik Drexler | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* 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 <gtest/gtest.h> | ||
|
||
#include "../../../include/loki/common/pddl/persistent_factory.hpp" | ||
#include "../../../include/loki/domain/pddl/object.hpp" | ||
|
||
|
||
namespace loki::domain::tests { | ||
|
||
TEST(LokiTests, PersistentFactoryTest) { | ||
PersistentFactory<pddl::ObjectImpl, 2> factory; | ||
EXPECT_EQ(factory.size(), 0); | ||
|
||
// Test uniqueness: insert the same element twice | ||
const auto object_0_0 = factory.get_or_create<pddl::ObjectImpl>("object_0"); | ||
EXPECT_EQ(factory.size(), 1); | ||
EXPECT_EQ(object_0_0->get_identifier(), 0); | ||
EXPECT_EQ(object_0_0->get_name(), "object_0"); | ||
const auto object_0_1 = factory.get_or_create<pddl::ObjectImpl>("object_0"); | ||
EXPECT_EQ(factory.size(), 1); | ||
EXPECT_EQ(object_0_0, object_0_1); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (C) 2023 Dominik Drexler | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* 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 <gtest/gtest.h> | ||
|
||
#include "../../../include/loki/common/pddl/segmented_vector.hpp" | ||
|
||
|
||
namespace loki::domain::tests { | ||
|
||
TEST(LokiTests, SegmentedVectorTest) { | ||
SegmentedVector<int, 2> vec; | ||
EXPECT_EQ(vec.size(), 0); | ||
EXPECT_EQ(vec.capacity(), 0); | ||
|
||
vec.push_back(2); | ||
EXPECT_EQ(vec.size(), 1); | ||
EXPECT_EQ(vec.capacity(), 2); | ||
EXPECT_EQ(vec[0], 2); | ||
|
||
vec.push_back(1); | ||
EXPECT_EQ(vec.size(), 2); | ||
EXPECT_EQ(vec[1], 1); | ||
EXPECT_EQ(vec.capacity(), 2); | ||
|
||
vec.push_back(0); | ||
EXPECT_EQ(vec.size(), 3); | ||
EXPECT_EQ(vec[2], 0); | ||
EXPECT_EQ(vec.capacity(), 4); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
file(GLOB SRC_FILES | ||
"*.cpp") | ||
"ast/*.cpp") | ||
|
||
add_executable(domain_tests ${SRC_FILES}) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.