2014-07-31 00:35:19 +00:00
|
|
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
|
2014-08-05 23:13:55 +00:00
|
|
|
#include "osquery/status.h"
|
2014-07-31 00:35:19 +00:00
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
2014-08-05 23:13:55 +00:00
|
|
|
namespace osquery {
|
2014-07-31 00:35:19 +00:00
|
|
|
|
|
|
|
class StatusTests : public testing::Test {};
|
|
|
|
|
|
|
|
TEST_F(StatusTests, test_constructor) {
|
|
|
|
auto s = Status(5, "message");
|
|
|
|
EXPECT_EQ(s.getCode(), 5);
|
|
|
|
EXPECT_EQ(s.getMessage(), "message");
|
|
|
|
}
|
|
|
|
|
2014-09-06 10:41:10 +00:00
|
|
|
TEST_F(StatusTests, test_constructor_2) {
|
|
|
|
Status s;
|
|
|
|
EXPECT_EQ(s.getCode(), 0);
|
|
|
|
EXPECT_EQ(s.getMessage(), "OK");
|
|
|
|
}
|
|
|
|
|
2014-07-31 00:35:19 +00:00
|
|
|
TEST_F(StatusTests, test_ok) {
|
|
|
|
auto s1 = Status(5, "message");
|
|
|
|
EXPECT_FALSE(s1.ok());
|
|
|
|
auto s2 = Status(0, "message");
|
|
|
|
EXPECT_TRUE(s2.ok());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(StatusTests, test_to_string) {
|
|
|
|
auto s = Status(0, "foobar");
|
|
|
|
EXPECT_EQ(s.toString(), "foobar");
|
|
|
|
}
|
2014-08-05 23:13:55 +00:00
|
|
|
}
|
2014-07-31 00:35:19 +00:00
|
|
|
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
testing::InitGoogleTest(&argc, argv);
|
|
|
|
return RUN_ALL_TESTS();
|
|
|
|
}
|