Debian Codegraph @

mtxclient/tests/errors.cpp

raw symbols SCIP
1 #include <gtest/gtest.h>
2
3 #include <mtx/errors.hpp>
4
5 #include <nlohmann/json.hpp>
6
7 using namespace mtx::errors;
8
9 TEST(MatrixErrors, BasicError)
10 {
11 nlohmann::json data = R"({
12 "errcode": "M_UNRECOGNIZED",
13 "error": "Unrecognized request"
14 })"_json;
15
16 Error err = data.get<Error>();
17
18 EXPECT_EQ(err.errcode, ErrorCode::M_UNRECOGNIZED);
19 EXPECT_EQ(err.error, "Unrecognized request");
20
21 nlohmann::json data2 = R"({
22 "errcode": "M_MISSING_TOKEN",
23 "error": "Missing access token"
24 })"_json;
25
26 err = data2.get<Error>();
27
28 EXPECT_EQ(err.errcode, ErrorCode::M_MISSING_TOKEN);
29 EXPECT_EQ(err.error, "Missing access token");
30 }