Blame src/utilities_unittest.cc

Packit 18d29c
// Copyright (c) 2008, Google Inc.
Packit 18d29c
// All rights reserved.
Packit 18d29c
//
Packit 18d29c
// Redistribution and use in source and binary forms, with or without
Packit 18d29c
// modification, are permitted provided that the following conditions are
Packit 18d29c
// met:
Packit 18d29c
//
Packit 18d29c
//     * Redistributions of source code must retain the above copyright
Packit 18d29c
// notice, this list of conditions and the following disclaimer.
Packit 18d29c
//     * Redistributions in binary form must reproduce the above
Packit 18d29c
// copyright notice, this list of conditions and the following disclaimer
Packit 18d29c
// in the documentation and/or other materials provided with the
Packit 18d29c
// distribution.
Packit 18d29c
//     * Neither the name of Google Inc. nor the names of its
Packit 18d29c
// contributors may be used to endorse or promote products derived from
Packit 18d29c
// this software without specific prior written permission.
Packit 18d29c
//
Packit 18d29c
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 18d29c
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 18d29c
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Packit 18d29c
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
Packit 18d29c
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
Packit 18d29c
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Packit 18d29c
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit 18d29c
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit 18d29c
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit 18d29c
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 18d29c
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 18d29c
//
Packit 18d29c
// Author: Shinichiro Hamaji
Packit 18d29c
#include "utilities.h"
Packit 18d29c
#include "googletest.h"
Packit 18d29c
#include "glog/logging.h"
Packit 18d29c
Packit 18d29c
#ifdef HAVE_LIB_GFLAGS
Packit 18d29c
#include <gflags/gflags.h>
Packit 18d29c
using namespace GFLAGS_NAMESPACE;
Packit 18d29c
#endif
Packit 18d29c
Packit 18d29c
using namespace GOOGLE_NAMESPACE;
Packit 18d29c
Packit 18d29c
TEST(utilities, sync_val_compare_and_swap) {
Packit 18d29c
  bool now_entering = false;
Packit 18d29c
  EXPECT_FALSE(sync_val_compare_and_swap(&now_entering, false, true));
Packit 18d29c
  EXPECT_TRUE(sync_val_compare_and_swap(&now_entering, false, true));
Packit 18d29c
  EXPECT_TRUE(sync_val_compare_and_swap(&now_entering, false, true));
Packit 18d29c
}
Packit 18d29c
Packit 18d29c
TEST(utilities, InitGoogleLoggingDeathTest) {
Packit 18d29c
  ASSERT_DEATH(InitGoogleLogging("foobar"), "");
Packit 18d29c
}
Packit 18d29c
Packit 18d29c
int main(int argc, char **argv) {
Packit 18d29c
  InitGoogleLogging(argv[0]);
Packit 18d29c
  InitGoogleTest(&argc, argv);
Packit 18d29c
Packit 18d29c
  CHECK_EQ(RUN_ALL_TESTS(), 0);
Packit 18d29c
}