ModEasy, a c++ library, is an easy to add modding system that is functional out of the box, but also designed to be extendable for whatever you may need.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.0 KiB

#include "TestBase.h"
#include "Configuration/ConfigStore.h"
#include <memory>
int main (int argc, char* argv[]) {
//TEST_BEGIN( "test1" );
//ASSERT_EQUAL( 0, 0 );
//ASSERT_THROW( 0 == 0 );
//EXPECT_EXCEPTION( fakeFileLoad("does_not_exist.txt"), FileNotFound );
std::shared_ptr<ConfigStore> store1 = std::make_shared<ConfigStore>(),
store2 = std::make_shared<ConfigStore>(),
store3 = std::make_shared<ConfigStore>();
TEST_BEGIN( "isPopulated: Test ConfigStore is false" );
ASSERT_THROW( store1->isPopulated() == false );
TEST_BEGIN( "getStr: Test getStr of invalid key" );
ASSERT_THROW( store1->getStr("invalid key") == "" );
TEST_BEGIN( "getNested: Test getNested of invalid key" );
ASSERT_THROW( store1->getNested("invalid key") == nullptr );
TEST_BEGIN( "set and getStr: Set and Get valid strings" );
store1->set("data1", "str data");
store3->set("data3", "str data3");
ASSERT_THROW( store1->getStr("data1") == "str data");
ASSERT_THROW( store3->getStr("data3") == "str data3");
TEST_BEGIN( "set and getNested: Set and Get valid ConfigStore" );
store1->set("nest2", store2);
store2->set("nest3", store3);
ASSERT_THROW( store1->getNested("nest2") == store2);
ASSERT_THROW( store1->getNested("nest2")->getNested("nest3") == store3);
TEST_BEGIN( "isPopulated: Test ConfigStore with only string is true" );
ASSERT_THROW( store3->isPopulated() == true );
TEST_BEGIN( "isPopulated: Test ConfigStore with only nested ConfigStore is true" );
ASSERT_THROW( store2->isPopulated() == true );
TEST_BEGIN( "isPopulated: Test ConfigStore with nested and string ConfigStore is true" );
ASSERT_THROW( store1->isPopulated() == true );
//TODO need to test iterators
return 0;