-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcpumask_ctest.cc
41 lines (33 loc) · 1012 Bytes
/
cpumask_ctest.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "catch_amalgamated.hpp"
// #include <memory>
#include <string>
#define TESTING
#include "cpumask.c"
using Catch::Matchers::ContainsSubstring;
TEST_CASE("parse a single core correctly") {
REQUIRE(parse_core(std::string("3,").c_str()) == 3U);
}
/*
Causes the test itself to exit.
Catch2 appears to have no equivalent to Googletest's EXPECT_EXIT().
TEST_CASE("bad core strings are rejected") {
CHECK(1 == parse_core(std::string(",").c_str()));
}
*/
TEST_CASE("range parsing works") {
// works with single-digit delimiters
CHECK(3 == parse_range("0-1,", 1U));
/*
clang-format off
As with the Googletest equivalent, triggers an ASAN SEGV.
std::shared_ptr<const char> str1("0-1");
CHECK(3 == parse_range(str1.get(), 1U));
clang-format on
*/
// works with multi-digit delimiters
CHECK((1 << 10) + (1 << 11) == parse_range("10-11,", 2U));
// Empty range.
CHECK(0 == parse_range("1-0,", 1U));
// Single-core equivalent.
CHECK(2 == parse_range("1-1,", 1U));
}