Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(386)

Side by Side Diff: native_client_sdk/src/examples/hello_world/test_helper_functions.cc

Issue 9370041: Clean up examples (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This is an example of a simple unit test to verify that the logic helper
6 // functions works as expected. Note that this looks like a 'normal' C++
7 // program, with a main function. It is compiled and linked using the NaCl
8 // toolchain, so in order to run it, you must use 'sel_ldr_x86_32' or
9 // 'sel_ldr_x86_64' from the toolchain's bin directory.
10 //
11 // For example (assuming the toolchain bin directory is in your path):
12 // sel_ldr_x86_32 test_helper_functions_x86_32_dbg.nexe
13 //
14 // You can also use the 'test32', or 'test64' SCons target to run these tests.
15 // For example, this will run the test in 32-bit mode on Mac or Linux:
16 // ../scons test32
17 // On Windows 64:
18 // ..\scons test64
19
20 #include "examples/hello_world/helper_functions.h"
21
22 #include <cassert>
23 #include <cstdio>
24 #include <string>
25
26 // A very simple macro to print 'passed' if boolean_expression is true and
27 // 'FAILED' otherwise.
28 // This is meant to approximate the functionality you would get from a real test
29 // framework. You should feel free to build and use the test framework of your
30 // choice.
31 #define EXPECT_EQUAL(left, right)\
32 printf("Check: \"" #left "\" == \"" #right "\" %s\n", \
33 ((left) == (right)) ? "passed" : "FAILED")
34
35 using hello_world::FortyTwo;
36 using hello_world::ReverseText;
37
38 int main() {
39 EXPECT_EQUAL(FortyTwo(), 42);
40
41 std::string empty_string;
42 EXPECT_EQUAL(ReverseText(empty_string), empty_string);
43
44 std::string palindrome("able was i ere i saw elba");
45 EXPECT_EQUAL(ReverseText(palindrome), palindrome);
46
47 std::string alphabet("abcdefghijklmnopqrstuvwxyz");
48 std::string alphabet_backwards("zyxwvutsrqponmlkjihgfedcba");
49 EXPECT_EQUAL(ReverseText(alphabet), alphabet_backwards);
50 return 0;
51 }
52
OLDNEW
« no previous file with comments | « native_client_sdk/src/examples/hello_world/helper_functions.cc ('k') | native_client_sdk/src/examples/hello_world_c/Makefile » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698