зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1111151 - Move TestCRT.cpp to gtest and enable it; r=froydnj
--HG-- rename : xpcom/tests/TestCRT.cpp => xpcom/glue/tests/gtest/TestCRT.cpp extra : rebase_source : 95297289071d49a160cfd79a609ba81d3aaf994c
This commit is contained in:
Родитель
dd2247efcc
Коммит
5cf11173d2
|
@ -7,6 +7,7 @@
|
|||
#include "nsString.h"
|
||||
#include "plstr.h"
|
||||
#include <stdlib.h>
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace TestCRT {
|
||||
|
||||
|
@ -29,15 +30,9 @@ int sign(int val) {
|
|||
// iso-latin-1 strings, so the comparison must be valid.
|
||||
static void Check(const char* s1, const char* s2, int n)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
int clib =
|
||||
#endif
|
||||
PL_strcmp(s1, s2);
|
||||
int clib = PL_strcmp(s1, s2);
|
||||
|
||||
#ifdef DEBUG
|
||||
int clib_n =
|
||||
#endif
|
||||
PL_strncmp(s1, s2, n);
|
||||
int clib_n = PL_strncmp(s1, s2, n);
|
||||
|
||||
nsAutoString t1,t2;
|
||||
t1.AssignWithConversion(s1);
|
||||
|
@ -45,18 +40,13 @@ static void Check(const char* s1, const char* s2, int n)
|
|||
const char16_t* us1 = t1.get();
|
||||
const char16_t* us2 = t2.get();
|
||||
|
||||
#ifdef DEBUG
|
||||
int u2 =
|
||||
#endif
|
||||
nsCRT::strcmp(us1, us2);
|
||||
int u2 = nsCRT::strcmp(us1, us2);
|
||||
|
||||
#ifdef DEBUG
|
||||
int u2_n =
|
||||
#endif
|
||||
nsCRT::strncmp(us1, us2, n);
|
||||
int u2_n = nsCRT::strncmp(us1, us2, n);
|
||||
|
||||
NS_ASSERTION(sign(clib) == sign(u2), "strcmp");
|
||||
NS_ASSERTION(sign(clib_n) == sign(u2_n), "strncmp");
|
||||
EXPECT_EQ(sign(clib), sign(u2));
|
||||
EXPECT_EQ(sign(clib), sign(u2_n));
|
||||
EXPECT_EQ(sign(clib), sign(clib_n));
|
||||
}
|
||||
|
||||
struct Test {
|
||||
|
@ -83,16 +73,12 @@ static Test tests[] = {
|
|||
};
|
||||
#define NUM_TESTS int((sizeof(tests) / sizeof(tests[0])))
|
||||
|
||||
}
|
||||
|
||||
using namespace TestCRT;
|
||||
|
||||
int main()
|
||||
TEST(CRT, main)
|
||||
{
|
||||
Test* tp = tests;
|
||||
TestCRT::Test* tp = tests;
|
||||
for (int i = 0; i < NUM_TESTS; i++, tp++) {
|
||||
Check(tp->s1, tp->s2, tp->n);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
UNIFIED_SOURCES += [
|
||||
'TestArray.cpp',
|
||||
'TestCRT.cpp',
|
||||
'TestFileUtils.cpp',
|
||||
'TestGCPostBarriers.cpp',
|
||||
'TestStrings.cpp',
|
||||
|
|
|
@ -80,7 +80,6 @@ if CONFIG['MOZ_MEMORY']:
|
|||
|
||||
# XXX Make these tests work in libxul builds.
|
||||
#CPP_UNIT_TESTS += [
|
||||
# 'TestCRT',
|
||||
# 'TestEncoding',
|
||||
# 'TestExpirationTracker',
|
||||
# 'TestPipes',
|
||||
|
|
Загрузка…
Ссылка в новой задаче