// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "views/events/event.h"

#include "base/logging.h"
#include "ui/aura/event.h"

namespace views {

////////////////////////////////////////////////////////////////////////////////
// LocatedEvent, protected:

LocatedEvent::LocatedEvent(const NativeEvent& native_event)
    : Event(native_event, native_event->type(), native_event->flags()),
      location_(static_cast<aura::LocatedEvent*>(native_event)->location()) {
}

////////////////////////////////////////////////////////////////////////////////
// KeyEvent, public:

KeyEvent::KeyEvent(const NativeEvent& native_event)
    : Event(native_event, native_event->type(), native_event->flags()),
      key_code_(static_cast<aura::KeyEvent*>(native_event)->key_code()),
      character_(GetCharacterFromKeyCode(key_code_, flags())),
      unmodified_character_(0) {
}

uint16 KeyEvent::GetCharacter() const {
  return character_;
}

uint16 KeyEvent::GetUnmodifiedCharacter() const {
  return unmodified_character_;
}

////////////////////////////////////////////////////////////////////////////////
// MouseWheelEvent, public:

MouseWheelEvent::MouseWheelEvent(const NativeEvent& native_event)
    : MouseEvent(native_event),
      offset_(ui::GetMouseWheelOffset(native_event->native_event())) {
}

}  // namespace views

// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "views/events/event.h"

#include "base/logging.h"
#include "ui/aura/event.h"

namespace views {

////////////////////////////////////////////////////////////////////////////////
// LocatedEvent, protected:

LocatedEvent::LocatedEvent(const NativeEvent& native_event)
    : Event(native_event, native_event->type(), native_event->flags()),
      location_(static_cast<aura::LocatedEvent*>(native_event)->location()) {
}

////////////////////////////////////////////////////////////////////////////////
// KeyEvent, public:

KeyEvent::KeyEvent(const NativeEvent& native_event)
    : Event(native_event, native_event->type(), native_event->flags()),
      key_code_(static_cast<aura::KeyEvent*>(native_event)->key_code()),
      character_(GetCharacterFromKeyCode(key_code_, flags())),
      unmodified_character_(0) {
}

uint16 KeyEvent::GetCharacter() const {
  return character_;
}

uint16 KeyEvent::GetUnmodifiedCharacter() const {
  if (unmodified_character_)
    return unmodified_character_;

  return GetCharacterFromKeyCode(key_code_, flags() & ui::EF_SHIFT_DOWN);
}

////////////////////////////////////////////////////////////////////////////////
// MouseWheelEvent, public:

MouseWheelEvent::MouseWheelEvent(const NativeEvent& native_event)
    : MouseEvent(native_event),
      offset_(ui::GetMouseWheelOffset(native_event->native_event())) {
}

}  // namespace views

Fix the KeyEvent unit test failure due to the aura implementation of GetUnmodifiedCharacter().

BUG=99129
TEST=NONE

Review URL: http://codereview.chromium.org/8286006

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@105549 0039d316-1c4b-4281-b951-d872f2087c98


// Nikita Kouevda
// 2013/11/04

#include <iostream>

#include "prime.hpp"

using namespace std;

int main(int argc, char *argv[]) {
  int i, n;
  char *endptr;

  if (argc < 2) {
    cerr << "usage: prime number ..." << endl;
    return 1;
  }

  for (i = 1; i < argc; ++i) {
    n = strtol(argv[i], &endptr, 10);

    if (*endptr) {
      cerr << "prime: illegal argument: " << argv[i] << endl;
      continue;
    }

    cout << argv[i] << " is";

    if (!isPrime(n)) {
      cout << " not";
    }

    cout << " prime" << endl;
  }

  return 0;
}

// Nikita Kouevda
// 2013/11/04

#include <cstdlib>
#include <iostream>

#include "prime.hpp"

using namespace std;

int main(int argc, char *argv[]) {
  int i, n;
  char *endptr;

  if (argc < 2) {
    cerr << "usage: prime number ..." << endl;
    return 1;
  }

  for (i = 1; i < argc; ++i) {
    n = strtol(argv[i], &endptr, 10);

    if (*endptr) {
      cerr << "prime: illegal argument: " << argv[i] << endl;
      continue;
    }

    cout << argv[i] << " is";

    if (!isPrime(n)) {
      cout << " not";
    }

    cout << " prime" << endl;
  }

  return 0;
}

Include cstdlib just in case.

Include cstdlib just in case.


#include <curses.h>
#include <iostream>
#include "mopViewer.h"
#include <string>

int main() {
        mopViewer mopViewers;
        std::string fileName;
        int skipCount;
        std::cout << "Enter the MopFile Name (No need to use extension/location: ";
        std::cin >> fileName;
        std::cout << std::endl << "Enter Required Skip Count: ";
        std::cin >> skipCount;
        mopViewers.selectGame(fileName, skipCount);
        return 0;
}

#include <curses.h>
#include <iostream>
#include "mopViewer.h"
#include <string>

int main() {
        mopViewer mopViewers;
        std::string fileName;
        int skipCount;
        std::cout << "Enter the MopFile Name (No need to use extension/location: ";
        std::cin >> fileName;
        std::cout << std::endl << "Enter Required Skip Count: ";
        std::cin >> skipCount;
        if(skipCount < 0){
        	std::cout << "Skip Count Must be 0 or larger" << std::endl;
        	std::cout << "Exiting Now!" << std::endl;
        	return 0;
        }
        mopViewers.selectGame(fileName, skipCount);
        return 0;
}

Add some minor error checking

Add some minor error checking


#include <catch.hpp>

#include <chi/Context.hpp>
#include <chi/DataType.hpp>
#include <chi/LangModule.hpp>
#include <chi/NodeType.hpp>
#include <chi/Support/Result.hpp>
#include <chi/Fetcher/Fetcher.hpp>

#include <llvm/IR/DerivedTypes.h>

using namespace chi;
namespace fs = boost::filesystem;

TEST_CASE("Contexts can fetch remote modules", "[Context]") {
	// create a temporary directory for a workspace
	fs::path workspaceDir =
	    boost::filesystem::temp_directory_path() / fs::unique_path();  // this is a tmp file
	fs::create_directories(workspaceDir);

	// create the .chigraphworkspace file
	{ fs::ofstream stream{workspaceDir / ".chigraphworkspace"}; }

	auto res = fetchModule(workspaceDir, "github.com/russelltg/hellochigraph/hello/main", true);
	REQUIRE(res.dump() == "");

	REQUIRE(fs::is_directory(workspaceDir / "src" / "github.com" / "russelltg" / "hellochigraph"));
}

#include <catch.hpp>

#include <chi/Context.hpp>
#include <chi/DataType.hpp>
#include <chi/LangModule.hpp>
#include <chi/NodeType.hpp>
#include <chi/Support/Result.hpp>
#include <chi/Fetcher/Fetcher.hpp>

#include <llvm/IR/DerivedTypes.h>

using namespace chi;
namespace fs = boost::filesystem;

TEST_CASE("Contexts can fetch remote modules", "[Context]") {
	// create a temporary directory for a workspace
	fs::path workspaceDir =
	    boost::filesystem::temp_directory_path() / fs::unique_path();  // this is a tmp file
	fs::create_directories(workspaceDir);

	// create the .chigraphworkspace file
	{ fs::ofstream stream{workspaceDir / ".chigraphworkspace"}; }

	auto res = fetchModule(workspaceDir, "github.com/chigraph/hellochigraph/hello/main", true);
	REQUIRE(res.dump() == "");

	REQUIRE(fs::is_directory(workspaceDir / "src" / "github.com" / "chigraph" / "hellochigraph"));
}

Fix test because repo moved

Fix test because repo moved


#include "includes/SWidgets/SSearchArea.hpp"
#include "includes/SMainWindow.hpp"

SSearchArea::SSearchArea(const QIcon & icon, SMainWindow * parent) :
	QLineEdit(parent),
	m_parent(parent),
	m_icon(icon)
{
	setTextMargins(18, 0, 0, 0);
	connect(this, &SSearchArea::returnPressed, this, &SSearchArea::loadSearch);
	setClearButtonEnabled(true);
}

SSearchArea::~SSearchArea()
{
	// Empty
}

void SSearchArea::paintEvent(QPaintEvent * event)
{
	// Paint the shearch icon before the line edit
	QLineEdit::paintEvent(event);
	QPainter painter(this);
	m_icon.paint(&painter, (height() - 16) / 2, (height() - 16) / 2, 16, 16);
}

void SSearchArea::loadSearch()
{
	// Load the search
	// TODO: fix the bug when we seach with "+"
	QString search{ text() };
	search.replace(" ", "+");
	m_parent->currentPage()->load(QUrl("http://www.google.com/search?q=" + search));
}

#include "includes/SWidgets/SSearchArea.hpp"
#include "includes/SMainWindow.hpp"

SSearchArea::SSearchArea(const QIcon & icon, SMainWindow * parent) :
	QLineEdit(parent),
	m_parent(parent),
	m_icon(icon)
{
	setTextMargins(18, 0, 0, 0);
	connect(this, &SSearchArea::returnPressed, this, &SSearchArea::loadSearch);
	setClearButtonEnabled(true);

    setStyleSheet("QLineEdit{ border: none; background-color: #FFFFFF; }");
}

SSearchArea::~SSearchArea()
{
	// Empty
}

void SSearchArea::paintEvent(QPaintEvent * event)
{
	// Paint the shearch icon before the line edit
	QLineEdit::paintEvent(event);
	QPainter painter(this);
	m_icon.paint(&painter, (height() - 16) / 2, (height() - 16) / 2, 16, 16);
}

void SSearchArea::loadSearch()
{
	// Load the search
	// TODO: fix the bug when we seach with "+"
	QString search{ text() };
	search.replace(" ", "+");
	m_parent->currentPage()->load(QUrl("http://www.google.com/search?q=" + search));
}

UPDATE the style of the search bar

UPDATE the style of the search bar


#include "Course.h"

#include <iostream>

using namespace std;

int main() {
  // test instantiation of a Course object.
  cout << "Testing instantiation of a Course object:" << endl;
  Course course("test-0");
  cout << "Created " << course.getName() << endl;

  cout << "All Assignments:" << endl;

  for (auto it : course.assignments) {
    cout << it.first << "=>" << it.second << '\n';
  }
}

#include "Course.h"

#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  if (remove("test-0.sqlite") != 0) {
    cout << "Error with deletion of database file\n";
  } else {
    cout << "Database file successfully deleted\n";
  }

  // test instantiation of a Course object.
  cout << "Testing instantiation of a Course object:" << endl;
  Course course("test-0");
  cout << "Created " << course.getName() << endl;

  cout << "All Assignments:" << endl;

  for (auto it : course.assignments) {
    cout << it.first << "=>" << it.second << '\n';
  }
}

Remove database file before Course instantiation


// Copyright 2014 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd

#include "media/base/closure_thread.h"

namespace media {

ClosureThread::ClosureThread(
    const std::string& name_prefix,
    const base::Closure& task)
    : base::SimpleThread(name_prefix), task_(task) {}

ClosureThread::~ClosureThread() {
  if (!HasBeenJoined())
    Join();
}

void ClosureThread::Run() { task_.Run(); }

}  // namespace media

// Copyright 2014 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd

#include "media/base/closure_thread.h"

namespace media {

ClosureThread::ClosureThread(
    const std::string& name_prefix,
    const base::Closure& task)
    : base::SimpleThread(name_prefix), task_(task) {}

ClosureThread::~ClosureThread() {
  if (HasBeenStarted() && !HasBeenJoined())
    Join();
}

void ClosureThread::Run() { task_.Run(); }

}  // namespace media

Fix ClosureThread unittest crash in release build

The crash happens if the thread is created but never started. An
improper Join triggered the crash. We should not call Join if the thread
is not started.

Change-Id: Icace740889089d3b2e15cf6c76c2b0887eb84535


#include "catch.hpp"
#include "library.hpp"
#include <functional>

namespace {
#ifdef _WIN32
	const std::string testlibname("testlib.dll");
#else
	const std::string testlibname("libtestlib.so");
#endif
}
SCENARIO("Loading a shared library")
{
	GIVEN("library is loaded successfully")
	{
		loader::Library lib(testlibname);
		REQUIRE(lib.loaded() == true);

		WHEN("symbol is loaded successfully")
		{
			auto testfunc = lib.func<int(int)>("test");

			THEN("function pointed by symbol is called successfully")
			{
				REQUIRE(testfunc(3) == 3);
			}
		}
	}
}

SCENARIO("Loading non-existent library")
{
	GIVEN("a non-existing library name")
	{
		WHEN("an attempt is made to load the library")
		{
			loader::Library lib("not there");
			THEN("library is not loaded")
			{
				REQUIRE(lib.loaded() == false);
			}
			THEN("symbol loads return null")
			{
				REQUIRE(lib.func<int(int)>("test") == nullptr);
			}
		}
	}
}

