Debian Codegraph @

tests/test_jwt_object.cc

raw
1 #include "gtest/gtest.h"
2 #include "jwt/jwt.hpp"
3
4 namespace {
5
6 struct Wrapper
7 {
8 // The std::move here is required to resolve to the move ctor
9 // rather than to the universal reference ctor.
10 Wrapper(jwt::jwt_object&& obj) : object{std::move(obj)} {}
11 jwt::jwt_object object;
12 };
13
14 } // END namespace
15
16 TEST (ObjectTest, MoveConstructor)
17 {
18 using namespace jwt::params;
19
20 jwt::jwt_object obj{algorithm("HS256"), secret("secret")};
21
22 obj.add_claim("iss", "arun.muralidharan");
23
24 auto wrapper = Wrapper{std::move(obj)};
25
26 EXPECT_EQ(wrapper.object.header().algo(), jwt::algorithm::HS256);
27 EXPECT_EQ(wrapper.object.secret(), "secret");
28 EXPECT_TRUE(wrapper.object.payload().has_claim_with_value("iss", "arun.muralidharan"));
29 }
30