1
0
mirror of https://github.com/google/cpu_features.git synced 2025-07-01 21:31:15 +02:00

Reformat files

This commit is contained in:
Arvid Gerstmann
2018-05-04 09:32:17 +02:00
parent 235d57c591
commit d968991caa
12 changed files with 122 additions and 67 deletions

View File

@ -94,7 +94,8 @@ extern "C" void CpuFeatures_CloseFile(int file_descriptor) {
kFilesystem->FindFileOrDie(file_descriptor)->Close();
}
extern "C" int CpuFeatures_ReadFile(int file_descriptor, void* buf, size_t count) {
extern "C" int CpuFeatures_ReadFile(int file_descriptor, void* buf,
size_t count) {
return kFilesystem->FindFileOrDie(file_descriptor)
->Read(file_descriptor, buf, count);
}

View File

@ -42,7 +42,8 @@ class LinuxFeatureAggregatorTest : public testing::Test {
TEST_F(LinuxFeatureAggregatorTest, FromFlagsEmpty) {
Features features;
CpuFeatures_SetFromFlags(kConfigs.size(), kConfigs.data(), str(""), &features);
CpuFeatures_SetFromFlags(kConfigs.size(), kConfigs.data(), str(""),
&features);
EXPECT_FALSE(features.a);
EXPECT_FALSE(features.b);
EXPECT_FALSE(features.c);
@ -50,7 +51,8 @@ TEST_F(LinuxFeatureAggregatorTest, FromFlagsEmpty) {
TEST_F(LinuxFeatureAggregatorTest, FromFlagsAllSet) {
Features features;
CpuFeatures_SetFromFlags(kConfigs.size(), kConfigs.data(), str("a c b"), &features);
CpuFeatures_SetFromFlags(kConfigs.size(), kConfigs.data(), str("a c b"),
&features);
EXPECT_TRUE(features.a);
EXPECT_TRUE(features.b);
EXPECT_TRUE(features.c);
@ -58,7 +60,8 @@ TEST_F(LinuxFeatureAggregatorTest, FromFlagsAllSet) {
TEST_F(LinuxFeatureAggregatorTest, FromFlagsOnlyA) {
Features features;
CpuFeatures_SetFromFlags(kConfigs.size(), kConfigs.data(), str("a"), &features);
CpuFeatures_SetFromFlags(kConfigs.size(), kConfigs.data(), str("a"),
&features);
EXPECT_TRUE(features.a);
EXPECT_FALSE(features.b);
EXPECT_FALSE(features.c);
@ -69,7 +72,8 @@ TEST_F(LinuxFeatureAggregatorTest, FromHwcapsNone) {
capability.hwcaps = 0; // matches none
capability.hwcaps2 = 0; // matches none
Features features;
CpuFeatures_OverrideFromHwCaps(kConfigs.size(), kConfigs.data(), capability, &features);
CpuFeatures_OverrideFromHwCaps(kConfigs.size(), kConfigs.data(), capability,
&features);
EXPECT_FALSE(features.a);
EXPECT_FALSE(features.b);
EXPECT_FALSE(features.c);
@ -80,7 +84,8 @@ TEST_F(LinuxFeatureAggregatorTest, FromHwcapsSet) {
capability.hwcaps = 0b0010; // matches b but not a
capability.hwcaps2 = 0b1111; // matches c
Features features;
CpuFeatures_OverrideFromHwCaps(kConfigs.size(), kConfigs.data(), capability, &features);
CpuFeatures_OverrideFromHwCaps(kConfigs.size(), kConfigs.data(), capability,
&features);
EXPECT_FALSE(features.a);
EXPECT_TRUE(features.b);
EXPECT_TRUE(features.c);

View File

@ -57,12 +57,15 @@ TEST(StringViewTest, CpuFeatures_StringView_IndexOf) {
TEST(StringViewTest, CpuFeatures_StringView_StartsWith) {
EXPECT_TRUE(CpuFeatures_StringView_StartsWith(str("test"), str("te")));
EXPECT_FALSE(CpuFeatures_StringView_StartsWith(str("test"), str("")));
EXPECT_FALSE(CpuFeatures_StringView_StartsWith(str("test"), kEmptyStringView));
EXPECT_FALSE(CpuFeatures_StringView_StartsWith(kEmptyStringView, str("test")));
EXPECT_FALSE(
CpuFeatures_StringView_StartsWith(str("test"), kEmptyStringView));
EXPECT_FALSE(
CpuFeatures_StringView_StartsWith(kEmptyStringView, str("test")));
}
TEST(StringViewTest, CpuFeatures_StringView_IsEquals) {
EXPECT_TRUE(CpuFeatures_StringView_IsEquals(kEmptyStringView, kEmptyStringView));
EXPECT_TRUE(
CpuFeatures_StringView_IsEquals(kEmptyStringView, kEmptyStringView));
EXPECT_TRUE(CpuFeatures_StringView_IsEquals(kEmptyStringView, str("")));
EXPECT_TRUE(CpuFeatures_StringView_IsEquals(str(""), kEmptyStringView));
EXPECT_TRUE(CpuFeatures_StringView_IsEquals(str("a"), str("a")));
@ -111,11 +114,14 @@ TEST(StringViewTest, CpuFeatures_StringView_CopyString) {
TEST(StringViewTest, CpuFeatures_StringView_HasWord) {
// Find flags at beginning, middle and end.
EXPECT_TRUE(CpuFeatures_StringView_HasWord(str("first middle last"), "first"));
EXPECT_TRUE(CpuFeatures_StringView_HasWord(str("first middle last"), "middle"));
EXPECT_TRUE(
CpuFeatures_StringView_HasWord(str("first middle last"), "first"));
EXPECT_TRUE(
CpuFeatures_StringView_HasWord(str("first middle last"), "middle"));
EXPECT_TRUE(CpuFeatures_StringView_HasWord(str("first middle last"), "last"));
// Do not match partial flags
EXPECT_FALSE(CpuFeatures_StringView_HasWord(str("first middle last"), "irst"));
EXPECT_FALSE(
CpuFeatures_StringView_HasWord(str("first middle last"), "irst"));
EXPECT_FALSE(CpuFeatures_StringView_HasWord(str("first middle last"), "mid"));
EXPECT_FALSE(CpuFeatures_StringView_HasWord(str("first middle last"), "las"));
}