feat(Exception)

This commit is contained in:
2024-09-30 16:17:24 +03:00
parent 7e78bca810
commit 4eaf5b53c0
5 changed files with 111 additions and 0 deletions

35
test/test-Exception.cpp Normal file
View File

@ -0,0 +1,35 @@
#include <basen/Exception.hpp>
#include <gtest/gtest.h>
TEST(Exception, Exception)
{
EXPECT_ANY_THROW(throw basen::Exception(basen::Exception::Code::BASE));
}
TEST(Exception, message)
{
try
{
throw basen::Exception(basen::Exception::Code::BASE);
}
catch (const basen::Exception &e)
{
EXPECT_STREQ(e.message(), "incorrect base");
}
}
TEST(Exception, code)
{
try
{
throw basen::Exception(basen::Exception::Code::BASE);
}
catch (const basen::Exception &e)
{
EXPECT_EQ(uint32_t(e.code()), uint32_t(basen::Exception::Code::BASE));
}
}
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}