Skip to content

Commit

Permalink
Added TUser Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AdventureT committed Dec 10, 2023
1 parent b6bb86a commit 7bc3550
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions Tools/UnitTests/Source/TKernel/TUser_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,40 @@

TOSHI_NAMESPACE_USING

static TUser testUser("Test");
static TUser testUser2("AdventureT");

TEST_CASE("Register User", "[TUser]")
{
TUser user("AdventureT");
TSHORT iUserID = user.Register();
TSHORT iUserID = testUser.Register();

REQUIRE(iUserID != -1);
REQUIRE(TUserHandler::GetSingleton().FindUser("Test"));
REQUIRE(testUser.IsRegistered());

iUserID = testUser2.Register();

REQUIRE(iUserID != -1);
REQUIRE(user.IsRegistered());
REQUIRE(TUserHandler::GetSingleton().FindUser("AdventureT"));
REQUIRE(testUser.IsRegistered());

REQUIRE(TUserHandler::GetSingleton().FindUser("Toshi")); // This user is created in the ctor of TKernelInterface
REQUIRE(TUserHandler::GetSingleton().GetUserCount() == 3);
}

TEST_CASE("Deregister User", "[TUser]")
{
testUser.Deregister();

REQUIRE(!TUserHandler::GetSingleton().FindUser("Test"));
REQUIRE(!testUser.IsRegistered());

testUser2.Deregister();

REQUIRE(!TUserHandler::GetSingleton().FindUser("AdventureT"));
REQUIRE(!testUser2.IsRegistered());

REQUIRE(TUserHandler::GetSingleton().FindUser("Toshi")); // This user is created in the ctor of TKernelInterface
// The Users are still present, but not Registered
REQUIRE(TUserHandler::GetSingleton().GetUserCount() == 3);
}

0 comments on commit 7bc3550

Please sign in to comment.