diff options
author | Marat Dukhan <marat@fb.com> | 2017-09-26 18:35:52 -0700 |
---|---|---|
committer | Marat Dukhan <marat@fb.com> | 2017-09-26 18:35:52 -0700 |
commit | 3040197bc3eb13796351e74a2e7a6f2bcc081752 (patch) | |
tree | 2387e26e11be3307d931e4741d2f3ae559e0bb09 /test/get-current.cc | |
parent | 2b24889379602c17d2448c891e25c76d2b039ffc (diff) | |
download | cpuinfo-3040197bc3eb13796351e74a2e7a6f2bcc081752.tar.gz |
Major API refactoring
Diffstat (limited to 'test/get-current.cc')
-rw-r--r-- | test/get-current.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/get-current.cc b/test/get-current.cc new file mode 100644 index 0000000..c9bc1b9 --- /dev/null +++ b/test/get-current.cc @@ -0,0 +1,34 @@ +#include <gtest/gtest.h> + +#include <cpuinfo.h> + + +TEST(CURRENT_PROCESSOR, not_null) { + ASSERT_TRUE(cpuinfo_get_current_processor()); +} + +TEST(CURRENT_PROCESSOR, within_bounds) { + const struct cpuinfo_processor* current_processor = cpuinfo_get_current_processor(); + const struct cpuinfo_processor* processors_begin = cpuinfo_get_processors(); + const struct cpuinfo_processor* processors_end = processors_begin + cpuinfo_get_processors_count(); + ASSERT_GE(current_processor, processors_begin); + ASSERT_LT(current_processor, processors_end); +} + +TEST(CURRENT_CORE, not_null) { + ASSERT_TRUE(cpuinfo_get_current_core()); +} + +TEST(CURRENT_CORE, within_bounds) { + const struct cpuinfo_core* current_core = cpuinfo_get_current_core(); + const struct cpuinfo_core* cores_begin = cpuinfo_get_cores(); + const struct cpuinfo_core* cores_end = cores_begin + cpuinfo_get_cores_count(); + ASSERT_GE(current_core, cores_begin); + ASSERT_LT(current_core, cores_end); +} + +int main(int argc, char* argv[]) { + cpuinfo_initialize(); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} |