Use googletest on Windows CE

Source: Internet
Author: User

I 've been trying to use googletest on Windows CE platform to do unit testing. but gtest doesn' t provide a Windows CE project file, so I had to modify the project myself. here is how to do so:

1. Add a new platform

I added a new Windows CE based platform (Windows Mobile 5.0 Pocket PC SDK (armv4i), for example) in the Configuration Manager of the gtest project.

2. Add below Preprocessor Definitions
 

In order to compile gtest library for Windows CE, I used below Preprocessor definitions:
 

"Ndebug;_ Win32_wce = $ (cever);Under_ce; $ (Platformdefines); wince; _ console;$ (Archfam); $ (_ archfam _); _ Unicode; Unicode"

Not all of them are mandatory, but missing the bold ones may cause gtest fail to compile.

3. Create a Windows CE console Project

The sample project is available:
Http://code.google.com/p/rxwen-blog-stuff/source/browse/#svn/trunk/wince/ce_gtest_proj

This project expects to find gtest header file (gtest \ gtest. h) and static library (gtestd. Lib) in googletest folder in parent directory.

Finally, I run the Unit Testing Application on a Windows CE device, and get below outputs in Visual Studio and serial port output respectively. The output shows that the test case passed successfully.

4. Run the application on emulator/device and verify output

Visual Studio output windowdevice serial port output

 

 

it's not always necessary to run Unit Testing Application on Windows CE device. if we write our application with care, it's possible that the application can compile and run on both Win32 and Windows CE platform. then we can do unit testing on a normal PC, which will be easier and faster.
but I still wowould like to run the unit testing on Windows CE if our product is supposed to run on it. any subtle differences between Win32 and Win CE may cause the unit testing succeed on one platform but fail on the other. it's wise to do unit testing on the platform that the application will actually run.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.