#include "catch.hpp"
#include "library.hpp"
#include <functional>

namespace {
#ifdef _WIN32
	const std::string testlibname("testlib.dll");
#else
	const std::string testlibname("libtestlib.so");
#endif
}
SCENARIO("Loading a shared library")
{
	GIVEN("library is loaded successfully")
	{
		loader::Library lib(testlibname);
		REQUIRE(lib.loaded() == true);

		WHEN("symbol is loaded successfully")
		{
			auto testfunc = lib.func<int(int)>("test");

			THEN("function pointed by symbol is called successfully")
			{
				REQUIRE(testfunc(3) == 3);
			}
		}
	}
}

SCENARIO("Loading non-existent library")
{
	GIVEN("a non-existing library name")
	{
		WHEN("an attempt is made to load the library")
		{
			loader::Library lib("not there");
			THEN("library is not loaded")
			{
				REQUIRE(lib.loaded() == false);
			}
			THEN("symbol loads return null")
			{
				REQUIRE(!lib.func<int(int)>("test"));
			}
		}
	}
}

Use bool operator instead of null-check for std::function


#include "tcframe/aggregator.hpp"
#include "tcframe/evaluator.hpp"
#include "tcframe/generator.hpp"
#include "tcframe/grader.hpp"
#include "tcframe/os.hpp"
#include "tcframe/runner.hpp"
#include "tcframe/spec.hpp"

#include __TCFRAME_SPEC_FILE__

using tcframe::Runner;

int main(int argc, char* argv[]) {
    Runner<ProblemSpec> runner(
            __TCFRAME_SPEC_FILE__,
            new TestSpec(),
            new SimpleLoggerEngine(),
            new OperatingSystem(),
            new RunnerLoggerFactory(),
            new GraderLoggerFactory(),
            new GeneratorFactory(),
            new GraderFactory(),
            new EvaluatorRegistry(new EvaluatorHelperRegistry()),
            new AggregatorRegistry());

    return runner.run(argc, argv);
}

#include "tcframe/runner.hpp"

#include __TCFRAME_SPEC_FILE__

using tcframe::Runner;

int main(int argc, char* argv[]) {
    Runner<ProblemSpec> runner(
            __TCFRAME_SPEC_FILE__,
            new TestSpec(),
            new SimpleLoggerEngine(),
            new OperatingSystem(),
            new RunnerLoggerFactory(),
            new GraderLoggerFactory(),
            new GeneratorFactory(),
            new GraderFactory(),
            new EvaluatorRegistry(new EvaluatorHelperRegistry()),
            new AggregatorRegistry());

    return runner.run(argc, argv);
}

Use only single header in main file

Use only single header in main file

So that we can precompile it.


#include "include/vortex.hpp"
#include "include/app.hpp"
#include "include/logger.hpp"

#include "common_def_priv.hpp"

#include <memory>

namespace vtx
{
	struct PRIVATE_STRUCT_NAME(Vortex)
	{
		std::unique_ptr<Application> m_application;
	};

	void Vortex::setApplication(Application &&app)
	{
		m_private->m_application.reset(&app);
	}

	Vortex::Vortex() : m_private{ new PRIVATE_STRUCT_NAME(Vortex) }
	{
		Logger::createInstance();
		ldebug() << "Vortex library instance created" << endline();
	}

	Vortex::~Vortex()
	{
		ldebug() << "Vortex library instance beeing deleted" << endline();
		DELETE_PRIVATE_MPRIVATE_PIMPL(Vortex);
		ldebug() << "Vortex library instance deleted" << endline();
	}

	void Vortex::initialize()
	{
		linfo() << "Initializing Vortex library..." << endline();
	}

	void Vortex::deinitialize()
	{
		linfo() << "Deinitializing Vortex library..." << endline();
	}
}

#include "include/vortex.hpp"
#include "include/app.hpp"
#include "include/logger.hpp"

#include "common_def_priv.hpp"

#include <memory>

namespace vtx
{
	struct PRIVATE_STRUCT_NAME(Vortex)
	{
		std::unique_ptr<Application> m_application;
	};

	void Vortex::setApplication(Application &&app)
	{
		m_private->m_application.reset(&app);
	}

	Vortex::Vortex() : m_private{ new PRIVATE_STRUCT_NAME(Vortex) }
	{
		Logger::createInstance();
		ldebug() << "Vortex library instance created" << endline();
	}

	Vortex::~Vortex()
	{
		ldebug() << "Vortex library instance beeing deleted" << endline();
		DELETE_PRIVATE_MPRIVATE_PIMPL(Vortex);
		ldebug() << "Vortex library instance deleted" << endline();
	}

	void Vortex::initialize()
	{
		linfo() << "Initializing Vortex library..." << endline();
		if (!m_private->m_application) {
			lerror() << "No application set" << endline();
			return;
		}
	}

	void Vortex::deinitialize()
	{
		linfo() << "Deinitializing Vortex library..." << endline();
	}
}

Check that an application has been set

Check that an application has been set


#include <iostream>
#include "Room.h"
#include "XMLParser.cpp"

int main() {
	Room current_room;

	current_room.loadFromXMLFile("Speelveld1.0.xml");
	current_room.loadMovesFromXMLFile("Bewegingen1.0.xml");

	current_room.executeAllMoves("HuidigSpeelveld.txt", "ResterendeBewegingen.txt");

	return 0;
}

#include <iostream>
#include "Room.h"
#include "XMLParser.cpp"

int main() {
	Room current_room;

	current_room.loadFromXMLFile("xmlfiles/Speelveld1.0.xml");
	current_room.loadMovesFromXMLFile("xmlfiles/Bewegingen1.0.xml");

	current_room.executeAllMoves("HuidigSpeelveld.txt", "ResterendeBewegingen.txt");

	return 0;
}

Set xml files to moved files

Set xml files to moved files


#include <QCoreApplication>
#include "Network/NetworkBalancer.hpp"

int main(int argc, char *argv[])
{
    Network::NetworkBalancer aBalancerExample = Network::NetworkBalancer();

    return( 0 );
}

#include <QCoreApplication>
#include "Tests/Unit/Network/TestNetworkBalancer.hpp"

#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/ui/text/TestRunner.h>

using namespace std;
using namespace CppUnit;

int main(int argc, char *argv[])
{
    // Initialice test runner
    CppUnit::TextUi::TestRunner aRunner;
    // Add network balancer test suite
    aRunner.addTest( TestNetworkBalancer::suite() );
    // Start test runner
    aRunner.run();

    return( 0 );
}

Test Runner added to check the NetworkBalancer class


/**********************************************************************
 *
 * GEOS - Geometry Engine Open Source
 * http://geos.refractions.net
 *
 * Copyright (C) 2001-2002 Vivid Solutions Inc.
 *
 * This is free software; you can redistribute and/or modify it under
 * the terms of the GNU Lesser General Public Licence as published
 * by the Free Software Foundation.
 * See the COPYING file for more information.
 *
 **********************************************************************/

#include <geos/geom/Coordinate.h>
#include <geos/platform.h> // for ISNAN

#include <sstream>
#include <string>

#ifndef GEOS_INLINE
# include <geos/geom/Coordinate.inl>
#endif

using namespace std;

namespace geos {
namespace geom { // geos::geom

Coordinate Coordinate::nullCoord=Coordinate(DoubleNotANumber,DoubleNotANumber,DoubleNotANumber);

Coordinate&
Coordinate::getNull()
{
	return nullCoord;
}

string
Coordinate::toString() const
{
	ostringstream s;
	s<<*this;
	return s.str();
}

std::ostream& operator<< (std::ostream& os, const Coordinate& c)
{
	if ( ISNAN(c.z) )
	{
		os << c.x << " " << c.y;
	} else {
		os << c.x << " " << c.y << " " << c.z;
	}
	return os;
}

} // namespace geos::geom
} // namespace geos

/**********************************************************************
 *
 * GEOS - Geometry Engine Open Source
 * http://geos.refractions.net
 *
 * Copyright (C) 2001-2002 Vivid Solutions Inc.
 *
 * This is free software; you can redistribute and/or modify it under
 * the terms of the GNU Lesser General Public Licence as published
 * by the Free Software Foundation.
 * See the COPYING file for more information.
 *
 **********************************************************************/

#include <geos/geom/Coordinate.h>
#include <geos/platform.h> // for ISNAN

#include <sstream>
#include <string>
#include <iomanip>

#ifndef GEOS_INLINE
# include <geos/geom/Coordinate.inl>
#endif

using namespace std;

namespace geos {
namespace geom { // geos::geom

Coordinate Coordinate::nullCoord=Coordinate(DoubleNotANumber,DoubleNotANumber,DoubleNotANumber);

Coordinate&
Coordinate::getNull()
{
	return nullCoord;
}

string
Coordinate::toString() const
{
	ostringstream s;
	s << std::setprecision(17) << *this;
	return s.str();
}

std::ostream& operator<< (std::ostream& os, const Coordinate& c)
{
	if ( ISNAN(c.z) )
	{
		os << c.x << " " << c.y;
	} else {
		os << c.x << " " << c.y << " " << c.z;
	}
	return os;
}

} // namespace geos::geom
} // namespace geos

Use 18 significant digits for TopologyException point coordinates

git-svn-id: 6c2b1bd10c324c49ea9d9e6e31006a80e70507cb@3522 5242fede-7e19-0410-aef8-94bd7d2200fb


#include "glfwApp.h"
#include "linuxPlatform.h"
#include "log.h"
#include "map.h"
#include <memory>
#include <signal.h>
#include <stdlib.h>

using namespace Tangram;

int main(int argc, char* argv[]) {

    auto platform = std::make_shared<LinuxPlatform>();

    // Create the windowed app.
    GlfwApp::create(platform, sceneUrl.string(), 1024, 768);

    GlfwApp::parseArgs(argc, argv);

    Url baseUrl = Url(GlfwApp::sceneFile).resolved("file:///");
    Url sceneUrl = Url(inputString).resolved(baseUrl);
    GlfwApp::sceneFile = sceneUrl.string();

    // Give it a chance to shutdown cleanly on CTRL-C
    signal(SIGINT, &GlfwApp::stop);

    // Loop until the user closes the window
    GlfwApp::run();

    // Clean up.
    GlfwApp::destroy();

}

#include "glfwApp.h"
#include "linuxPlatform.h"
#include "log.h"
#include "map.h"
#include <memory>
#include <limits.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>

using namespace Tangram;

int main(int argc, char* argv[]) {

    auto platform = std::make_shared<LinuxPlatform>();

    // Create the windowed app.
    GlfwApp::create(platform, 1024, 768);

    GlfwApp::parseArgs(argc, argv);

    // Resolve the input path against the current directory.
    Url baseUrl("file:///");
    char pathBuffer[PATH_MAX] = {0};
    if (getcwd(pathBuffer, PATH_MAX) != nullptr) {
        baseUrl = Url(std::string(pathBuffer) + "/").resolved(baseUrl);
    }

    LOG("Base URL: %s", baseUrl.string().c_str());

    Url sceneUrl = Url(GlfwApp::sceneFile).resolved(baseUrl);
    GlfwApp::sceneFile = sceneUrl.string();

    // Give it a chance to shutdown cleanly on CTRL-C
    signal(SIGINT, &GlfwApp::stop);

    // Loop until the user closes the window
    GlfwApp::run();

    // Clean up.
    GlfwApp::destroy();

}

Fix linux base URL for demo executable

Fix linux base URL for demo executable


// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "remoting/host/capturer.h"

namespace remoting {

Capturer::Capturer()
    : width_(0),
      height_(0),
      pixel_format_(PixelFormatInvalid),
      bytes_per_pixel_(0),
      bytes_per_row_(0),
      current_buffer_(0) {
}

Capturer::~Capturer() {
}

void Capturer::GetDirtyRects(DirtyRects* rects) const {
  *rects = dirty_rects_;
}

int Capturer::GetWidth() const {
  return width_;
}

int Capturer::GetHeight() const {
  return height_;
}

PixelFormat Capturer::GetPixelFormat() const {
  return pixel_format_;
}

void Capturer::InvalidateRect(gfx::Rect dirty_rect) {
  inval_rects_.push_back(dirty_rect);
}

void Capturer::FinishCapture(Task* done_task) {
  done_task->Run();
  delete done_task;

  // Select the next buffer to be the current buffer.
  current_buffer_ = ++current_buffer_ % kNumBuffers;
}

}  // namespace remoting

// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "remoting/host/capturer.h"

