{"id":19399768,"url":"https://github.com/korfuri/fake_clock","last_synced_at":"2025-08-16T13:48:29.811Z","repository":{"id":35992797,"uuid":"40284643","full_name":"korfuri/fake_clock","owner":"korfuri","description":"A C++11-compliant fake clock useful for C++ unit tests that depend on time.","archived":false,"fork":false,"pushed_at":"2017-09-21T02:36:49.000Z","size":4,"stargazers_count":21,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-08-16T22:36:45.275Z","etag":null,"topics":["c-plus-plus","clock","testing"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/korfuri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-06T04:39:04.000Z","updated_at":"2023-03-23T17:12:07.000Z","dependencies_parsed_at":"2022-09-09T07:41:31.868Z","dependency_job_id":null,"html_url":"https://github.com/korfuri/fake_clock","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korfuri%2Ffake_clock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korfuri%2Ffake_clock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korfuri%2Ffake_clock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korfuri%2Ffake_clock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/korfuri","download_url":"https://codeload.github.com/korfuri/fake_clock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223942581,"owners_count":17229112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-plus-plus","clock","testing"],"created_at":"2024-11-10T11:11:08.917Z","updated_at":"2024-11-10T11:11:09.527Z","avatar_url":"https://github.com/korfuri.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libfake_clock\n\nA clock class that is convenient for testing.\n\nThis class satisfies the\n[TrivialClock](http://en.cppreference.com/w/cpp/concept/TrivialClock)\nrequirement and as such can be used in place of any standard clock\n(e.g. std::chrono::system_clock). This is useful to test C++ code that\nmanipulates time, without having to use sleep() in your unittests.\n\nThe clock uses an uint64_t internally, so it can store all\nnanoseconds in a century. This is consistent with the precision\nrequired of std::chrono::nanoseconds in C++11.\n\nExample usage:\n\n````C++\n   fake_clock::time_point t1 = fake_clock::now();\n   fake_clock::advance(std::chrono::milliseconds(100));\n   fake_clock::time_point t2 = fake_clock::now();\n   auto elapsed_us = std::chrono::duration_cast\u003c\n          std::chrono::microseconds\u003e(t2 - t1).count();\n   assert(100000 == elapsed_us);\n````\n\nFor a more advanced and practical example, see\n[my prometheus client implementation](https://github.com/korfuri/client_cpp/blob/c922b557ec01e9399499a05b04835cb43c2bc4c6/prometheus/client_test.cc)\nfor which I originally wrote this.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkorfuri%2Ffake_clock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkorfuri%2Ffake_clock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkorfuri%2Ffake_clock/lists"}