diff --git a/CMakeLists.txt b/CMakeLists.txt index cf40050..903a95e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,3 +29,5 @@ set(JWT_HEADERS ${JWT_INCLUDE_PATH}/jwt-cpp/jwt.h) install(FILES ${JWT_HEADERS} DESTINATION include/jwt-cpp) + +add_subdirectory(tests) diff --git a/tests/BaseTest.cpp b/tests/BaseTest.cpp index aceeb38..fd3171c 100644 --- a/tests/BaseTest.cpp +++ b/tests/BaseTest.cpp @@ -1,5 +1,5 @@ #include -#include "include/jwt-cpp/base.h" +#include "jwt-cpp/base.h" TEST(BaseTest, Base64Decode) { ASSERT_EQ("1", jwt::base::decode("MQ==")); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..7ea2344 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,18 @@ +enable_testing() + +find_package(GTest CONFIG REQUIRED) + +set(TEST_SOURCES +${CMAKE_CURRENT_SOURCE_DIR}/BaseTest.cpp +${CMAKE_CURRENT_SOURCE_DIR}/ClaimTest.cpp +${CMAKE_CURRENT_SOURCE_DIR}/HelperTest.cpp +${CMAKE_CURRENT_SOURCE_DIR}/TestMain.cpp +${CMAKE_CURRENT_SOURCE_DIR}/TokenFormatTest.cpp +${CMAKE_CURRENT_SOURCE_DIR}/TokenTest.cpp +) + +add_executable(jwt-cpp-test ${TEST_SOURCES}) + +target_link_libraries(jwt-cpp-test PRIVATE jwt-cpp GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main) + +add_test(AllTests jwt-cpp-test) \ No newline at end of file diff --git a/tests/ClaimTest.cpp b/tests/ClaimTest.cpp index 6f66ec1..f4f3f04 100644 --- a/tests/ClaimTest.cpp +++ b/tests/ClaimTest.cpp @@ -1,5 +1,5 @@ #include -#include "include/jwt-cpp/jwt.h" +#include "jwt-cpp/jwt.h" TEST(ClaimTest, AudienceAsString) { std::string token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJ0ZXN0In0.WZnM3SIiSRHsbO3O7Z2bmIzTJ4EC32HRBKfLznHhrh4"; diff --git a/tests/HelperTest.cpp b/tests/HelperTest.cpp index f998e12..3f08ce8 100644 --- a/tests/HelperTest.cpp +++ b/tests/HelperTest.cpp @@ -1,5 +1,5 @@ #include -#include "include/jwt-cpp/jwt.h" +#include "jwt-cpp/jwt.h" namespace { extern std::string google_cert; diff --git a/tests/TokenFormatTest.cpp b/tests/TokenFormatTest.cpp index e670a82..3749f76 100644 --- a/tests/TokenFormatTest.cpp +++ b/tests/TokenFormatTest.cpp @@ -1,5 +1,5 @@ #include -#include "include/jwt-cpp/jwt.h" +#include "jwt-cpp/jwt.h" TEST(TokenFormatTest, MissingDot) { ASSERT_THROW(jwt::decode("eyJhbGciOiJub25lIiwidHlwIjoiSldTIn0.eyJpc3MiOiJhdXRoMCJ9"), std::invalid_argument); diff --git a/tests/TokenTest.cpp b/tests/TokenTest.cpp index 9d3089e..22e6ce2 100644 --- a/tests/TokenTest.cpp +++ b/tests/TokenTest.cpp @@ -1,5 +1,5 @@ #include -#include "include/jwt-cpp/jwt.h" +#include "jwt-cpp/jwt.h" namespace { extern std::string rsa_priv_key;