2012-06-21 22:50:05 +08:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include "ProcReader.h"
|
|
|
|
#include "TegraDetector.h"
|
|
|
|
#include "HardwareDetector.h"
|
|
|
|
#include "StringUtils.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
TEST(Strip, StripEmptyString)
|
|
|
|
{
|
|
|
|
string a = "";
|
|
|
|
EXPECT_FALSE(StripString(a));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Strip, StripClearString)
|
|
|
|
{
|
|
|
|
string a = "qqqwww";
|
|
|
|
EXPECT_TRUE(StripString(a));
|
|
|
|
EXPECT_STREQ("qqqwww", a.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Strip, StripStringLeft)
|
|
|
|
{
|
|
|
|
string a = " qqqwww";
|
|
|
|
EXPECT_TRUE(StripString(a));
|
|
|
|
EXPECT_STREQ("qqqwww", a.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Strip, StripStringRight)
|
|
|
|
{
|
|
|
|
string a = "qqqwww ";
|
|
|
|
EXPECT_TRUE(StripString(a));
|
|
|
|
EXPECT_STREQ("qqqwww", a.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Strip, StripStringLeftRight)
|
|
|
|
{
|
|
|
|
string a = "qqqwww ";
|
|
|
|
EXPECT_TRUE(StripString(a));
|
|
|
|
EXPECT_STREQ("qqqwww", a.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Strip, StripStringWithSpaces)
|
|
|
|
{
|
|
|
|
string a = " qqq www ";
|
|
|
|
EXPECT_TRUE(StripString(a));
|
|
|
|
EXPECT_STREQ("qqq www", a.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Parse, ParseEmptyString)
|
|
|
|
{
|
|
|
|
string a = "";
|
|
|
|
string key;
|
|
|
|
string value;
|
|
|
|
EXPECT_FALSE(ParseString(a, key, value));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Parse, ParseStringWithoutSeporator)
|
|
|
|
{
|
|
|
|
string a = "qqqwww";
|
|
|
|
string key;
|
2012-10-17 07:18:30 +08:00
|
|
|
string value;
|
2012-06-21 22:50:05 +08:00
|
|
|
EXPECT_FALSE(ParseString(a, key, value));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Parse, ParseClearString)
|
|
|
|
{
|
|
|
|
string a = "qqq:www";
|
|
|
|
string key;
|
|
|
|
string value;
|
|
|
|
EXPECT_TRUE(ParseString(a, key, value));
|
|
|
|
EXPECT_STREQ("qqq", key.c_str());
|
|
|
|
EXPECT_STREQ("www", value.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Parse, ParseDirtyString)
|
|
|
|
{
|
|
|
|
string a = "qqq : www";
|
|
|
|
string key;
|
|
|
|
string value;
|
|
|
|
EXPECT_TRUE(ParseString(a, key, value));
|
|
|
|
EXPECT_STREQ("qqq", key.c_str());
|
|
|
|
EXPECT_STREQ("www", value.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Split, SplitEmptyString)
|
|
|
|
{
|
|
|
|
string a = "";
|
|
|
|
set<string> b = SplitString(a, ' ');
|
|
|
|
EXPECT_EQ(0, b.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Split, SplitOneElementString)
|
|
|
|
{
|
|
|
|
string a = "qqq";
|
|
|
|
set<string> b = SplitString(a, ' ');
|
|
|
|
EXPECT_EQ(1, b.size());
|
|
|
|
EXPECT_FALSE(b.find("qqq") == b.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Split, SplitMultiElementString)
|
|
|
|
{
|
|
|
|
string a = "qqq www eee";
|
|
|
|
set<string> b = SplitString(a, ' ');
|
|
|
|
EXPECT_EQ(3, b.size());
|
|
|
|
EXPECT_FALSE(b.find("qqq") == b.end());
|
|
|
|
EXPECT_FALSE(b.find("www") == b.end());
|
|
|
|
EXPECT_FALSE(b.find("eee") == b.end());
|
|
|
|
}
|
|
|
|
|
2012-10-02 19:02:04 +08:00
|
|
|
TEST(CpuCount, CheckNonZero)
|
|
|
|
{
|
|
|
|
EXPECT_TRUE(GetProcessorCount() != 0);
|
|
|
|
}
|
|
|
|
|
2012-06-21 22:50:05 +08:00
|
|
|
TEST(GetCpuInfo, GetCpuInfo)
|
|
|
|
{
|
|
|
|
map<string, string> a = GetCpuInfo();
|
|
|
|
EXPECT_FALSE(a.empty());
|
|
|
|
EXPECT_TRUE(a.find("") == a.end());
|
|
|
|
}
|
|
|
|
|
2012-10-02 19:02:04 +08:00
|
|
|
TEST(CpuID, CheckNotEmpy)
|
2012-06-21 22:50:05 +08:00
|
|
|
{
|
2012-10-02 19:02:04 +08:00
|
|
|
int cpu_id = GetCpuID();
|
|
|
|
EXPECT_NE(0, cpu_id);
|
2012-06-21 22:50:05 +08:00
|
|
|
}
|
|
|
|
|
2013-01-22 19:53:07 +08:00
|
|
|
#if defined(__i386__)
|
2012-10-02 19:02:04 +08:00
|
|
|
TEST(CpuID, CheckX86)
|
2012-06-21 22:50:05 +08:00
|
|
|
{
|
2012-10-02 19:02:04 +08:00
|
|
|
int cpu_id = GetCpuID();
|
|
|
|
EXPECT_TRUE(cpu_id & ARCH_X86);
|
2012-06-21 22:50:05 +08:00
|
|
|
}
|
|
|
|
|
2012-10-02 19:02:04 +08:00
|
|
|
TEST(CpuID, CheckSSE2)
|
2012-06-21 22:50:05 +08:00
|
|
|
{
|
|
|
|
int cpu_id = GetCpuID();
|
2012-10-02 19:02:04 +08:00
|
|
|
EXPECT_TRUE(cpu_id & FEATURES_HAS_SSE2);
|
|
|
|
}
|
2013-01-22 19:53:07 +08:00
|
|
|
#elif defined(__mips)
|
2013-01-18 22:33:04 +08:00
|
|
|
#ifdef __SUPPORT_MIPS
|
|
|
|
TEST(CpuID, CheckMips)
|
|
|
|
{
|
2012-10-17 07:18:30 +08:00
|
|
|
int cpu_id = GetCpuID();
|
|
|
|
EXPECT_TRUE(cpu_id & ARCH_MIPS);
|
2013-01-18 22:33:04 +08:00
|
|
|
}
|
|
|
|
#endif
|
2012-10-02 19:02:04 +08:00
|
|
|
#else
|
|
|
|
TEST(TegraDetector, Detect)
|
|
|
|
{
|
|
|
|
EXPECT_TRUE(DetectTegra() != 0);
|
2012-06-21 22:50:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(CpuID, CheckArmV7)
|
|
|
|
{
|
|
|
|
int cpu_id = GetCpuID();
|
|
|
|
EXPECT_TRUE(cpu_id & ARCH_ARMv7);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(CpuID, CheckNeon)
|
|
|
|
{
|
|
|
|
int cpu_id = GetCpuID();
|
|
|
|
EXPECT_TRUE(cpu_id & FEATURES_HAS_NEON);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(CpuID, CheckVFPv3)
|
|
|
|
{
|
|
|
|
int cpu_id = GetCpuID();
|
|
|
|
EXPECT_TRUE(cpu_id & FEATURES_HAS_VFPv3);
|
|
|
|
}
|
|
|
|
|
2013-12-03 21:33:28 +08:00
|
|
|
TEST(PlatformDetector, CheckTegra)
|
2012-06-21 22:50:05 +08:00
|
|
|
{
|
|
|
|
EXPECT_NE(PLATFORM_UNKNOWN, DetectKnownPlatforms());
|
2012-10-02 19:02:04 +08:00
|
|
|
}
|
2013-01-18 22:33:04 +08:00
|
|
|
#endif
|