14b6829f0d28990dd645e16386eb226d0f10c8731shiqian// Copyright 2006, Google Inc.
24b6829f0d28990dd645e16386eb226d0f10c8731shiqian// All rights reserved.
34b6829f0d28990dd645e16386eb226d0f10c8731shiqian//
44b6829f0d28990dd645e16386eb226d0f10c8731shiqian// Redistribution and use in source and binary forms, with or without
54b6829f0d28990dd645e16386eb226d0f10c8731shiqian// modification, are permitted provided that the following conditions are
64b6829f0d28990dd645e16386eb226d0f10c8731shiqian// met:
74b6829f0d28990dd645e16386eb226d0f10c8731shiqian//
84b6829f0d28990dd645e16386eb226d0f10c8731shiqian//     * Redistributions of source code must retain the above copyright
94b6829f0d28990dd645e16386eb226d0f10c8731shiqian// notice, this list of conditions and the following disclaimer.
104b6829f0d28990dd645e16386eb226d0f10c8731shiqian//     * Redistributions in binary form must reproduce the above
114b6829f0d28990dd645e16386eb226d0f10c8731shiqian// copyright notice, this list of conditions and the following disclaimer
124b6829f0d28990dd645e16386eb226d0f10c8731shiqian// in the documentation and/or other materials provided with the
134b6829f0d28990dd645e16386eb226d0f10c8731shiqian// distribution.
144b6829f0d28990dd645e16386eb226d0f10c8731shiqian//     * Neither the name of Google Inc. nor the names of its
154b6829f0d28990dd645e16386eb226d0f10c8731shiqian// contributors may be used to endorse or promote products derived from
164b6829f0d28990dd645e16386eb226d0f10c8731shiqian// this software without specific prior written permission.
174b6829f0d28990dd645e16386eb226d0f10c8731shiqian//
184b6829f0d28990dd645e16386eb226d0f10c8731shiqian// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
194b6829f0d28990dd645e16386eb226d0f10c8731shiqian// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
204b6829f0d28990dd645e16386eb226d0f10c8731shiqian// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
214b6829f0d28990dd645e16386eb226d0f10c8731shiqian// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
224b6829f0d28990dd645e16386eb226d0f10c8731shiqian// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
234b6829f0d28990dd645e16386eb226d0f10c8731shiqian// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
244b6829f0d28990dd645e16386eb226d0f10c8731shiqian// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
254b6829f0d28990dd645e16386eb226d0f10c8731shiqian// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
264b6829f0d28990dd645e16386eb226d0f10c8731shiqian// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
274b6829f0d28990dd645e16386eb226d0f10c8731shiqian// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
284b6829f0d28990dd645e16386eb226d0f10c8731shiqian// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
294b6829f0d28990dd645e16386eb226d0f10c8731shiqian
304b6829f0d28990dd645e16386eb226d0f10c8731shiqian// Tests that a Google Test program that has no test defined can run
314b6829f0d28990dd645e16386eb226d0f10c8731shiqian// successfully.
324b6829f0d28990dd645e16386eb226d0f10c8731shiqian//
334b6829f0d28990dd645e16386eb226d0f10c8731shiqian// Author: wan@google.com (Zhanyong Wan)
344b6829f0d28990dd645e16386eb226d0f10c8731shiqian
352620c79810d4741922e9fa89050c0af564994f24zhanyong.wan#include "gtest/gtest.h"
364b6829f0d28990dd645e16386eb226d0f10c8731shiqian
374b6829f0d28990dd645e16386eb226d0f10c8731shiqianint main(int argc, char **argv) {
384b6829f0d28990dd645e16386eb226d0f10c8731shiqian  testing::InitGoogleTest(&argc, argv);
394b6829f0d28990dd645e16386eb226d0f10c8731shiqian
404b6829f0d28990dd645e16386eb226d0f10c8731shiqian  // An ad-hoc assertion outside of all tests.
414b6829f0d28990dd645e16386eb226d0f10c8731shiqian  //
4263b4f32b442c767ebe54ec66aed8b65d9c0b6f5ezhanyong.wan  // This serves three purposes:
434b6829f0d28990dd645e16386eb226d0f10c8731shiqian  //
444b6829f0d28990dd645e16386eb226d0f10c8731shiqian  // 1. It verifies that an ad-hoc assertion can be executed even if
454b6829f0d28990dd645e16386eb226d0f10c8731shiqian  //    no test is defined.
4663b4f32b442c767ebe54ec66aed8b65d9c0b6f5ezhanyong.wan  // 2. It verifies that a failed ad-hoc assertion causes the test
4763b4f32b442c767ebe54ec66aed8b65d9c0b6f5ezhanyong.wan  //    program to fail.
4863b4f32b442c767ebe54ec66aed8b65d9c0b6f5ezhanyong.wan  // 3. We had a bug where the XML output won't be generated if an
494b6829f0d28990dd645e16386eb226d0f10c8731shiqian  //    assertion is executed before RUN_ALL_TESTS() is called, even
504b6829f0d28990dd645e16386eb226d0f10c8731shiqian  //    though --gtest_output=xml is specified.  This makes sure the
514b6829f0d28990dd645e16386eb226d0f10c8731shiqian  //    bug is fixed and doesn't regress.
5263b4f32b442c767ebe54ec66aed8b65d9c0b6f5ezhanyong.wan  EXPECT_EQ(1, 2);
534b6829f0d28990dd645e16386eb226d0f10c8731shiqian
5463b4f32b442c767ebe54ec66aed8b65d9c0b6f5ezhanyong.wan  // The above EXPECT_EQ() should cause RUN_ALL_TESTS() to return non-zero.
5563b4f32b442c767ebe54ec66aed8b65d9c0b6f5ezhanyong.wan  return RUN_ALL_TESTS() ? 0 : 1;
564b6829f0d28990dd645e16386eb226d0f10c8731shiqian}
57