code format

This commit is contained in:
keita
2021-03-05 11:31:44 +09:00
parent 9aa3fe1c9a
commit dcb2565df6
10 changed files with 49 additions and 47 deletions
+5 -4
View File
@@ -13,10 +13,11 @@ void Create::id(const std::string& _id) {
CocoaTweet::API::Model::Tweet Create::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
CocoaTweet::API::Model::Tweet tweet;
HttpPost::process(_oauth, [&tweet](const unsigned int _responseCode, const std::string& _rcv) {
tweet = CocoaTweet::API::Model::Tweet(_responseCode, _rcv);
});
HttpPost::process(_oauth,
[&tweet](const unsigned int _responseCode, const std::string& _rcv) {
tweet = CocoaTweet::API::Model::Tweet(_responseCode, _rcv);
});
return tweet;
return tweet;
}
} // namespace CocoaTweet::API::Favorites
+1 -1
View File
@@ -9,7 +9,7 @@ class Create : public CocoaTweet::API::Interface::HttpPost {
public:
Create();
void id(const std::string& _id);
CocoaTweet::API::Model::Tweet process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
CocoaTweet::API::Model::Tweet process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
private:
};
+7 -5
View File
@@ -11,12 +11,14 @@ void Destroy::id(const std::string& _id) {
bodyParam_.insert_or_assign("id", _id);
}
CocoaTweet::API::Model::Tweet Destroy::process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
CocoaTweet::API::Model::Tweet Destroy::process(
std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth) {
CocoaTweet::API::Model::Tweet tweet;
HttpPost::process(_oauth, [&tweet](const unsigned int _responseCode, const std::string& _rcv) {
tweet = CocoaTweet::API::Model::Tweet(_responseCode, _rcv);
});
HttpPost::process(_oauth,
[&tweet](const unsigned int _responseCode, const std::string& _rcv) {
tweet = CocoaTweet::API::Model::Tweet(_responseCode, _rcv);
});
return tweet;
return tweet;
}
} // namespace CocoaTweet::API::Favorites
+1 -1
View File
@@ -9,7 +9,7 @@ class Destroy : public CocoaTweet::API::Interface::HttpPost {
public:
Destroy();
void id(const std::string& _id);
CocoaTweet::API::Model::Tweet process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
CocoaTweet::API::Model::Tweet process(std::weak_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
private:
};
+2 -2
View File
@@ -10,8 +10,8 @@ class Favorite : public groupInterface {
public:
Favorite() = default;
Favorite(std::shared_ptr<CocoaTweet::OAuth::OAuth1> _oauth);
CocoaTweet::API::Model::Tweet Create(const std::string& _id) const;
CocoaTweet::API::Model::Tweet Destroy(const std::string& _id) const;
CocoaTweet::API::Model::Tweet Create(const std::string& _id) const;
CocoaTweet::API::Model::Tweet Destroy(const std::string& _id) const;
};
} // namespace CocoaTweet::API::Favorites
+10 -10
View File
@@ -13,21 +13,21 @@ Tweet Tweet::parse(const unsigned int _responseCode, const std::string& _json) {
if (_responseCode == 200) {
tweet.id(j["id_str"]);
tweet.createdAt(j["created_at"]);
tweet.text(j["text"]);
tweet.source(j["source"]);
tweet.createdAt(j["created_at"]);
tweet.text(j["text"]);
tweet.source(j["source"]);
} else {
auto error = j["errors"][0]["code"];
auto message = j["errors"][0]["message"];
if (error.get<int>() == 144) {
throw CocoaTweet::Exception::TweetNotFoundException(message.get<std::string>().c_str());
}else if(error.get<int>() == 32){
} else if (error.get<int>() == 32) {
throw CocoaTweet::Exception::AuthenticateException(message.get<std::string>().c_str());
}else if(error.get<int>() == 187){
} else if (error.get<int>() == 187) {
throw CocoaTweet::Exception::TweetDuplicateException(message.get<std::string>().c_str());
}else if(error.get<int>() == 88 || error.get<int>() == 185){
} else if (error.get<int>() == 88 || error.get<int>() == 185) {
throw CocoaTweet::Exception::RateLimitException(message.get<std::string>().c_str());
}else if(error.get<int>() == 186){
} else if (error.get<int>() == 186) {
throw CocoaTweet::Exception::TweetTooLongException(message.get<std::string>().c_str());
}
}
@@ -39,14 +39,14 @@ void Tweet::id(const std::string _id) {
id_ = _id;
}
void Tweet::createdAt(const std::string _at){
void Tweet::createdAt(const std::string _at) {
createdAt_ = _at;
}
void Tweet::text(const std::string _text){
void Tweet::text(const std::string _text) {
text_ = _text;
}
void Tweet::source(const std::string _source){
void Tweet::source(const std::string _source) {
source_ = _source;
}
+9 -11
View File
@@ -12,21 +12,19 @@ public:
: Tweet(Tweet::parse(_responseCode, _json)) {}
static Tweet parse(const unsigned int _responseCode, const std::string& _json);
void id(const std::string _id);
void createdAt(const std::string _at);
void text(const std::string _text);
void source(const std::string _source);
void createdAt(const std::string _at);
void text(const std::string _text);
void source(const std::string _source);
const std::string id() const;
const std::string createdAt() const;
const std::string text() const;
const std::string source() const;
const std::string createdAt() const;
const std::string text() const;
const std::string source() const;
private:
std::string id_;
std::string createdAt_;
std::string text_;
std::string source_;
std::string createdAt_;
std::string text_;
std::string source_;
};
} // namespace CocoaTweet::API::Model
+1 -5
View File
@@ -11,11 +11,7 @@ class Key {
const std::string accessTokenSecret_;
public:
Key()
: consumerKey_(""),
consumerSecret_(""),
accessToken_(""),
accessTokenSecret_("") {}
Key() : consumerKey_(""), consumerSecret_(""), accessToken_(""), accessTokenSecret_("") {}
Key(const std::string& _consumerKey, const std::string& _consumerSecret,
const std::string& _accessToken, const std::string& _accessTokenSecret)
: consumerKey_(_consumerKey),
+10 -5
View File
@@ -42,7 +42,8 @@ BOOST_AUTO_TEST_CASE(test03) {
}]
})";
BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(401, json), CocoaTweet::Exception::AuthenticateException);
BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(401, json),
CocoaTweet::Exception::AuthenticateException);
}
BOOST_AUTO_TEST_CASE(test04) {
@@ -53,7 +54,8 @@ BOOST_AUTO_TEST_CASE(test04) {
}]
})";
BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(429, json), CocoaTweet::Exception::RateLimitException);
BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(429, json),
CocoaTweet::Exception::RateLimitException);
}
BOOST_AUTO_TEST_CASE(test05) {
@@ -64,7 +66,8 @@ BOOST_AUTO_TEST_CASE(test05) {
}]
})";
BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(403, json), CocoaTweet::Exception::RateLimitException);
BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(403, json),
CocoaTweet::Exception::RateLimitException);
}
BOOST_AUTO_TEST_CASE(test06) {
@@ -75,7 +78,8 @@ BOOST_AUTO_TEST_CASE(test06) {
}]
})";
BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(403, json), CocoaTweet::Exception::TweetTooLongException);
BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(403, json),
CocoaTweet::Exception::TweetTooLongException);
}
BOOST_AUTO_TEST_CASE(test07) {
@@ -86,6 +90,7 @@ BOOST_AUTO_TEST_CASE(test07) {
}]
})";
BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(403, json), CocoaTweet::Exception::TweetDuplicateException);
BOOST_CHECK_THROW(CocoaTweet::API::Model::Tweet(403, json),
CocoaTweet::Exception::TweetDuplicateException);
}
BOOST_AUTO_TEST_SUITE_END()
+3 -3
View File
@@ -6,7 +6,7 @@
BOOST_AUTO_TEST_SUITE(oauth_key)
BOOST_AUTO_TEST_CASE(test01) {
CocoaTweet::OAuth::Key key;
CocoaTweet::OAuth::Key key;
BOOST_TEST(key.consumerKey() == "");
BOOST_TEST(key.consumerSecret() == "");
@@ -15,7 +15,8 @@ BOOST_AUTO_TEST_CASE(test01) {
}
BOOST_AUTO_TEST_CASE(test02) {
CocoaTweet::OAuth::Key key("consumerKey", "consumerSecret", "accessToken", "accessTokenSecret");
CocoaTweet::OAuth::Key key("consumerKey", "consumerSecret", "accessToken",
"accessTokenSecret");
BOOST_TEST(key.consumerKey() == "consumerKey");
BOOST_TEST(key.consumerSecret() == "consumerSecret");
@@ -31,5 +32,4 @@ BOOST_AUTO_TEST_CASE(test02) {
BOOST_TEST(secret.at("oauth_token") == "accessTokenSecret");
}
BOOST_AUTO_TEST_SUITE_END()