本文整理汇总了C++中UnitTest类的典型用法代码示例。如果您正苦于以下问题:C++ UnitTest类的具体用法?C++ UnitTest怎么用?C++ UnitTest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UnitTest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: printf
int UnitTest::RunAllInGroup( const char* group )
{
printf( "GROUP %s\n", group );
int error_count = 0;
const char dashes[] = "------------------------------";
// Because of (naughty) reliance of static constructor to register tests, the order in the list is out of my
// control. A little extra code to make them run in alphabetical order.
UnitTest* test = FindNext( group, NULL );
while( test )
{
size_t offset = strlen( test->m_Name );
if( offset >= sizeof( dashes ) )
{
offset = sizeof( dashes ) - 1;
}
printf( " %s %s ", test->m_Name, dashes + offset );
test->m_ErrorCount = 0;
test->Test();
if( test->m_ErrorCount == 0 )
{
printf( "pass\n" );
}
error_count += test->m_ErrorCount;
test->m_Done = true;
test = FindNext( group, test );
}
return error_count;
}
开发者ID:RonPieket,项目名称:MojoLib,代码行数:30,代码来源:UnitTest.cpp
示例2: main
int main (int argc, char** argv)
{
UnitTest t (16);
// Ensure environment has no influence.
unsetenv ("TASKDATA");
unsetenv ("TASKRC");
t.is (mk_wcwidth ('a'), 1, "U+0061 --> 1");
t.is (mk_wcwidth (0x5149), 2, "U+5149 --> 2");
t.is (mk_wcwidth (0x9a8c), 2, "U+9a8c --> 2");
t.is (mk_wcwidth (0x4e70), 2, "U+4e70 --> 2");
t.is (mk_wcwidth (0x94b1), 2, "U+94b1 --> 2");
t.is (mk_wcwidth (0x5305), 2, "U+5305 --> 2");
t.is (mk_wcwidth (0x91cd), 2, "U+91cd --> 2");
t.is (mk_wcwidth (0x65b0), 2, "U+65b0 --> 2");
t.is (mk_wcwidth (0x8bbe), 2, "U+8bbe --> 2");
t.is (mk_wcwidth (0x8ba1), 2, "U+8ba1 --> 2");
t.is (mk_wcwidth (0x5411), 2, "U+5411 --> 2");
t.is (mk_wcwidth (0x4e0a), 2, "U+4e0a --> 2");
t.is (mk_wcwidth (0x4e0b), 2, "U+4e0b --> 2");
t.is (mk_wcwidth (0x7bad), 2, "U+7bad --> 2");
t.is (mk_wcwidth (0x5934), 2, "U+5934 --> 2");
t.is (mk_wcwidth (0xff0c), 2, "U+ff0c --> 2"); // comma
return 0;
}
开发者ID:georgebrock,项目名称:task,代码行数:28,代码来源:width.t.cpp
示例3: test_tialloc_size10
void test_tialloc_size10(UnitTest &utf) {
vector<void *> all_allocations;
vector<int > all_allocations_size;
for(size_t n=0; n<10000; n++) {
int allocation_size = 10;
unsigned char *allocation = (unsigned char *) tialloc::instance()->alloc(allocation_size);
// fill allocated memory
for(size_t i=0; i<allocation_size; i++) {
allocation[i] = (i*n)%256;
}
all_allocations.push_back(allocation);
all_allocations_size.push_back(allocation_size);
}
// check allocations
for(size_t n=0; n<all_allocations.size(); n++) {
for(size_t i=0; i<all_allocations_size[n]; i++) {
unsigned char v = ((unsigned char *) all_allocations[n])[i];
if(all_allocations_size[n] <= 121) {
utf.test_equality(true,tialloc::instance()->is_tiallocated(all_allocations[n]));
}
utf.test_equality((int)v,(int) (i*n)%256);
}
tialloc::instance()->free(all_allocations[n]);
}
}
开发者ID:new299,项目名称:tialloc,代码行数:30,代码来源:test_tialloc.cpp
示例4: XP_RunUnitTests
XP_EXPORT int XP_RunUnitTests(PRFileDesc *fd)
{
int passed = 0;
int failed = 0;
PR_fprintf(fd, "Running unit tests\n");
UnitTest *test = tests;
while (test) {
PR_fprintf(fd, "Running %s from %s:%d\n", test->name, test->filename, test->line);
XPStatus rv = test->fn(fd);
if (rv == XP_SUCCESS) {
PR_fprintf(fd, "PASS: %s passed\n", test->name);
passed++;
} else {
PR_fprintf(fd, "FAILURE: %s failed\n", test->name);
failed++;
}
test = test->next;
}
PR_fprintf(fd, "%d test(s) passed\n", passed);
PR_fprintf(fd, "%d test(s) failed\n", failed);
int total = passed + failed;
PR_fprintf(fd, "%.0f%% pass rate\n", total ? passed * 100.0 / total : 100.0);
if (failed) {
PR_fprintf(fd, "FAILURE: Some tests failed\n");
} else {
PR_fprintf(fd, "SUCCESS: All tests passed\n");
}
return failed;
}
开发者ID:OldsSourcesBackups,项目名称:Heliod-Web-Server,代码行数:35,代码来源:xpunit.cpp
示例5: OnTestIterationStart
// Called before each iteration of tests starts.
void TersePrinter::OnTestIterationStart(const UnitTest& unit_test, int /*iteration*/)
{
ColoredPrintf(COLOR_GREEN, "%s", "Using TersePrinter.\n");
ColoredPrintf(COLOR_GREEN, "%s", "[==========] ");
printf("Running %s from %d test cases.\n",
FormatTestCount(unit_test.test_to_run_count()).c_str(),
unit_test.test_case_to_run_count());
fflush(stdout);
}
开发者ID:a-w,项目名称:astyle,代码行数:10,代码来源:TersePrinter.cpp
示例6: r
std::vector<mxArray*> TestCommand::handle()
{
UnitTest ut;
bool b = ut.test(t.val, u.val, f.val, deltaF.val, g.val, deltaG.val);
std::vector<mxArray*> r(1);
r[0] = mxCreateLogicalScalar(b);
return r;
}
开发者ID:dwendelen,项目名称:Thesis,代码行数:9,代码来源:command.cpp
示例7: test_tialloc
int test_tialloc(UnitTest &utf) {
utf.begin_test_set("tialloc tests");
test_tialloc_size10(utf);
test_tialloc_size5to10(utf);
test_tialloc_random(utf);
utf.end_test_set();
}
开发者ID:new299,项目名称:tialloc,代码行数:10,代码来源:test_tialloc.cpp
示例8: AllTests
void AllTests()
{
UnitTest tests;
ArrayTests(tests);
DictionaryTests(tests);
ListTests(tests);
StringTests(tests);
WriteLine(tests.Execute());
ReadLine();
}
开发者ID:sysrpl,项目名称:Codebot.Cpp,代码行数:10,代码来源:main.cpp
示例9: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
UnitTest unittest;
unittest.add(new BasicTestA());
unittest.add(new BasicTestB());
unittest.add(new BasicTestC());
unittest.add(new BasicTestD());
unittest.add(new BasicTestE());
unittest.add(new BasicTestF());
unittest.add(new BasicTestG());
unittest.add(new BasicTestH());
unittest.add(new BasicTestI());
std::cout << unittest.execute() << std::endl;
std::cout << unittest.percentageOKString() << std::endl;
std::cout << "Test sucess: " << unittest.percentageOK() << "%" << std::endl;
std::cout << "Press any key to continue...";
std::cin.get();
/*
std::cout << ASSERT_IS_EQUAL(0,0) << std::endl;
std::cout << ASSERT_IS_EQUAL(0,'h') << std::endl;
std::cout << ASSERT_IS_EQUAL(0,1) << std::endl;
std::cout << ASSERT_IS_EQUAL("hola","hola") << std::endl;
std::cout << std::endl;
std::cout << ASSERT_IS_NOT_EQUAL(0,0) << std::endl;
std::cout << ASSERT_IS_NOT_EQUAL(0,'h') << std::endl;
std::cout << ASSERT_IS_NOT_EQUAL(0,1) << std::endl;
std::cout << "Press any key to continue...";
std::cin.get();
*/
return 0;
}
开发者ID:abraracurcix,项目名称:UnitTestAssert,代码行数:31,代码来源:Main.cpp
示例10: main
int main (int argc, char** argv)
{
UnitTest t (8);
std::vector <std::string> options;
options.push_back ("abc");
options.push_back ("abcd");
options.push_back ("abcde");
options.push_back ("bcdef");
options.push_back ("cdefg");
std::vector <std::string> matches;
int result = autoComplete ("", options, matches);
t.is (result, 0, "no match on empty string");
result = autoComplete ("x", options, matches);
t.is (result, 0, "no match on wrong string");
result = autoComplete ("abcd", options, matches);
t.is (result, 1, "exact match on 'abcd'");
t.is (matches[0], "abcd", "exact match on 'abcd'");
result = autoComplete ("ab", options, matches);
t.is (result, 3, "partial match on 'ab'");
t.is (matches[0], "abc", "partial match on 'abc'");
t.is (matches[1], "abcd", "partial match on 'abcd'");
t.is (matches[2], "abcde", "partial match on 'abcde'");
return 0;
}
开发者ID:SEJeff,项目名称:task,代码行数:30,代码来源:autocomplete.t.cpp
示例11: main
int main (int argc, char** argv)
{
UnitTest t (12);
// std::string formatBytes (size_t);
t.is (formatBytes (0), "0 B", "0 -> 0 B");
t.is (formatBytes (994), "994 B", "994 -> 994 B");
t.is (formatBytes (995), "1.0 KiB", "995 -> 1.0 KiB");
t.is (formatBytes (999), "1.0 KiB", "999 -> 1.0 KiB");
t.is (formatBytes (1000), "1.0 KiB", "1000 -> 1.0 KiB");
t.is (formatBytes (1001), "1.0 KiB", "1001 -> 1.0 KiB");
t.is (formatBytes (999999), "1.0 MiB", "999999 -> 1.0 MiB");
t.is (formatBytes (1000000), "1.0 MiB", "1000000 -> 1.0 MiB");
t.is (formatBytes (1000001), "1.0 MiB", "1000001 -> 1.0 MiB");
t.is (formatBytes (999999999), "1.0 GiB", "999999999 -> 1.0 GiB");
t.is (formatBytes (1000000000), "1.0 GiB", "1000000000 -> 1.0 GiB");
t.is (formatBytes (1000000001), "1.0 GiB", "1000000001 -> 1.0 GiB");
// TODO const std::string uuid ();
// TODO const std::string encode (const std::string& value);
// TODO const std::string decode (const std::string& value);
return 0;
}
开发者ID:PedroLopes,项目名称:taskd,代码行数:28,代码来源:util.t.cpp
示例12: main
int main(int ac, char *argv[])
{
UnitTest unit;
try {
unit.init(ac, argv);
unit.launch();
} catch (const std::exception &e) {
std::cerr << e.what() << std::endl;
}
}
开发者ID:antgar,项目名称:rtype_cpp,代码行数:11,代码来源:main.cpp
示例13: test_tialloc_random
void test_tialloc_random(UnitTest &utf) {
vector<void *> all_allocations;
vector<int > all_allocations_size;
for(size_t n=0; n<1000; n++) {
int allocation_size = (rand()%500) + 1;
unsigned char *allocation = (unsigned char *) tialloc::instance()->alloc(allocation_size);
// fill allocated memory
for(size_t i=0; i<allocation_size; i++) {
allocation[i] = i%256;
}
all_allocations.push_back(allocation);
all_allocations_size.push_back(allocation_size);
}
// check allocations
for(size_t n=0; n<all_allocations.size(); n++) {
for(size_t i=0; i<all_allocations_size[n]; i++) {
unsigned char v = ((unsigned char *) all_allocations[n])[i];
if(all_allocations_size[n] <= 121) {
utf.test_equality(true,tialloc::instance()->is_tiallocated(all_allocations[n]));
}
utf.test_equality((int)v,(int) i%256);
}
}
// try reallocs
for(size_t n=0; n<all_allocations.size(); n++) {
all_allocations[n] = tialloc::instance()->realloc(all_allocations[n],all_allocations_size[n]+1);
}
// check allocations again!
for(size_t n=0; n<all_allocations.size(); n++) {
for(size_t i=0; i<all_allocations_size[n]; i++) {
unsigned char v = ((unsigned char *) all_allocations[n])[i];
utf.test_equality((int)v,(int) i%256);
}
tialloc::instance()->free(all_allocations[n]);
}
// alloc size tests
for(size_t n=1; n<1000; n++) {
uint32_t *i = (uint32_t *) tialloc::instance()->alloc(n);
utf.test_equality(tialloc::instance()->alloc_size(i),n);
}
}
开发者ID:new299,项目名称:tialloc,代码行数:53,代码来源:test_tialloc.cpp
示例14: DoAll
void UnitTest::DoAll(const char *test_name) {
UnitTest *test = First;
Time_struct Time;
int n = 0;
while(test) {
if(!test_name ||
ToLower(test->Test.Name.c_str()).find(ToLower(test_name)) != string::npos) {
test->Run();
n++;
}
test = test->Next;
}
cout << "Tests done " << n << " test time " << Time << "\n";
}
开发者ID:pyal,项目名称:eos_cpp,代码行数:14,代码来源:unit_test.cpp
示例15: test_adaptivethreshold
void test_adaptivethreshold(UnitTest &ut) {
ut.begin_test_set("AdaptiveThreshold");
/*
SwiftImage<uint16> img("./Images/tiny5dot.tif");
AdaptiveThreshold<uint16> at(1,0.7,AdaptiveThreshold<uint16>::mask_type_circle);
SwiftImage<uint16> imgat = at.process(img);
ut.test(imgat(0,0),static_cast<uint16>(0));
ut.test(imgat(1,0),static_cast<uint16>(0));
ut.test(imgat(2,0),static_cast<uint16>(0));
ut.test(imgat(3,0),static_cast<uint16>(0));
ut.test(imgat(4,0),static_cast<uint16>(0));
ut.test(imgat(0,1),static_cast<uint16>(0));
ut.test(imgat(1,1),static_cast<uint16>(65534));
ut.test(imgat(2,1),static_cast<uint16>(65534));
ut.test(imgat(3,1),static_cast<uint16>(65534));
ut.test(imgat(4,1),static_cast<uint16>(0));
ut.test(imgat(0,2),static_cast<uint16>(0));
ut.test(imgat(1,2),static_cast<uint16>(65534));
ut.test(imgat(2,2),static_cast<uint16>(0));
ut.test(imgat(3,2),static_cast<uint16>(65534));
ut.test(imgat(4,2),static_cast<uint16>(0));
ut.test(imgat(0,3),static_cast<uint16>(0));
ut.test(imgat(1,3),static_cast<uint16>(65534));
ut.test(imgat(2,3),static_cast<uint16>(65534));
ut.test(imgat(3,3),static_cast<uint16>(65534));
ut.test(imgat(4,3),static_cast<uint16>(0));
ut.test(imgat(0,4),static_cast<uint16>(0));
ut.test(imgat(1,4),static_cast<uint16>(0));
ut.test(imgat(2,4),static_cast<uint16>(0));
ut.test(imgat(3,4),static_cast<uint16>(0));
ut.test(imgat(4,4),static_cast<uint16>(0));
SwiftImage<uint16> i2("./Images/run475_lane1tile1/C2.1/s_1_1_a.tif");
MorphologicalOpening<uint16> mo(4);
SwiftImage<uint16> i4 = mo.process(i2);
i2 = i2 - i4;
SwiftImage<uint16> i3 = at.process(i2);
i3.save("./adaptive_morph.tif");
*/
ut.end_test_set();
}
开发者ID:emmaggie,项目名称:swift,代码行数:49,代码来源:test_adaptivethreshold.cpp
示例16: test_runlengthencode
void test_runlengthencode(UnitTest &ut) {
ut.begin_test_set("RunLengthEncode");
SwiftImage<uint16> img("./Images/tinyline.tif");
RunLengthEncode<uint16> rle;
vector<RLERun<> > runs = rle.process(img);
ut.test(static_cast<int>(runs.size()) ,1);
ut.test(runs[0].pos.x ,2);
ut.test(runs[0].pos.y ,1);
ut.test(runs[0].length,9);
ut.end_test_set();
}
开发者ID:emmaggie,项目名称:swift,代码行数:16,代码来源:test_runlengthencode.cpp
示例17: OnTestIterationEnd
// Called after each iteration of tests finishes.
void TersePrinter::OnTestIterationEnd(const UnitTest& unit_test, int /*iteration*/)
{
g_test_to_run = unit_test.test_to_run_count();
ColoredPrintf(COLOR_GREEN, "%s", "[==========] ");
printf("%s from %d test cases ran.",
FormatTestCount(unit_test.test_to_run_count()).c_str(),
unit_test.test_case_to_run_count());
float time_in_ms = static_cast<float>(unit_test.elapsed_time());
printf(" (%1.2f seconds total)\n", time_in_ms / 1000);
// Print total passed.
ColoredPrintf(COLOR_GREEN, "%s", "[ PASSED ] ");
printf("%s.\n", FormatTestCount(unit_test.successful_test_count()).c_str());
// Print total failed.
int num_failures = unit_test.failed_test_count();
if (num_failures)
{
ColoredPrintf(COLOR_RED, "%s", "[ FAILED ] ");
printf("%s, listed below:\n", FormatTestCount(num_failures).c_str());
PrintFailedTestsList(unit_test);
printf("\n%d FAILED %s\n", num_failures,
num_failures == 1 ? "TEST" : "TESTS");
}
// Print total disabled.
int num_disabled = unit_test.disabled_test_count();
if (num_disabled)
{
if (!num_failures)
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
ColoredPrintf(COLOR_YELLOW, " YOU HAVE %d DISABLED TESTS\n", num_disabled);
}
// Ensure that Google Test output is printed before, e.g., heapchecker output.
fflush(stdout);
}
开发者ID:a-w,项目名称:astyle,代码行数:34,代码来源:TersePrinter.cpp
示例18: test_reporting
void test_reporting(UnitTest &ut) {
ut.begin_test_set("Reporting");
Cluster<double> c1;
c1.add_signal("RAW");
c1.signal("RAW").push_back(ReadIntensity<double>(1000 ,0,0,0 ));
c1.signal("RAW").push_back(ReadIntensity<double>(500 ,0,0,2000));
c1.signal("RAW").push_back(ReadIntensity<double>(250 ,0,0,2000));
c1.signal("RAW").push_back(ReadIntensity<double>(125 ,0,0,2000));
c1.signal("RAW").push_back(ReadIntensity<double>(62.5 ,0,0,2000));
c1.signal("RAW").push_back(ReadIntensity<double>(31.25,0,0,2000));
c1.add_signal("FINAL_CORRECTED");
c1.signal("FINAL_CORRECTED").push_back(ReadIntensity<double>(1000 ,0,0,0 ));
c1.signal("FINAL_CORRECTED").push_back(ReadIntensity<double>(500 ,0,0,2000));
c1.signal("FINAL_CORRECTED").push_back(ReadIntensity<double>(250 ,0,0,2000));
c1.signal("FINAL_CORRECTED").push_back(ReadIntensity<double>(125 ,0,0,2000));
c1.signal("FINAL_CORRECTED").push_back(ReadIntensity<double>(62.5 ,0,0,2000));
c1.signal("FINAL_CORRECTED").push_back(ReadIntensity<double>(31.25,0,0,2000));
c1.add_sequence("BASECALL_FINAL");
//TODO: I'm really unclear as to why I need this cast, for some reason gcc can't see base_type from here...
c1.sequence("BASECALL_FINAL").sequence().push_back(static_cast<int>(ScoredSequence<>::base_a));
c1.sequence("BASECALL_FINAL").sequence().push_back(static_cast<int>(ScoredSequence<>::base_t));
c1.sequence("BASECALL_FINAL").sequence().push_back(static_cast<int>(ScoredSequence<>::base_t));
c1.sequence("BASECALL_FINAL").sequence().push_back(static_cast<int>(ScoredSequence<>::base_t));
c1.sequence("BASECALL_FINAL").sequence().push_back(static_cast<int>(ScoredSequence<>::base_t));
c1.sequence("BASECALL_FINAL").sequence().push_back(static_cast<int>(ScoredSequence<>::base_t));
vector<Cluster<double> > clusters;
clusters.push_back(c1);
clusters.push_back(c1);
clusters.push_back(c1);
clusters.push_back(c1);
clusters.push_back(c1);
clusters.push_back(c1);
Reporting<double> m_reporting(clusters,true,"./phi_plus_SNPs.fa");
m_reporting.write_report_file("report");
ut.end_test_set();
}
开发者ID:emmaggie,项目名称:swift,代码行数:45,代码来源:test_reporting.cpp
示例19: catch
void TestSuite::runUnitTests(ITestCallback* callback) {
callback->beginTestSuite(this);
UnitTests::iterator it = mUnitTests.begin();
UnitTests::iterator end = mUnitTests.end();
for(;it != end; ++it) {
UnitTest* test = *it;
callback->beginUnitTest(this, test);
try {
test->Run(this);
} catch(TestException e) {
callback->testFailure(this, test, e.File.c_str(), e.Message.c_str(), e.Line);
}
callback->endUnitTest(this, test);
}
callback->endTestSuite(this);
}
开发者ID:perandersson,项目名称:everstore-server,代码行数:18,代码来源:TestSuite.cpp
示例20: OnEnvironmentsTearDownStart
// Called before environment tear-down for each iteration of tests starts.
void TersePrinter::OnEnvironmentsTearDownStart(const UnitTest& unit_test)
{
// need a linefeed if a test case end is not printed
if ((useTerseOutput && unit_test.failed_test_count() != 0)
|| !GTEST_FLAG(print_time))
printf("\n");
ColoredPrintf(COLOR_GREEN, "%s", "[----------] ");
printf("Global test environment tear-down.\n");
fflush(stdout);
}
开发者ID:a-w,项目名称:astyle,代码行数:11,代码来源:TersePrinter.cpp
注:本文中的UnitTest类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论