File: test_jwt_object.cc

package info (click to toggle)
cpp-jwt 1.5%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 508 kB
  • sloc: cpp: 3,374; ansic: 33; sh: 31; makefile: 12
file content (30 lines) | stat: -rw-r--r-- 741 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "gtest/gtest.h"
#include "jwt/jwt.hpp"

namespace {

struct Wrapper
{
    // The std::move here is required to resolve to the move ctor
    // rather than to the universal reference ctor.
    Wrapper(jwt::jwt_object&& obj) : object{std::move(obj)} {}
    jwt::jwt_object object;
};

} // END namespace

TEST (ObjectTest, MoveConstructor)
{
  using namespace jwt::params;

  jwt::jwt_object obj{algorithm("HS256"), secret("secret")};

  obj.add_claim("iss", "arun.muralidharan");

  auto wrapper = Wrapper{std::move(obj)};

  EXPECT_EQ(wrapper.object.header().algo(), jwt::algorithm::HS256);
  EXPECT_EQ(wrapper.object.secret(), "secret");
  EXPECT_TRUE(wrapper.object.payload().has_claim_with_value("iss", "arun.muralidharan"));
}