namespace remoting {

Capturer::Capturer()
    : width_(0),
      height_(0),
      pixel_format_(PixelFormatInvalid),
      bytes_per_pixel_(0),
      bytes_per_row_(0),
      current_buffer_(0) {
}

Capturer::~Capturer() {
}

void Capturer::GetDirtyRects(DirtyRects* rects) const {
  *rects = dirty_rects_;
}

int Capturer::GetWidth() const {
  return width_;
}

int Capturer::GetHeight() const {
  return height_;
}

PixelFormat Capturer::GetPixelFormat() const {
  return pixel_format_;
}

void Capturer::InvalidateRect(gfx::Rect dirty_rect) {
  inval_rects_.push_back(dirty_rect);
}

void Capturer::FinishCapture(Task* done_task) {
  done_task->Run();
  delete done_task;

  // Select the next buffer to be the current buffer.
  current_buffer_ = (current_buffer_ + 1) % kNumBuffers;
}

}  // namespace remoting

Coverity: Fix undefined assignment evaluation order in remoting::Capturer::FinishCapture.

CID=10878
BUG=none
TEST=builds

Review URL: http://codereview.chromium.org/2847010

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@50012 0039d316-1c4b-4281-b951-d872f2087c98


#include "test.h"
#include "lcg.h"
#include <cassert>
#include <limits>

template <class T>
void boxmuller(T* data, size_t count) {
	assert(count % 2 == 0);
	static const T twopi = T(2.0 * 3.14159265358979323846);

	LCG r;
	for (size_t i = 0; i < count; i += 2) {
        T u1, u2;
        do {
            u1 = r();
            u2 = r();
        } while (u1 <= std::numeric_limits<T>::min());

		T radius = std::sqrt(-2 * std::log(u1));
		T theta = twopi * u2;
		data[i    ] = radius * std::cos(theta);
		data[i + 1] = radius * std::sin(theta);
	}
}

static void normaldistf_boxmuller(float* data, size_t count) {
    boxmuller(data, count);
}

static void normaldist_boxmuller(double* data, size_t count) {
    boxmuller(data, count);
}

REGISTER_TEST(boxmuller);

#include "test.h"
#include "lcg.h"
#include <cassert>
#include <limits>
#include <algorithm>

template <class T>
void boxmuller(T* data, size_t count) {
	assert(count % 2 == 0);
	static const T twopi = T(2.0 * 3.14159265358979323846);

	LCG r;
	for (size_t i = 0; i < count; i += 2) {
        T u1, u2;
        u1 = r();
        u2 = r();
        u1  = std::max(u1, std::numeric_limits<T>::min());

		T radius = std::sqrt(-2 * std::log(u1));
		T theta = twopi * u2;
		data[i    ] = radius * std::cos(theta);
		data[i + 1] = radius * std::sin(theta);
	}
}

static void normaldistf_boxmuller(float* data, size_t count) {
    boxmuller(data, count);
}

static void normaldist_boxmuller(double* data, size_t count) {
    boxmuller(data, count);
}

REGISTER_TEST(boxmuller);

Use minimum instead of do-while in Box-Muller


#include <QCoreApplication>
#include <QTest>
#include "test_engine.hpp"

int main(int argc, char *argv[]) {
    QCoreApplication a(argc, argv);
    QTest::qExec( new Test_Engine, argc, argv );

    return a.exec();
}

#include <QApplication>
#include <QTest>
#include "test_engine.hpp"

int main( int argc, char *argv[] ) {
    QApplication a( argc, argv );
    QTest::qExec( new Test_Engine, argc, argv );

    return a.exec();
}

Replace QCoreApplication to QAppliation for QWidget work.


#include <tiramisu/tiramisu.h>

using namespace tiramisu;

void gen(std::string name, int size, int val0, int val1)
{
    tiramisu::init(name);

    tiramisu::function *function0 = global::get_implicit_function();

    tiramisu::constant N("N", tiramisu::expr((int32_t) size), p_int32, true, NULL, 0, &function0);

    tiramisu::var i("i", 0, 10), j("j", 0, 10);
    tiramisu::var i0("i0"), j0("j0"), i1("i1"), j1("j1");

    tiramisu::computation S0(tiramisu::expr((uint8_t) (val0 + val1)), i, j);

    //S0.tile(i, j, 2, 2, i0, j0, i1, j1);
    S0.tag_parallel_level(i);

    tiramisu::buffer buf0("buf0", {size, size}, tiramisu::p_uint8, a_output, &function0);
    S0.store_in(&buf0, {i ,j});

    function0.codegen({&buf0}, "build/generated_fct_test_114.o");
}

int main(int argc, char **argv)
{
    gen("func", 10, 3, 4);

    return 0;
}

#include <tiramisu/tiramisu.h>

using namespace tiramisu;

void gen(std::string name, int size, int val0, int val1)
{
    tiramisu::init(name);

    tiramisu::function *function0 = global::get_implicit_function();

    tiramisu::constant N("N", tiramisu::expr((int32_t) size), p_int32, true, NULL, 0, function0);

    tiramisu::var i("i", 0, 10), j("j", 0, 10);
    tiramisu::var i0("i0"), j0("j0"), i1("i1"), j1("j1");

    tiramisu::computation S0(tiramisu::expr((uint8_t) (val0 + val1)), i, j);

    //S0.tile(i, j, 2, 2, i0, j0, i1, j1);
    S0.tag_parallel_level(i);

    tiramisu::buffer buf0("buf0", {size, size}, tiramisu::p_uint8, a_output, function0);
    S0.store_in(&buf0, {i ,j});

    function0->codegen({&buf0}, "build/generated_fct_test_114.o");
}

int main(int argc, char **argv)
{
    gen("func", 10, 3, 4);

    return 0;
}

Add support for implicit function

Add support for implicit function


/*----------------------------------------*/
// Test sending messages from master.
//
// In this script, master sends a message (command = 0x01)
// with alternating 0s and 1s for each node on the bus.
//
/*----------------------------------------*/

#include <stdint.h>
#include <util/delay.h>

#include "MultidropMaster.h"
#include "MultidropDataUart.h"

#define NODE_COUNT 1

int main() {
  MultidropDataUart serial;
  serial.begin(9600);
	MultidropMaster master(&serial);

  uint8_t iteration = 1, i = 0;
  master.setNodeLength(NODE_COUNT);
  while(1) {

    master.startMessage(0x01, MultidropMaster::BROADCAST_ADDRESS, 1, true);

    // Send alternating 1s and 0s
    for (i = 0; i < NODE_COUNT; i++) {
      if ((i + iteration) % 2 == 0) {
        master.sendData(0x01);
      } else {
        master.sendData(0x00);
      }
    }

    master.finishMessage();

    iteration++;
    _delay_ms(1000);
  }
}

/*----------------------------------------*/
// Test sending messages from master.
//
// In this script, master sends a message (command = 0x01)
// with alternating 0s and 1s for each node on the bus.
//
/*----------------------------------------*/

#include <stdint.h>
#include <util/delay.h>

#include "MultidropMaster.h"
#include "MultidropDataUart.h"

#define NODE_COUNT 1

int main() {
  uint8_t iteration = 1, i = 0;

  MultidropDataUart serial;
	MultidropMaster master(&serial);

  serial.begin(9600);
  master.setNodeLength(NODE_COUNT);

  while(1) {
    master.startMessage(0x01, MultidropMaster::BROADCAST_ADDRESS, 1, true);

    // Send alternating 1s and 0s
    for (i = 0; i < NODE_COUNT; i++) {
      if ((i + iteration) % 2 == 0) {
        master.sendData(0x01);
      } else {
        master.sendData(0x00);
      }
    }

    master.finishMessage();

    iteration++;
    _delay_ms(1000);
  }
}

Rearrange code to be clearer

Rearrange code to be clearer


/*! \file PathToImage.cpp
 *  \author Jared Hoberock
 *  \brief Implementation of PathToImage class.
 */

#include "PathToImage.h"

void PathToImage
  ::evaluate(const PathSampler::Result &r,
             const PathSampler::HyperPoint &x,
             const Path &xPath,
             float &u,
             float &v) const
{
  if(r.mEyeLength == 0)
  {
    std::cerr << "PathToImage::evaluate(): Implement me!" << std::endl;
  } // end if
  else if(r.mEyeLength == 1)
  {
    // we need to invert the sensor function
    unsigned int endOfLightPath = xPath.getSubpathLengths().sum() - r.mLightLength;
    ::Vector w = xPath[endOfLightPath].mDg.getPoint();
    w -= xPath[0].mDg.getPoint();
    xPath[0].mSensor->invert(w, xPath[0].mDg,
                             u, v);
  } // end if
  else
  {
    // the first coordinate naturally corresponds to (u,v)
    u = x[0][0];
    v = x[0][1];
  } // end else
} // end PathToImage::evaluate()

void PathToImage
  ::operator()(const PathSampler::Result &r,
               const PathSampler::HyperPoint &x,
               const Path &xPath,
               float &u,
               float &v) const
{
  return evaluate(r,x,xPath,u,v);
} // end PathToImage::operator()()

/*! \file PathToImage.cpp
 *  \author Jared Hoberock
 *  \brief Implementation of PathToImage class.
 */

#include "PathToImage.h"

void PathToImage
  ::evaluate(const PathSampler::Result &r,
             const PathSampler::HyperPoint &x,
             const Path &xPath,
             float &u,
             float &v) const
{
  if(r.mEyeLength <= 1)
  {
    // we need to invert the sensor function
    unsigned int endOfLightPath = xPath.getSubpathLengths().sum() - r.mLightLength;
    ::Vector w = xPath[endOfLightPath].mDg.getPoint();
    w -= xPath[0].mDg.getPoint();
    xPath[0].mSensor->invert(w, xPath[0].mDg,
                             u, v);
  } // end if
  else
  {
    // the first coordinate naturally corresponds to (u,v)
    u = x[0][0];
    v = x[0][1];
  } // end else
} // end PathToImage::evaluate()

void PathToImage
  ::operator()(const PathSampler::Result &r,
               const PathSampler::HyperPoint &x,
               const Path &xPath,
               float &u,
               float &v) const
{
  return evaluate(r,x,xPath,u,v);
} // end PathToImage::operator()()

Allow mapping for paths with no eye subpath.

git-svn-id: eeeef91d721e48f02083ec31b1220ddf564a51e4@1055 3bb10773-34f4-0310-b88c-ec9d511ba0d9


#include <cmath>
#include "lights/light.h"
#include "material/blinn_phong.h"

BlinnPhong::BlinnPhong(const Colorf &diffuse, const Colorf &specular, float gloss)
	: diffuse(diffuse), specular(specular), gloss(gloss)
{}
Colorf BlinnPhong::shade(const Ray &r, const HitInfo &hitinfo, const LightCache &lights) const {
	Colorf illum;
	for (const auto &lit : lights){
		const auto &light = lit.second;
		if (light->is_ambient()){
			illum += diffuse * light->illuminate(hitinfo.point);
		}
		else {
			Vector l = -light->direction(hitinfo.point);
			Vector v = -r.d.normalized();
			Vector h = (l + v).normalized();
			//Normal may not be normalized due to translation into world space
			Normal n = hitinfo.normal.normalized();
			float dif = std::max(l.dot(n), 0.f);
			float spec = std::pow(std::max(n.dot(h), 0.f), gloss);
			illum += (diffuse * dif + specular * spec) * light->illuminate(hitinfo.point);
		}
	}
	illum.normalize();
	return illum;
}

#include <cmath>
#include "lights/light.h"
#include "material/blinn_phong.h"

BlinnPhong::BlinnPhong(const Colorf &diffuse, const Colorf &specular, float gloss)
	: diffuse(diffuse), specular(specular), gloss(gloss)
{}
Colorf BlinnPhong::shade(const Ray &r, const HitInfo &hitinfo, const LightCache &lights) const {
	Colorf illum;
	for (const auto &lit : lights){
		const auto &light = lit.second;
		if (light->is_ambient()){
			illum += diffuse * light->illuminate(hitinfo.point);
		}
		else {
			Vector l = -light->direction(hitinfo.point);
			Vector v = -r.d.normalized();
			Vector h = (l + v).normalized();
			//Normal may not be normalized due to translation into world space
			Normal n = hitinfo.normal.normalized();
			float dif = std::max(l.dot(n), 0.f);
			float spec = std::pow(std::max(n.dot(h), 0.f), gloss);
			illum += diffuse * dif * light->illuminate(hitinfo.point)
				+ specular * spec * light->illuminate(hitinfo.point);
		}
	}
	illum.normalize();
	return illum;
}

Fix some issue with coloring of specular highlights


/******************************************************
 * This is CIR-KIT 3rd robot control driver.
 * Author : Arita Yuta(Kyutech)
 ******************************************************/
#include "cirkit_unit03_driver.hpp"

#include <string>

int main(int argc, char** argv)
{
  ros::init(argc, argv, "cirkit_unit03_driver_node");
  ROS_INFO("cirkit unit03 robot driver for ROS.");

  ros::NodeHandle n {"~"};
  std::string imcs01_port {"/dev/urbtc0"};
  n.param<std::string>("imcs01_port", imcs01_port, imcs01_port);

  cirkit::CirkitUnit03Driver driver(std::move(imcs01_port), ros::NodeHandle {});
  driver.run();

  return 0;
}

/******************************************************
 * This is CIR-KIT 3rd robot control driver.
 * Author : Arita Yuta(Kyutech)
 ******************************************************/
#include "cirkit_unit03_driver.hpp"

#include <string>
#include <utility>

int main(int argc, char** argv)
{
  ros::init(argc, argv, "cirkit_unit03_driver_node");
  ROS_INFO("cirkit unit03 robot driver for ROS.");

  ros::NodeHandle n {"~"};
  std::string imcs01_port {"/dev/urbtc0"};
  n.param<std::string>("imcs01_port", imcs01_port, imcs01_port);

  cirkit::CirkitUnit03Driver driver(std::move(imcs01_port), ros::NodeHandle {});
  driver.run();

  return 0;
}

Add include file is utility

Add include file is utility

もしROSがutilityをインクルードしなくなってもコンパイルが通るように。
いやまあ、ありえないけど、こういう気遣いも大切かとおもう。


// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -main-file-name cxx-virtual-destructor-calls.cpp %s -o - -fprofile-instrument=clang | FileCheck %s

struct Member {
  ~Member();
};

struct A {
  virtual ~A();
};

struct B : A {
  Member m;
  virtual ~B();
};

// Base dtor counters and profile data
// CHECK: @__profc__ZN1BD2Ev = private global [1 x i64] zeroinitializer
// CHECK: @__profd__ZN1BD2Ev =

// Complete dtor counters and profile data must absent
// CHECK-NOT: @__profc__ZN1BD1Ev = private global [1 x i64] zeroinitializer
// CHECK-NOT: @__profd__ZN1BD1Ev =

// Deleting dtor counters and profile data must absent
// CHECK-NOT: @__profc__ZN1BD0Ev = private global [1 x i64] zeroinitializer
// CHECK-NOT: @__profd__ZN1BD0Ev =

B::~B() { }

// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -main-file-name cxx-virtual-destructor-calls.cpp %s -o - -fprofile-instrument=clang | FileCheck %s

struct Member {
  ~Member();
};

struct A {
  virtual ~A();
};

struct B : A {
  Member m;
  virtual ~B();
};

// Base dtor
// CHECK: @__profn__ZN1BD2Ev = private constant [9 x i8] c"_ZN1BD2Ev"

// Complete dtor must not be instrumented
// CHECK-NOT: @__profn__ZN1BD1Ev = private constant [9 x i8] c"_ZN1BD1Ev"

// Deleting dtor must not be instrumented
// CHECK-NOT: @__profn__ZN1BD0Ev = private constant [9 x i8] c"_ZN1BD0Ev"

// Base dtor counters and profile data
// CHECK: @__profc__ZN1BD2Ev = private global [1 x i64] zeroinitializer
// CHECK: @__profd__ZN1BD2Ev =

// Complete dtor counters and profile data must absent
// CHECK-NOT: @__profc__ZN1BD1Ev = private global [1 x i64] zeroinitializer
// CHECK-NOT: @__profd__ZN1BD1Ev =

// Deleting dtor counters and profile data must absent
// CHECK-NOT: @__profc__ZN1BD0Ev = private global [1 x i64] zeroinitializer
// CHECK-NOT: @__profd__ZN1BD0Ev =

B::~B() { }

Revert "[profiling] Update test case to deal with name variable change (NFC)"

This reverts commit r295085, because the corresponding llvm change was
reverted.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@295100 91177308-0d34-0410-b5e6-96231b3b80d8


//C++ header - Open Scene Graph Simulation - Copyright (C) 1998-2002 Robert Osfield
// Distributed under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation.
//
// All software using osgSim must be GPL'd or excempted via the
// purchase of the Open Scene Graph Professional License (OSGPL)
// for further information contact robert@openscenegraph.com.

#include <osgSim/BlinkSequence>

#include <stdlib.h>

using namespace osgSim;

BlinkSequence::BlinkSequence():
    Referenced(),
    _pulsePeriod(0.0),
    _phaseShift(0.0),
    _pulseData(),
    _sequenceGroup(0) {}

BlinkSequence::BlinkSequence(const BlinkSequence& bs):
    Referenced(),
    _pulsePeriod(bs._pulsePeriod),
    _phaseShift(bs._phaseShift),
    _pulseData(bs._pulseData),
    _sequenceGroup(bs._sequenceGroup) {}

BlinkSequence::SequenceGroup::SequenceGroup():
    Referenced()
{
    // set a random base time between 0 and 1000.0
    _baseTime = ((double)rand()/(double)RAND_MAX)*1000.0;
}

BlinkSequence::SequenceGroup::SequenceGroup(double baseTime):
    Referenced(),
    _baseTime(baseTime) {}

//C++ header - Open Scene Graph Simulation - Copyright (C) 1998-2002 Robert Osfield
// Distributed under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation.
//
// All software using osgSim must be GPL'd or excempted via the
// purchase of the Open Scene Graph Professional License (OSGPL)
// for further information contact robert@openscenegraph.com.

#include <osgSim/BlinkSequence>

#include <stdlib.h>

using namespace osgSim;

BlinkSequence::BlinkSequence():
    _pulsePeriod(0.0),
    _phaseShift(0.0),
    _pulseData(),
    _sequenceGroup(0)
{
}

BlinkSequence::BlinkSequence(const BlinkSequence& bs):
    _pulsePeriod(bs._pulsePeriod),
    _phaseShift(bs._phaseShift),
    _pulseData(bs._pulseData),
    _sequenceGroup(bs._sequenceGroup)
{
}

BlinkSequence::SequenceGroup::SequenceGroup()
{
    // set a random base time between 0 and 1000.0
    _baseTime = ((double)rand()/(double)RAND_MAX)*1000.0;
}

BlinkSequence::SequenceGroup::SequenceGroup(double baseTime):
    _baseTime(baseTime)
{
}

Fix for compile problems under IRIX.

Fix for compile problems under IRIX.


/**
 * @file   equationTest.cpp
 * @brief  equation header tester.
 * @author zer0
 * @date   2016-08-26
 */

#include <gtest/gtest.h>
#include <libtbag/math/equation.hpp>

using namespace libtbag;
using namespace libtbag::math;

TEST(equationTest, getLinearEquationWithTwoPoint)
{
    auto e = getLinearEquationWithTwoPoint(1, 1, 2, 2);
    ASSERT_EQ(1, e.a);
    ASSERT_EQ(0, e.b);
}

TEST(equationTest, getIntersectionWithTwoLinearEquation)
{
    LinearEquation<double> e1{ 2,  0};
    LinearEquation<double> e2{-2,  2};
    auto p = getIntersectionWithTwoLinearEquation(e1, e2);
    ASSERT_NEAR(0.5, p.x, 1);
    ASSERT_NEAR(1.0, p.y, 1);
}

/**
 * @file   equationTest.cpp
 * @brief  equation header tester.
 * @author zer0
 * @date   2016-08-26
 */

#include <gtest/gtest.h>
#include <libtbag/math/equation.hpp>

using namespace libtbag;
using namespace libtbag::math;

TEST(equationTest, getLinearEquationWithTwoPoint)
{
    auto e = getLinearEquationWithTwoPoint(1, 1, 2, 2);
    ASSERT_EQ(1, e.a);
    ASSERT_EQ(0, e.b);
}

TEST(equationTest, isParallelWithTwoLinearEquation)
{
    LinearEquation<double> e1{2.4, 1};
    LinearEquation<double> e2{2.4, 2};
    ASSERT_TRUE(isParallelWithTwoLinearEquation(e1, e2));
}

TEST(equationTest, getIntersectionWithTwoLinearEquation)
{
    LinearEquation<double> e1{ 2, 0};
    LinearEquation<double> e2{-2, 2};
    auto p = getIntersectionWithTwoLinearEquation(e1, e2);
    ASSERT_NEAR(0.5, p.x, 0.1);
    ASSERT_NEAR(1.0, p.y, 0.1);
}

Fix the ASSERT_NEAR() parameter bug.

Fix the ASSERT_NEAR() parameter bug.


// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/logging.h"
#include "base/path_service.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/ui_test_utils.h"
#include "net/base/mock_host_resolver.h"

// http://crbug.com/111165
#if defined(OS_WIN)
#define MAYBE_WebSocket FAILS_WebSocket
#else
#define MAYBE_WebSocket WebSocket
#endif
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_WebSocket) {
  FilePath websocket_root_dir;
  ASSERT_TRUE(PathService::Get(chrome::DIR_LAYOUT_TESTS, &websocket_root_dir));
  // TODO(toyoshim): Remove following logging after a bug investigation.
  // http://crbug.com/107836 .
  LOG(INFO) << "Assume LayoutTests in " << websocket_root_dir.MaybeAsASCII();

  ui_test_utils::TestWebSocketServer server;
  ASSERT_TRUE(server.Start(websocket_root_dir));
  ASSERT_TRUE(RunExtensionTest("websocket")) << message_;
}

// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/logging.h"
#include "base/path_service.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/ui_test_utils.h"
#include "net/base/mock_host_resolver.h"

// http://crbug.com/111165
#if defined(OS_WIN)
#define MAYBE_WebSocket DISABLED_WebSocket
#else
#define MAYBE_WebSocket WebSocket
#endif
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_WebSocket) {
  FilePath websocket_root_dir;
  ASSERT_TRUE(PathService::Get(chrome::DIR_LAYOUT_TESTS, &websocket_root_dir));
  // TODO(toyoshim): Remove following logging after a bug investigation.
  // http://crbug.com/107836 .
  LOG(INFO) << "Assume LayoutTests in " << websocket_root_dir.MaybeAsASCII();

  ui_test_utils::TestWebSocketServer server;
  ASSERT_TRUE(server.Start(websocket_root_dir));
  ASSERT_TRUE(RunExtensionTest("websocket")) << message_;
}

Disable ExtensionApiTest.WebSocket instead of marked as FAILS_

BUG=111165
TEST=none
TBR=hbono@chromium.org

Review URL: https://chromiumcodereview.appspot.com/9117027

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@118821 0039d316-1c4b-4281-b951-d872f2087c98


// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include "commctrl.h"
#include "accctrl.h"
#include "shellapi.h"
#include "shlobj.h"
#include "aclapi.h"
#include "lm.h"
#include "d2d1.h"
#include "dwrite.h"

BOOL APIENTRY DllMain(
    HMODULE hModule,
    DWORD  ul_reason_for_call,
    LPVOID lpReserved)
{
    switch (ul_reason_for_call)
    {
        case DLL_PROCESS_ATTACH:
        case DLL_THREAD_ATTACH:
        case DLL_THREAD_DETACH:
        case DLL_PROCESS_DETACH:
            break;
    }

    return TRUE;
}

// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include "commctrl.h"
#include "accctrl.h"
#include "shellapi.h"
#include "shlobj.h"
#include "aclapi.h"
#include "lm.h"
#include "d2d1.h"
#include "dwrite.h"
#include "richedit.h"
#include "shlwapi.h"
#include "uxtheme.h"
#include "Mshtmhst.h"
#include "richole.h"
#include "OleCtl.h"
#include "winternl.h"

BOOL APIENTRY DllMain(
    HMODULE hModule,
    DWORD  ul_reason_for_call,
    LPVOID lpReserved)
{
    switch (ul_reason_for_call)
    {
        case DLL_PROCESS_ATTACH:
        case DLL_THREAD_ATTACH:
        case DLL_THREAD_DETACH:
        case DLL_PROCESS_DETACH:
            break;
    }

    return TRUE;
}

Add a few more headers to the native test project


//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2011 Utku Aydın <utkuaydin34@gmail.com>
//

#include "GeoSceneGeodata.h"
#include "GeoSceneTypes.h"

namespace Marble
{
GeoSceneGeodata::GeoSceneGeodata( QString name )
    : GeoSceneAbstractDataset( name ),
      m_name( name ),
      m_sourceFile( QString() ),
      m_sourceFileFormat( QString() )
{
}

GeoSceneGeodata::~GeoSceneGeodata()
{
}

const char* GeoSceneGeodata::nodeType() const
{
    return GeoSceneTypes::GeoSceneGeodataType;
}

QString GeoSceneGeodata::name() const
{
    return m_name;
}

QString GeoSceneGeodata::sourceFile() const
{
    return m_sourceFile;
}

void GeoSceneGeodata::setSourceFile(QString sourceFile)
{
    m_sourceFile = sourceFile;
}

QString GeoSceneGeodata::sourceFileFormat() const
{
    return m_sourceFileFormat;
}

void GeoSceneGeodata::setSourceFileFormat(QString format)
{
    m_sourceFileFormat = format;
}

QString GeoSceneGeodata::type()
{
    return "geodata";
}

}

#include "GeoSceneGeodata.moc"

//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2011 Utku Aydın <utkuaydin34@gmail.com>
//

#include "GeoSceneGeodata.h"
#include "GeoSceneTypes.h"

namespace Marble
{
GeoSceneGeodata::GeoSceneGeodata( QString name )
    : GeoSceneAbstractDataset( name ),
      m_name( name ),
      m_sourceFile( QString() ),
      m_sourceFileFormat( QString() )
{
}

GeoSceneGeodata::~GeoSceneGeodata()
{
}

const char* GeoSceneGeodata::nodeType() const
{
    return GeoSceneTypes::GeoSceneGeodataType;
}

QString GeoSceneGeodata::name() const
{
    return m_name;
}

QString GeoSceneGeodata::sourceFile() const
{
    return m_sourceFile;
}

void GeoSceneGeodata::setSourceFile(QString sourceFile)
{
    m_sourceFile = sourceFile;
}

QString GeoSceneGeodata::sourceFileFormat() const
{
    return m_sourceFileFormat;
}

void GeoSceneGeodata::setSourceFileFormat(QString format)
{
    m_sourceFileFormat = format;
}

QString GeoSceneGeodata::type()
{
    return "geodata";
}

}

// #include "GeoSceneGeodata.moc"

Fix compiler warning (moc has nothing to generate)

svn path=/trunk/KDE/kdeedu/marble/; revision=1213525


// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/printing/print_error_dialog.h"

namespace chrome {

void ShowPrintErrorDialog() {}

}  // namespace chrome

// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/printing/print_error_dialog.h"

void ShowPrintErrorDialog() {}

Move chrome/browser/printing out of the chrome namespace

https://crrev.com/787046bf5046


// Copyright (c) 2011 Timur Iskhodzhanov and MIPT students. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "gtest/gtest.h"

#include "base/common.h"

TEST(CheckTest, CheckTrueSucceedsTest) {
  CHECK(1);
  CHECK(42);
}

TEST(CheckTest, AssertionsAndChecksTest) {
  CHECK(2 + 2 == 4);        // NOLINT
  ASSERT_TRUE(2 + 2 == 4);  // NOLINT
  ASSERT_EQ(5, 2 + 2);
  ASSERT_LE(2 + 2, 5);
  printf("Passed all ASSERT macros, now EXPECT macros\n");
  EXPECT_EQ(4, 2 + 2);
  printf("End of test\n");
}

// C preprocessor magic, see
// http://www.decompile.com/cpp/faq/file_and_line_error_string.htm
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define __FILE_LINE__ __FILE__ ":" TOSTRING(__LINE__)

TEST(CheckTest, CheckFalseDeathTest) {
  ASSERT_DEATH(CHECK(0), "CHECK failed: .* at " __FILE_LINE__);
}

TEST(CheckTest, DCheckFalseDeathTest) {
  ASSERT_DEBUG_DEATH(DCHECK(0), "CHECK failed: .* at " __FILE_LINE__);
}

// Copyright (c) 2011 Timur Iskhodzhanov and MIPT students. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "gtest/gtest.h"

#include "base/common.h"

TEST(CheckTest, CheckTrueSucceedsTest) {
  CHECK(1);
  CHECK(42);
}

TEST(CheckTest, AssertionsAndChecksTest) {
  CHECK(2 + 2 == 4);        // NOLINT
  ASSERT_TRUE(2 + 2 == 4);  // NOLINT
  ASSERT_EQ(4, 2 + 2);
  ASSERT_LE(2 + 2, 5);
  printf("Passed all ASSERT macros, now EXPECT macros\n");
  EXPECT_EQ(4, 2 + 2);
  printf("End of test\n");
}

// C preprocessor magic, see
// http://www.decompile.com/cpp/faq/file_and_line_error_string.htm
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define __FILE_LINE__ __FILE__ ":" TOSTRING(__LINE__)

TEST(CheckTest, CheckFalseDeathTest) {
  ASSERT_DEATH(CHECK(0), "CHECK failed: .* at " __FILE_LINE__);
}

TEST(CheckTest, DCheckFalseDeathTest) {
  ASSERT_DEBUG_DEATH(DCHECK(0), "CHECK failed: .* at " __FILE_LINE__);
}

Revert r247, unbreak the build

Revert r247, unbreak the build


#include "ImwWindowManagerOGL.h"
#include "ImwPlatformWindowOGL.h"

#include "windows.h"

using namespace ImWindow;

ImwWindowManagerOGL::ImwWindowManagerOGL()
{
}

ImwWindowManagerOGL::~ImwWindowManagerOGL()
{
	Destroy();
}

ImwPlatformWindow* ImwWindowManagerOGL::CreatePlatformWindow(EPlatformWindowType eType, ImwPlatformWindow* pParent)
{
	IM_ASSERT(m_pCurrentPlatformWindow == NULL);
	ImwPlatformWindowOGL* pWindow = new ImwPlatformWindowOGL(eType, CanCreateMultipleWindow());
	if (pWindow->Init(pParent))
	{
		return (ImwPlatformWindow*)pWindow;
	}
	else
	{
		delete pWindow;
		return NULL;
	}
}

ImVec2 ImwWindowManagerOGL::GetCursorPos()
{
	POINT oPoint;
	::GetCursorPos(&oPoint);
	return ImVec2(oPoint.x, oPoint.y);
}

bool ImwWindowManagerOGL::IsLeftClickDown()
{
	return GetAsyncKeyState(VK_LBUTTON);
}

#include "ImwWindowManagerOGL.h"
#include "ImwPlatformWindowOGL.h"

#include "windows.h"

using namespace ImWindow;

ImwWindowManagerOGL::ImwWindowManagerOGL()
{
}

ImwWindowManagerOGL::~ImwWindowManagerOGL()
{
	Destroy();
}

ImwPlatformWindow* ImwWindowManagerOGL::CreatePlatformWindow(EPlatformWindowType eType, ImwPlatformWindow* pParent)
{
	IM_ASSERT(m_pCurrentPlatformWindow == NULL);
	ImwPlatformWindowOGL* pWindow = new ImwPlatformWindowOGL(eType, CanCreateMultipleWindow());
	if (pWindow->Init(pParent))
	{
		return (ImwPlatformWindow*)pWindow;
	}
	else
	{
		delete pWindow;
		return NULL;
	}
}

ImVec2 ImwWindowManagerOGL::GetCursorPos()
{
	POINT oPoint;
	::GetCursorPos(&oPoint);
	return ImVec2((float)oPoint.x, (float)oPoint.y);
}

bool ImwWindowManagerOGL::IsLeftClickDown()
{
	return GetAsyncKeyState(VK_LBUTTON) != 0;
}

Fix warnings in OpenGL backend

Fix warnings in OpenGL backend


//=======================================================================
// Copyright Baptiste Wicht 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================

#include "ltac/Register.hpp"

using namespace eddic;

ltac::Register::Register(){
    //Nothing to init
}

ltac::Register::Register(unsigned short reg) : reg(reg) {
    //Nothing to init
}

ltac::Register::operator int(){
    return reg;
}

bool ltac::Register::operator<(const Register& rhs) const {
    return reg > rhs.reg;
}

bool ltac::Register::operator>(const Register& rhs) const {
    return reg < rhs.reg;
}

bool ltac::Register::operator==(const Register& rhs) const {
    return reg == rhs.reg;
}

bool ltac::Register::operator!=(const Register& rhs) const {
    return !(*this == rhs);
}

std::ostream& ltac::operator<<(std::ostream& out, const ltac::Register& reg){
    return out << "r" << reg.reg;
}

//=======================================================================
// Copyright Baptiste Wicht 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================

#include "ltac/Register.hpp"

using namespace eddic;

ltac::Register::Register(){
    //Nothing to init
}

ltac::Register::Register(unsigned short reg) : reg(reg) {
    //Nothing to init
}

ltac::Register::operator int(){
    return reg;
}

bool ltac::Register::operator<(const Register& rhs) const {
    return reg > rhs.reg;
}

bool ltac::Register::operator>(const Register& rhs) const {
    return reg < rhs.reg;
}

bool ltac::Register::operator==(const Register& rhs) const {
    return reg == rhs.reg;
}

bool ltac::Register::operator!=(const Register& rhs) const {
    return !(*this == rhs);
}

std::ostream& ltac::operator<<(std::ostream& out, const ltac::Register& reg){
    if(reg == ltac::BP){
        return out << "bp";
    } else if(reg == ltac::SP){
        return out << "sp";
    }

    return out << "r" << reg.reg;
}

Complete printing of SP/BP registers

Complete printing of SP/BP registers


#include "aquila/global.h"
#include "aquila/source/generator/WhiteNoiseGenerator.h"
#include <unittestpp.h>
#include <algorithm>
#include <cstddef>
#include <cstdlib>
#include <ctime>

SUITE(WhiteNoiseGenerator)
{
    // sample frequency is fixed at 1 kHz
    Aquila::WhiteNoiseGenerator gen(1000);

    TEST(DoesNotOverrunAplitude)
    {
        std::srand(std::time(0));
        Aquila::SampleType amplitude = 1000;
        gen.setAmplitude(amplitude).generate(2048);
        auto result = std::minmax_element(std::begin(gen), std::end(gen));
        CHECK(*result.first > -amplitude);
        CHECK(*result.second < amplitude);
    }
}

#include "aquila/global.h"
#include "aquila/source/generator/WhiteNoiseGenerator.h"
#include <unittestpp.h>
#include <algorithm>
#include <cstddef>
#include <cstdlib>
#include <ctime>

SUITE(WhiteNoiseGenerator)
{
    // sample frequency is fixed at 1 kHz
    Aquila::WhiteNoiseGenerator gen(1000);

    TEST(DoesNotOverrunAplitude)
    {
        std::srand(std::time(0));
        Aquila::SampleType amplitude = 1000;
        gen.setAmplitude(amplitude).generate(2048);
        auto result = std::minmax_element(std::begin(gen), std::end(gen));
        CHECK(*result.first > -amplitude);
        CHECK(*result.second < amplitude);
    }

    TEST(ZeroMean)
    {
        std::srand(std::time(0));
        gen.setAmplitude(1).generate(2048);
        auto mean = Aquila::mean(gen);
        CHECK_CLOSE(0.0, mean, 0.01);
    }
}

Check that white noise mean value is close to 0.


#include "c_bmp_decoder.h"

namespace Img
{
	namespace Internal
	{
		using namespace Geom;

		bool BmpDataDecoder::Process()
		{
			return OnProcess();
		}

		BmpDataDecoder::BmpDataDecoder(std::shared_ptr<Img::Surface> destination, BMPHeader header):
			m_header{ header },
			m_destination{ destination }
		{

		}

		std::shared_ptr<Img::Surface::LockedArea> BmpDataDecoder::GetScanlinePtr(int row)
		{
			if (m_header.FlipVertical)
			{
				row = m_destination->Height() - row - 1;
			}
			return m_destination->LockSurface({ PointInt{0, row}, SizeInt{m_destination->Width(), 1} }, Img::LockReadWrite);
		}
	}
}

#include "c_bmp_decoder.h"

namespace Img
{
	namespace Internal
	{
		using namespace Geom;

		bool BmpDataDecoder::Process()
		{
			return OnProcess();
		}

		BmpDataDecoder::BmpDataDecoder(std::shared_ptr<Img::Surface> destination, BMPHeader header):
			m_header{ header },
			m_destination{ destination }
		{

		}

		std::shared_ptr<Img::Surface::LockedArea> BmpDataDecoder::GetScanlinePtr(int row)
		{
			if (m_header.FlipVertical)
			{
				row = m_destination->Height() - row - 1;
			}
			return m_destination->LockSurface({ PointInt{0, row}, SizeInt{m_destination->Width(), 1} }, Img::LockReadWrite);
			auto area = m_destination->LockSurface({ PointInt{0, row}, SizeInt{m_destination->Width(), 1} }, Img::LockReadWrite);
			if(area == nullptr)
			{
				DO_THROW(Err::CriticalError, "Could not get scanline ptr");
			}
			return area;
		}
	}
}

Make BMP decoder handle failed surface locks


// Test that no data is collected without a runtime flag.
//
// RUN: %clangxx_asan -fsanitize-coverage=1 %s -o %t
//
// RUN: rm -rf %T/coverage-disabled
//
// RUN: mkdir -p %T/coverage-disabled/normal
// RUN: ASAN_OPTIONS=coverage_direct=0:coverage_dir=%T/coverage-disabled/normal:verbosity=1 %run %t
// RUN: not %sancov print %T/coverage-disabled/normal/*.sancov 2>&1
//
// RUN: mkdir -p %T/coverage-disabled/direct
// RUN: ASAN_OPTIONS=coverage_direct=1:coverage_dir=%T/coverage-disabled/direct:verbosity=1 %run %t
// RUN: cd %T/coverage-disabled/direct
// RUN: not %sancov rawunpack *.sancov

int main(int argc, char **argv) {
  return 0;
}

// Test that no data is collected without a runtime flag.
//
// RUN: %clangxx_asan -fsanitize-coverage=1 %s -o %t
//
// RUN: rm -rf %T/coverage-disabled
//
// RUN: mkdir -p %T/coverage-disabled/normal
// RUN: ASAN_OPTIONS=coverage_direct=0:coverage_dir=%T/coverage-disabled/normal:verbosity=1 %run %t
// RUN: not %sancov print %T/coverage-disabled/normal/*.sancov 2>&1
//
// RUN: mkdir -p %T/coverage-disabled/direct
// RUN: ASAN_OPTIONS=coverage_direct=1:coverage_dir=%T/coverage-disabled/direct:verbosity=1 %run %t
// RUN: cd %T/coverage-disabled/direct
// RUN: not %sancov rawunpack *.sancov
//
// XFAIL: android

int main(int argc, char **argv) {
  return 0;
}

Disable one test on Android.

[asan] Disable one test on Android.

It used to pass by chance and started failing on recent Android builds.

git-svn-id: c199f293c43da69278bea8e88f92242bf3aa95f7@224818 91177308-0d34-0410-b5e6-96231b3b80d8


// RUN: %clangxx -O2 %s -o %t && %run %t 2>&1 | FileCheck %s

// Malloc/free hooks are not supported on Windows.
// XFAIL: win32

#include <stdlib.h>
#include <unistd.h>
#include <sanitizer/allocator_interface.h>

extern "C" {
const volatile void *global_ptr;

// Note: avoid calling functions that allocate memory in malloc/free
// to avoid infinite recursion.
void __sanitizer_malloc_hook(const volatile void *ptr, size_t sz) {
  if (__sanitizer_get_ownership(ptr)) {
    write(1, "MallocHook\n", sizeof("MallocHook\n"));
    global_ptr = ptr;
  }
}
void __sanitizer_free_hook(const volatile void *ptr) {
  if (__sanitizer_get_ownership(ptr) && ptr == global_ptr)
    write(1, "FreeHook\n", sizeof("FreeHook\n"));
}
}  // extern "C"

int main() {
  volatile int *x = new int;
  // CHECK: MallocHook
  // Check that malloc hook was called with correct argument.
  if (global_ptr != (void*)x) {
    _exit(1);
  }
  *x = 0;
  delete x;
  // CHECK: FreeHook
  return 0;
}

// RUN: %clangxx -O2 %s -o %t && %run %t 2>&1 | FileCheck %s

// Malloc/free hooks are not supported on Windows.
// XFAIL: win32

#include <stdlib.h>
#include <unistd.h>
#include <sanitizer/allocator_interface.h>

extern "C" {
const volatile void *global_ptr;

// Note: avoid calling functions that allocate memory in malloc/free
// to avoid infinite recursion.
void __sanitizer_malloc_hook(const volatile void *ptr, size_t sz) {
  if (__sanitizer_get_ownership(ptr) && sz == 4) {
    write(1, "MallocHook\n", sizeof("MallocHook\n"));
    global_ptr = ptr;
  }
}
void __sanitizer_free_hook(const volatile void *ptr) {
  if (__sanitizer_get_ownership(ptr) && ptr == global_ptr)
    write(1, "FreeHook\n", sizeof("FreeHook\n"));
}
}  // extern "C"

volatile int *x;

// Call this function with uninitialized arguments to poison
// TLS shadow for function parameters before calling operator
// new and, eventually, user-provided hook.
__attribute__((noinline)) void allocate(int *unused1, int *unused2) {
  x = new int;
}

int main() {
  int *undef1, *undef2;
  allocate(undef1, undef2);
  // CHECK: MallocHook
  // Check that malloc hook was called with correct argument.
  if (global_ptr != (void*)x) {
    _exit(1);
  }
  *x = 0;
  delete x;
  // CHECK: FreeHook
  return 0;
}

Add a test case for r258339.

[MSan] Add a test case for r258339.

git-svn-id: c199f293c43da69278bea8e88f92242bf3aa95f7@258413 91177308-0d34-0410-b5e6-96231b3b80d8


// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/command_line.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_switches.h"

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigation) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("webnavigation/api")) << message_;
}

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationEvents1) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("webnavigation/navigation1")) << message_;
}

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationEvents2) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("webnavigation/navigation2")) << message_;
}

// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/command_line.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_switches.h"

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigation) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("webnavigation/api")) << message_;
}

// Disabled, flakily exceeds timeout, http://crbug.com/72165.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_WebNavigationEvents1) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("webnavigation/navigation1")) << message_;
}

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationEvents2) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("webnavigation/navigation2")) << message_;
}

Disable ExtensionApiTest.WebNavigationEvents1, flakily exceeds test timeout

TBR=jochen

BUG=72165
TEST=browser_tests
Review URL: http://codereview.chromium.org/6286142

git-svn-id: dd90618784b6a4b323ea0c23a071cb1c9e6f2ac7@73975 4ff67af0-8c30-449e-8e8b-ad334ec8d88c


#include <iostream>
#include <vector>
#include <fstream>

#include "errors/RuntimeError.h"
#include "execution/Program.h"
#include "loader/ProgramReader.h"

int main(int argc, char **argv) {

    if (argc != 2) {
        std::cerr << "Usage: thingc filename.thingc" << std::endl;
        return 1;
    }

    auto reader = ProgramReader(argv[1]);

    try {
        auto info = reader.process();
        Program::load(info);
        Program::start();
    } catch (const RuntimeError &err) {
        std::cerr << "Error during execution: " << err.what() << std::endl;
        return 1;
    }

    return 0;
}

#include <iostream>
#include <vector>
#include <fstream>

#include "errors/RuntimeError.h"
#include "execution/Program.h"
#include "loader/ProgramReader.h"

int main(int argc, char **argv) {

    if (argc != 2) {
        std::cerr << "Usage: thingc filename.thingc" << std::endl;
        return 1;
    }

    auto filename = std::string(argv[1]);

    if(filename == "--build-only"){
        std::cerr << "Build completed, not executing." << std::endl;
        return 0;
    }

    auto reader = filename == "-" ? ProgramReader() : ProgramReader(filename);

    try {
        auto info = reader.process();
        Program::load(info);
        Program::start();
    } catch (const RuntimeError &err) {
        std::cerr << "Error during execution: " << err.what() << std::endl;
        return 1;
    }

    return 0;
}

Allow thinglang bytecode to be piped directly into the VM


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <systemlib/mixer/mixer.h>
#include <systemlib/err.h>
#include <drivers/drv_hrt.h>
#include <px4iofirmware/px4io.h>
#include "../../src/systemcmds/tests/tests.h"
#include <geo/geo.h>

int main(int argc, char *argv[]) {
	warnx("autodeclination test started");

	if (argc < 3)
		errx(1, "Need lat/lon!");

	char* p_end;

	float lat = strtod(argv[1], &p_end);
	float lon = strtod(argv[2], &p_end);

	float declination = get_mag_declination(lat, lon);

	printf("lat: %f lon: %f, dec: %f\n", lat, lon, declination);

}

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
#include <systemlib/mixer/mixer.h>
#include <systemlib/err.h>
#include <drivers/drv_hrt.h>
#include <px4iofirmware/px4io.h>
// #include "../../src/systemcmds/tests/tests.h"
#include <geo/geo.h>

int main(int argc, char *argv[]) {
	warnx("autodeclination test started");

	char* latstr = 0;
	char* lonstr = 0;
	char* declstr = 0;

	if (argc < 4) {
		warnx("Too few arguments. Using default lat / lon and declination");
		latstr = "47.0";
		lonstr = "8.0";
		declstr = "0.6";
	} else {
		latstr = argv[1];
		lonstr = argv[2];
		declstr = argv[3];
	}

	char* p_end;

	float lat = strtod(latstr, &p_end);
	float lon = strtod(lonstr, &p_end);
	float decl_truth = strtod(declstr, &p_end);

	float declination = get_mag_declination(lat, lon);

	printf("lat: %f lon: %f, expected dec: %f, estimated dec: %f\n", lat, lon, declination, decl_truth);

	int ret = 0;

	// Fail if the declination differs by more than one degree
	float decldiff = fabs(decl_truth - declination);
	if (decldiff > 0.5f) {
		warnx("declination differs more than 1 degree: difference: %12.8f", decldiff);
		ret = 1;
	}

	return ret;
}

unittests: Improve auto declination test, not great coverage yet.


#include <gloperate/input/MouseDevice.h>

#include <gloperate/input/MouseEvent.h>
#include <gloperate/input/InputManager.h>

namespace gloperate
{

MouseDevice::MouseDevice(InputManager * inputManager, const std::string & deviceDescriptor)
: AbstractDevice(inputManager, deviceDescriptor)
{
}

MouseDevice::~MouseDevice()
{
}

void MouseDevice::move(const glm::ivec2 & pos)
{
    auto inputEvent = new MouseEvent{
        InputEvent::Type::MouseButtonPress,
        this,
        pos
    };

    m_inputManager->onEvent(inputEvent);
}

void MouseDevice::buttonPress(int button, const glm::ivec2 & pos)
{
    auto inputEvent = new MouseEvent{
        InputEvent::Type::MouseButtonPress,
        this,
        pos,
        button
    };

    m_inputManager->onEvent(inputEvent);
}

void MouseDevice::buttonRelease(int button, const glm::ivec2 & pos)
{
    auto inputEvent = new MouseEvent{
        InputEvent::Type::MouseButtonRelease,
        this,
        pos,
        button
    };

    m_inputManager->onEvent(inputEvent);
}

void MouseDevice::wheelScroll(const glm::vec2 & delta, const glm::ivec2 & pos)
{
    auto inputEvent = new MouseEvent{
        InputEvent::Type::MouseWheelScroll,
        this,
        pos,
        delta
    };

    m_inputManager->onEvent(inputEvent);
}

void MouseDevice::update()
{
}

} // namespace gloperate

#include <gloperate/input/MouseDevice.h>

#include <gloperate/input/MouseEvent.h>
#include <gloperate/input/InputManager.h>

namespace gloperate
{

MouseDevice::MouseDevice(InputManager * inputManager, const std::string & deviceDescriptor)
: AbstractDevice(inputManager, deviceDescriptor)
{
}

MouseDevice::~MouseDevice()
{
}

void MouseDevice::move(const glm::ivec2 & pos)
{
    auto inputEvent = new MouseEvent{
        InputEvent::Type::MouseMove,
        this,
        pos
    };

    m_inputManager->onEvent(inputEvent);
}

void MouseDevice::buttonPress(int button, const glm::ivec2 & pos)
{
    auto inputEvent = new MouseEvent{
        InputEvent::Type::MouseButtonPress,
        this,
        pos,
        button
    };

    m_inputManager->onEvent(inputEvent);
}

void MouseDevice::buttonRelease(int button, const glm::ivec2 & pos)
{
    auto inputEvent = new MouseEvent{
        InputEvent::Type::MouseButtonRelease,
        this,
        pos,
        button
    };

    m_inputManager->onEvent(inputEvent);
}

void MouseDevice::wheelScroll(const glm::vec2 & delta, const glm::ivec2 & pos)
{
    auto inputEvent = new MouseEvent{
        InputEvent::Type::MouseWheelScroll,
        this,
        pos,
        delta
    };

    m_inputManager->onEvent(inputEvent);
}

void MouseDevice::update()
{
}

} // namespace gloperate

Fix wrong event type for mouse move events


#include <iostream>
#include <string>
#include <utility>

#include "pool.h"

void Pool::add_machine(const Machine& new_machine)
{
    const std::string& machine_name = new_machine.get_name();

    std::cout << "Adding machine to pool: " << machine_name << std::endl;
    machines.insert(std::make_pair(machine_name, new_machine));
}

void Pool::add_job(const Job& new_job)
{
    const int job_id = new_job.get_id();
    const std::string& machine_name = new_job.get_machine();
    std::map<std::string, Machine>::iterator iter;

    std::cout << "Adding job to pool: " << job_id << " (" << machine_name << ")" << std::endl;
    jobs.insert(std::make_pair(job_id, new_job));

    iter = machines.find(machine_name);
    if (iter != machines.end()) {
        std::cout << "Adding job to machine: " << machine_name << std::endl;
        iter->second.add_job(new_job);
    }
}

#include <iostream>
#include <string>
#include <utility>

#include "pool.h"

void Pool::add_machine(const Machine& new_machine)
{
    const std::string& machine_name = new_machine.get_name();

    std::cout << "Adding machine to pool: " << machine_name << std::endl;
    machines.insert(std::make_pair(machine_name, new_machine));
}

void Pool::add_job(const Job& new_job)
{
    const int job_id = new_job.get_id();
    const std::string& machine_name = new_job.get_machine();

    std::cout << "Adding job to pool: " << job_id << " (" << machine_name << ")" << std::endl;
    jobs.insert(std::make_pair(job_id, new_job));

    std::map<std::string, Machine>::iterator iter = machines.find(machine_name);
    if (iter != machines.end()) {
        std::cout << "Adding job to machine: " << machine_name << std::endl;
        iter->second.add_job(new_job);
    }
}

Move iterator variable declaration to the point of use.


#include <chrono>
#include <cstdint>
#include <iostream>
#include <mutex>
#include <sstream>
#include <string>
#include <thread>
#include <vector>

std::mutex output;

void func(unsigned int value) {
	using std::chrono::seconds;
	using std::cout;
	using std::endl;
	using std::lock_guard;
	using std::mutex;

	std::this_thread::sleep_for(seconds(value));

	{
		lock_guard<mutex> lock{output};
		cout << value << endl;
	}
}

int main(int argc, char** argv) {
	using std::cout;
	using std::endl;
	using std::string;
	using std::stringstream;
	using std::thread;
	using std::vector;

	vector<thread>::size_type amount = argc - 1;
	vector<thread> threads;
	threads.reserve(amount);
	for (auto i = 1; i < argc; ++i) {
		stringstream ss;
		ss << argv[i];

		unsigned int value;
		if (!(ss >> value)) {
			string invalid;
			ss >> invalid;
			cout << "You input a non-integer: " << invalid << endl;
		} else {
			threads.emplace_back(func, value);
		}
	}

	for (auto& thread : threads) {
		thread.join();
	}

	return 0;
}

#include <chrono>
#include <cstdint>
#include <iostream>
#include <mutex>
#include <sstream>
#include <string>
#include <thread>
#include <vector>

std::mutex output;

void func(unsigned int value) {
	using std::chrono::seconds;
	using std::cout;
	using std::endl;
	using std::lock_guard;
	using std::mutex;

	std::this_thread::sleep_for(seconds(value));

	{
		lock_guard<mutex> lock{output};
		cout << value << endl;
	}
}

int main(int argc, char** argv) {
	using std::cout;
	using std::endl;
	using std::string;
	using std::stringstream;
	using std::thread;
	using std::vector;

	vector<thread>::size_type amount = argc - 1;
	vector<thread> threads;
	threads.reserve(amount);
	for (auto i = 1; i < argc; ++i) {
		stringstream ss;
		ss << argv[i];

		unsigned int value;
		if (!(ss >> value)) {
			cout << "You input a non-integer: " << argv[i] << endl;
		} else {
			threads.emplace_back(func, value);
		}
	}

	for (auto& thread : threads) {
		thread.join();
	}

	return 0;
}

Fix output of non-integer parameters

Fix output of non-integer parameters


#include "config.h"
#ifdef HAVE_ASPRINTF
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include "globit.c"
#endif

#include "config.h"
#ifdef HAVE_ASPRINTF
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
#endif
#include "globit.c"
#endif

Fix build failure with GCC <= 4.7

Fix build failure with GCC <= 4.7


// __BEGIN_LICENSE__
// Copyright (C) 2006-2011 United States Government as represented by
// the Administrator of the National Aeronautics and Space Administration.
// All Rights Reserved.
// __END_LICENSE__

#include <vw/Plate/detail/Seed.h>
#include <vw/Core/Thread.h>
#include <boost/cast.hpp>

namespace {
  vw::RunOnce seed_once = VW_RUNONCE_INIT;

  void hidden_seed_random() {
    srandom(boost::numeric_cast<unsigned int>(clock()));
  }
}

namespace vw {
namespace platefile {

  void plate_seed_random() {
    seed_once.run( hidden_seed_random );
  }

}}

// __BEGIN_LICENSE__
// Copyright (C) 2006-2011 United States Government as represented by
// the Administrator of the National Aeronautics and Space Administration.
// All Rights Reserved.
// __END_LICENSE__

#include <vw/Plate/detail/Seed.h>
#include <vw/Core/Thread.h>
#include <vw/Core/Stopwatch.h>
#include <sys/types.h>

namespace {
  vw::RunOnce seed_once = VW_RUNONCE_INIT;

  void hidden_seed_random() {
    srandom(vw::Stopwatch::microtime()*::getpid());
  }
}

namespace vw {
namespace platefile {

  void plate_seed_random() {
    seed_once.run( hidden_seed_random );
  }

}}

Replace random seed with something more unique

This should hopefully produce something unique across executables
starting at the same time. I have no faith in clock resolutions.


// Copyright (c) 2017 Pierre Fourgeaud
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.

#include <bandit/bandit.h>
#include "core/math/vector2.h"

using namespace bandit;
using namespace snowhouse;
using namespace CodeHero;

go_bandit([]() {
    describe("Vector2", []() {
        describe("Constructor", []() {
            it("should initialize vector with 0s if no arguments", [] {
                Vector2 test;

                AssertThat(test.x(), Equals(0.0f));
            });

            it("should initialize vector with correct x and y if provided", [] {
                float x = 1.5f;
                float y = 1.5f;
                Vector2 test(x, y);

                AssertThat(test.x(), Equals(x));
                AssertThat(test.y(), Equals(y));
            });
        });

        describe("::Length", [] {
            it("should compute the proper length", [] {
                float x = 2.0f;
                float y = 2.0f;
                Vector2 test(x, y);

                float res = 2.8284271247461903f;
                AssertThat(test.Length(), Equals(res));
            });
        });
    });
});

// Copyright (c) 2017 Pierre Fourgeaud
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.

#include <bandit/bandit.h>
#include "core/math/vector2.h"

using namespace bandit;
using namespace snowhouse;
using namespace CodeHero;

go_bandit([]() {
    describe("Vector2", []() {
        describe("Constructor", []() {
            it("should initialize vector with 0s if no arguments", [] {
                Vector2 test;

                AssertThat(test.x(), Equals(0.0f));
            });

            it("should initialize vector with correct x and y if provided", [] {
                float x = 1.5f;
                float y = 1.5f;
                Vector2 test(x, y);

                AssertThat(test.x(), Equals(x));
                AssertThat(test.y(), Equals(y));
            });
        });

        describe("::Length", [] {
            it("should compute the proper length", [] {
                float x = 2.0f;
                float y = 2.0f;
                Vector2 test(x, y);

                float res = 2.8284271247461903f;
                AssertThat(test.Length(), Equals(res));
            });
        });

        describe("::Normalize", [] {
            it("should compute the normalized vector", [] {
                Vector2 test(1.0f, 1.0f);

                float res = 0.70710678118f;
                test.Normalize();
                AssertThat(test.x(), Equals(res));
                AssertThat(test.y(), Equals(res));
            });
        });
    });
});

Normalize tested for vector2. vector2 tested fully


#include <iostream>

using namespace std;

const int MAX = 100;

struct Person {
  string firstName;
  string lastName;

  void input() {
    cout << "Enter person's first and last names separated by a space: ";
    cin >> firstName >> lastName;
  }

  void print() {
    cout << firstName << ' ' << lastName << '\n';
  }
};

struct Client {
  Person person;
  double account;

  void input() {
    person.input();

    cout << "Enter account: ";
    cin >> account;
  }

  void print() {
    person.print();
    cout << "Account: " << account << '\n';
  };
};

void inputClients(int n) {
  Client clients[MAX];

  for (int i = 0; i < n; ++i) {
    clients[i].input();
  }
}

void printClients(Client clients[], int n) {
  for (int i = 0; i < n; ++i) {
    clients[i].print();
  }
}

double sumAccounts(Client clients[], int n) {
  double sum = 0;

  for (int i = 0; i < n; ++i) {
    sum += clients[i].account;
  }

  return sum;
}

int main() {
  return 0;
}

#include <iostream>

using namespace std;

const int MAX = 100;

struct Person {
  string firstName;
  string lastName;

  void input() {
    cout << "Enter person's first and last names separated by a space: ";
    cin >> firstName >> lastName;
  }

  void print() {
    cout << firstName << ' ' << lastName << '\n';
  }
};

struct Client {
  Person person;
  double account;

  void input() {
    person.input();

    cout << "Enter account: ";
    cin >> account;
  }

  void print() {
    person.print();
    cout << "Account: " << account << '\n';
  };
};

void inputClients(Client clients[], int n) {
  for (int i = 0; i < n; ++i) {
    clients[i].input();
  }
}

void printClients(Client clients[], int n) {
  for (int i = 0; i < n; ++i) {
    clients[i].print();
  }
}

double sumAccounts(Client clients[], int n) {
  double sum = 0;

  for (int i = 0; i < n; ++i) {
    sum += clients[i].account;
  }

  return sum;
}

int main() {
  Client clients[MAX];
  int clientsCount = 3;

  inputClients(clients, clientsCount);
  printClients(clients, clientsCount);
  cout << sumAccounts(clients, clientsCount) << '\n';

  return 0;
}

Add test for first problem solution

Add test for first problem solution


//
// Created by dar on 2/21/16.
//

#include "EntityFather.h"

EntityFather::EntityFather(Map *map) : EntityMoving(map, 0.25, 0.25) {
    b2PolygonShape shape;
    shape.SetAsBox(0.25, 0.25);
    b2FixtureDef fixDef;
    fixDef.shape = &shape;
    fixDef.density = 6.0f;
    fixDef.friction = 0.1f;
    this->body->CreateFixture(&fixDef);
}

void EntityFather::update() {
    EntityMoving::update();
    this->applyImpulse(1.0f * this->getSpeed(), 0.0f);
}

double EntityFather::getSpeed() {
    return 0.5f;
}

//
// Created by dar on 2/21/16.
//

#include "EntityFather.h"

EntityFather::EntityFather(Map *map) : EntityMoving(map, 0.25, 0.25) {
    b2PolygonShape shape;
    shape.SetAsBox(0.25, 0.25);
    b2FixtureDef fixDef;
    fixDef.shape = &shape;
    fixDef.density = 6.0f;
    fixDef.friction = 0.1f;
    this->body->CreateFixture(&fixDef);
}

void EntityFather::update() {
    EntityMoving::update();
    this->applyImpulse(1.0f * this->getSpeed() * cos(this->getAngle()), 1.0f * this->getSpeed() * sin(this->getAngle()));
}

double EntityFather::getSpeed() {
    return 0.5f;
}

Make the father walk straight

Make the father walk straight


/*
 * main.cc
 *
 *  Copyright (c) 2015 Masatoshi Hanai
 *
 *  This software is released under MIT License.
 *  See LICENSE.
 *
 */
#include "glog/logging.h"
#include "gflags/gflags.h"
#include "gtest/gtest.h"
#include "leveldb/db.h"
#include "leveldb/options.h"

/* test files */
#include "medium/com_test.cc"
#include "medium/db_via_lp_test.cc"
#include "medium/gvt_test.cc"
#include "medium/logical_process_test.cc"
#include "small/db_test.cc"
#include "small/io_test.cc"
#include "small/thread_test.cc"
#include "small/util_test.cc"

int main(int argc, char** argv) {
  gflags::ParseCommandLineFlags(&argc, &argv, true);
  google::InitGoogleLogging(*argv);
  google::InstallFailureSignalHandler();

  ::testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}

/*
 * main.cc
 *
 *  Copyright (c) 2015 Masatoshi Hanai
 *
 *  This software is released under MIT License.
 *  See LICENSE.
 *
 */
#include "glog/logging.h"
#include "gflags/gflags.h"
#include "gtest/gtest.h"
#include "leveldb/db.h"
#include "leveldb/options.h"

/* test files */
#include "medium/com_test.cc"
#include "medium/db_via_lp_test.cc"
#include "medium/gvt_test.cc"
#include "medium/logical_process_test.cc"
#include "small/db_test.cc"
#include "small/io_test.cc"
#include "small/thread_test.cc"
#include "small/util_test.cc"

int main(int argc, char** argv) {
  ::testing::InitGoogleTest(&argc, argv);

  gflags::ParseCommandLineFlags(&argc, &argv, true);
  google::InitGoogleLogging(*argv);
  google::InstallFailureSignalHandler();

  return RUN_ALL_TESTS();
}

Fix bug for parsing google test flags

Fix bug for parsing google test flags


/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "perfetto/base/watchdog.h"

#include "gtest/gtest.h"

#include <time.h>

namespace perfetto {
namespace base {
namespace {

TEST(WatchDogTest, Crash) {
  EXPECT_DEATH(
      {
        WatchDog watchdog(1);
        usleep(2000000);
      },
      "");
}

TEST(WatchDogTest, NoCrash) {
  WatchDog watchdog(100000);
  usleep(5000);
}

}  // namespace
}  // namespace base
}  // namespace perfetto

/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "perfetto/base/watchdog.h"

#include "perfetto/base/logging.h"

#include "gtest/gtest.h"

#include <time.h>

namespace perfetto {
namespace base {
namespace {

TEST(WatchDogTest, Crash) {
  EXPECT_DEATH(
      {
        WatchDog watchdog(1);
        int sleep_s = 20;
        while (sleep_s != 0) {
          sleep_s = sleep(sleep_s);
        }
      },
      "");
}

TEST(WatchDogTest, NoCrash) {
  WatchDog watchdog(100000);
  PERFETTO_CHECK(usleep(5000) != -1);
}

}  // namespace
}  // namespace base
}  // namespace perfetto

Increase timeout of Crash test.

Increase timeout of Crash test.

Bug: 72652321
Change-Id: Ia1905bb20688d31da2de0052d37363733d875926


// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s

// CHECK: @a = global i32 10
int a = 10;
// CHECK: @ar = constant i32* @a
int &ar = a;

void f();
// CHECK: @fr = constant void ()* @_Z1fv
void (&fr)() = f;

struct S { int& a; };
// CHECK: @s = global %0 { i32* @a }
S s = { a };

// PR5581
namespace PR5581 {
class C {
public:
  enum { e0, e1 };
  unsigned f;
};

// CHECK: @_ZN6PR55812g0E = global %1 { i32 1 }
C g0 = { C::e1 };
}

namespace test2 {
  struct A {
    static const double d = 1.0;
    static const float f = d / 2;
  };

  // CHECK: @_ZN5test22t0E = global double 1.000000e+00, align 8
  // CHECK: @_ZN5test22t1E = global [2 x double] [double 1.000000e+00, double 5.000000e-01], align 16
  double t0 = A::d;
  double t1[] = { A::d, A::f };
}

// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s

// CHECK: @a = global i32 10
int a = 10;
// CHECK: @ar = constant i32* @a
int &ar = a;

void f();
// CHECK: @fr = constant void ()* @_Z1fv
void (&fr)() = f;

struct S { int& a; };
// CHECK: @s = global %0 { i32* @a }
S s = { a };

// PR5581
namespace PR5581 {
class C {
public:
  enum { e0, e1 };
  unsigned f;
};

// CHECK: @_ZN6PR55812g0E = global %1 { i32 1 }
C g0 = { C::e1 };
}

namespace test2 {
  struct A {
    static const double d = 1.0;
    static const float f = d / 2;
  };

  // CHECK: @_ZN5test22t0E = global double {{1\.0+e\+0+}}, align 8
  // CHECK: @_ZN5test22t1E = global [2 x double] [double {{1\.0+e\+0+}}, double {{5\.0+e-0*}}1], align 16
  double t0 = A::d;
  double t1[] = { A::d, A::f };
}

Secure this test against slightly different number formatters.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@116141 91177308-0d34-0410-b5e6-96231b3b80d8


// Copyright eeGeo Ltd (2012-2017), All Rights Reserved

#include <jni.h>

#include "AndroidAppThreadAssertionMacros.h"
#include "IndoorAtlasLocationManager.h"
#include "IndoorAtlasLocationManagerJni.h"

extern "C"
{
JNIEXPORT void JNICALL Java_com_eegeo_interiorsposition_indooratlas_IndoorAtlasLocationManagerJniMethods_DidUpdateLocation(
        JNIEnv *jenv, jclass jobj,
        jlong nativeObjectPtr,
        jdouble latitude,
        jdouble longitude,
        jstring floorId)
{
	const char* chars = jenv->GetStringUTFChars(floorId, 0);
	std::string floorIdString = chars;
	jenv->ReleaseStringUTFChars(floorId, chars);

    using ExampleApp::InteriorsPosition::SdkModel::IndoorAtlas::IndoorAtlasLocationManager;
    reinterpret_cast<IndoorAtlasLocationManager *>(nativeObjectPtr)->DidUpdateLocation(latitude,
                                                                                longitude,
                                                                                floorIdString);
}

JNIEXPORT void JNICALL Java_com_eegeo_interiorsposition_indooratlas_IndoorAtlasLocationManagerJniMethods_SetIsAuthorized(
        JNIEnv *jenv, jclass obj,
        jlong nativeObjectPtr,
        jboolean isAuthorized)
{
    using ExampleApp::InteriorsPosition::SdkModel::IndoorAtlas::IndoorAtlasLocationManager;
    reinterpret_cast<IndoorAtlasLocationManager *>(nativeObjectPtr)->SetIsAuthorized(isAuthorized);
}
}

// Copyright eeGeo Ltd (2012-2017), All Rights Reserved

#include <jni.h>

#include "AndroidAppThreadAssertionMacros.h"
#include "IndoorAtlasLocationManager.h"
#include "IndoorAtlasLocationManagerJni.h"

extern "C"
{
JNIEXPORT void JNICALL Java_com_eegeo_interiorsposition_indooratlas_IndoorAtlasLocationManagerJniMethods_DidUpdateLocation(
        JNIEnv *jenv, jclass jobj,
        jlong nativeObjectPtr,
        jdouble latitude,
        jdouble longitude,
        jstring floorId)
{
    std::string floorIdString = "";
    if(floorId != NULL)
    {
        const char *chars = jenv->GetStringUTFChars(floorId, 0);
        floorIdString = chars;
        jenv->ReleaseStringUTFChars(floorId, chars);
    }

    using ExampleApp::InteriorsPosition::SdkModel::IndoorAtlas::IndoorAtlasLocationManager;
    reinterpret_cast<IndoorAtlasLocationManager *>(nativeObjectPtr)->DidUpdateLocation(latitude,
                                                                                longitude,
                                                                                floorIdString);
}

JNIEXPORT void JNICALL Java_com_eegeo_interiorsposition_indooratlas_IndoorAtlasLocationManagerJniMethods_SetIsAuthorized(
        JNIEnv *jenv, jclass obj,
        jlong nativeObjectPtr,
        jboolean isAuthorized)
{
    using ExampleApp::InteriorsPosition::SdkModel::IndoorAtlas::IndoorAtlasLocationManager;
    reinterpret_cast<IndoorAtlasLocationManager *>(nativeObjectPtr)->SetIsAuthorized(isAuthorized);
}
}

Fix for MPLY-9036. Guard against null region values from IA. Buddy: Jordan


/*
 *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include "voice_engine/test/auto_test/fixtures/before_initialization_fixture.h"

#include <cstdlib>

class VoeBaseMiscTest : public BeforeInitializationFixture {
};

using namespace testing;

TEST_F(VoeBaseMiscTest, MaxNumChannelsIs32) {
  EXPECT_EQ(32, voe_base_->MaxNumOfChannels());
}

TEST_F(VoeBaseMiscTest, GetVersionPrintsSomeUsefulInformation) {
  char char_buffer[1024];
  memset(char_buffer, 0, sizeof(char_buffer));
  EXPECT_EQ(0, voe_base_->GetVersion(char_buffer));
  EXPECT_THAT(char_buffer, ContainsRegex("VoiceEngine"));
}

/*
 *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include "voice_engine/test/auto_test/fixtures/before_initialization_fixture.h"

#include <cstdlib>

class VoeBaseMiscTest : public BeforeInitializationFixture {
};

using namespace testing;

TEST_F(VoeBaseMiscTest, MaxNumChannelsIs100) {
  EXPECT_EQ(100, voe_base_->MaxNumOfChannels());
}

TEST_F(VoeBaseMiscTest, GetVersionPrintsSomeUsefulInformation) {
  char char_buffer[1024];
  memset(char_buffer, 0, sizeof(char_buffer));
  EXPECT_EQ(0, voe_base_->GetVersion(char_buffer));
  EXPECT_THAT(char_buffer, ContainsRegex("VoiceEngine"));
}

Fix MaxChannels test; 32 -> 100.

Fix MaxChannels test; 32 -> 100.

TBR=henrika

Review URL: https://webrtc-codereview.appspot.com/1060010

git-svn-id: 03ae4fbe531b1eefc9d815f31e49022782c42458@3460 4adac7df-926f-26a2-2b94-8c16560cd09d


#include <iostream>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <cstring>
#include <string>

#include "rand.h"

using namespace std;

int main() {
  string cipher;

  getline(cin, cipher);
  cout << cipher << endl;

}

#include <iostream>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <cstring>
#include <string>
#include <fstream>

#include "rand.h"

using namespace std;

int main() {
  string cipher, tmp;

  while( getline( cin, tmp ) )
    {
      cipher.append( tmp );
    }
  //  cout << cipher << endl;

  ifstream freq;
  freq.open( "freq.txt", ios::in );

  string freqletter[488];
  int freqnumber[488];

  if( freq.is_open() ) {
    for(int i = 0; i < 488; i++ ) {
      freq >> freqletter[i];
      freq >> freqnumber[i];
    }
  }

  freq.close();

  // for(int i = 0; i < 488; i++ ) {
  //   cout << freqletter[i] << " " << freqnumber[i] << endl;
  // }

}

Read in input and freq.txt

Read in input and freq.txt


//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

#include "swift/Runtime/Config.h"
#include "swift/Runtime/Metadata.h"

using namespace swift;

SWIFT_CC(swift) LLVM_LIBRARY_VISIBILITY extern "C"
uint32_t getMetadataKindOf(
    OpaqueValue *value,
    const Metadata *type
) {
  auto result = uint32_t(type->getKind());
  type->vw_destroy(value);
  return result;
}

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

#include "swift/Runtime/Config.h"
#include "swift/Runtime/Metadata.h"

using namespace swift;

SWIFT_CC(swift) LLVM_LIBRARY_VISIBILITY extern "C"
uint32_t getMetadataKindOf(
    OpaqueValue *value,
    const Metadata *type
) {
  auto result = uint32_t(type->getKind());
  SWIFT_CC_PLUSONE_GUARD(type->vw_destroy(value));
  return result;
}

[stdlibunittest] Update getMetadataKindOf for +0 parameters.

rdar://34222540


#include <iostream>

using std::cin;
using std::cout;

int main() {
  char operation;
  cout << "Choose an operation (+, -, *, /): ";
  cin >> operation;

  double first_operand;
  double second_operand;
  cout << "Enter your operands: ";
  cin >> first_operand >> second_operand;

  double result;

  switch(operation) {
    case '+':
      result = first_operand + second_operand;
      break;
    case '-':
      result = first_operand - second_operand;
      break;
    case '*':
      result = first_operand * second_operand;
      break;
    case '/':
      result = first_operand / second_operand;
      break;
    default:
      cout << "Unknown operation " << operation << '\n';
      return 1;
  }

  cout << first_operand << ' '
       << operation << ' '
       << second_operand << " = "
       << result << '\n';

  return 0;
}

#include <iostream>

using std::cin;
using std::cout;

int main() {
  char operation;
  cout << "Choose an operation (+, -, *, /): ";
  cin >> operation;

  double first_operand;
  double second_operand;
  cout << "Enter your operands: ";
  cin >> first_operand >> second_operand;

  double result;

  switch (operation) {
    case '+':
      result = first_operand + second_operand;
      break;
    case '-':
      result = first_operand - second_operand;
      break;
    case '*':
      result = first_operand * second_operand;
      break;
    case '/':
      result = first_operand / second_operand;
      break;
    default:
      cout << "Unknown operation " << operation << '\n';
      return 1;
  }

  cout << first_operand << ' '
       << operation << ' '
       << second_operand << " = "
       << result << '\n';

  return 0;
}

Add space after switch keyword

Add space after switch keyword


#include <boxer/boxer.h>
#include <gtk/gtk.h>

namespace boxer {

void show(const char *message, const char *title) {
  gtk_init(0, NULL);

  GtkWidget *dialog = gtk_message_dialog_new(NULL,
            GTK_DIALOG_MODAL,
            GTK_MESSAGE_INFO,
            GTK_BUTTONS_OK,
            message);
  gtk_window_set_title(GTK_WINDOW(dialog), title);
  gtk_dialog_run(GTK_DIALOG(dialog));

  gtk_widget_destroy(GTK_WIDGET(dialog));
  while (g_main_context_iteration(NULL, false));
}

} // namespace boxer

#include <boxer/boxer.h>
#include <gtk/gtk.h>

namespace boxer {

void show(const char *message, const char *title) {
  gtk_init(0, NULL);

  GtkWidget *dialog = gtk_message_dialog_new(NULL,
            GTK_DIALOG_MODAL,
            GTK_MESSAGE_INFO,
            GTK_BUTTONS_OK,
            "%s",
            message);
  gtk_window_set_title(GTK_WINDOW(dialog), title);
  gtk_dialog_run(GTK_DIALOG(dialog));

  gtk_widget_destroy(GTK_WIDGET(dialog));
  while (g_main_context_iteration(NULL, false));
}

} // namespace boxer

Add format string to gtk_message_dialog_new()