Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "time_keeper.h"
- #include <gtest/gtest.h>
- #include <gmock/gmock.h>
- #include "mocks/glfw_api_mock.h"
- using ::testing::Return;
- using ::testing::_;
- class TimeKeeperTest : public ::testing::Test {
- protected:
- TimeKeeper* time_keeper;
- GlfwApiMock glfw_api_mock;
- virtual void SetUp() {
- time_keeper = new TimeKeeper(&glfw_api_mock);
- }
- virtual void TearDown() {
- }
- };
- TEST_F(TimeKeeperTest, returnDelta) {
- ASSERT_LE(0, time_keeper->getDelta());
- }
- TEST_F(TimeKeeperTest, returnDifferentDeltas) {
- EXPECT_CALL(glfw_api_mock, glfwGetTime()).WillOnce(Return(10));
- double first_delta;
- double second_delta;
- first_delta = time_keeper->getDelta();
- time_keeper->calculate();
- second_delta = time_keeper->getDelta();
- ASSERT_LT(first_delta, second_delta);
- }
- TEST_F(TimeKeeperTest, resetDelta) {
- EXPECT_CALL(glfw_api_mock, glfwGetTime()).WillRepeatedly(Return(10));
- time_keeper->calculate();
- ASSERT_LT(0, time_keeper->getDelta());
- time_keeper->reset();
- ASSERT_EQ(0, time_keeper->getDelta());
- }
- TEST_F(TimeKeeperTest, returnCorrectDeltaAfterReset) {
- EXPECT_CALL(glfw_api_mock, glfwGetTime()).WillOnce(Return(10)).WillOnce(
- Return(20)).WillOnce(Return(40));
- time_keeper->calculate();
- time_keeper->reset();
- time_keeper->calculate();
- ASSERT_EQ(20, time_keeper->getDelta());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement