Skip to content

Instantly share code, notes, and snippets.

View andreysolovyev381's full-sized avatar

Andrey Solovyev andreysolovyev381

View GitHub Profile
@andreysolovyev381
andreysolovyev381 / Simple Unit test.cpp
Created October 4, 2019 08:37
Utils for running a simple Unit Test for any func. Usually "void TestSomething()"
/*
* usage:
* TestRunner tr;
* RUN_TEST(tr, FUNC_NAME);
*
*/
template<class T, class U>
void AssertEqual(const T& t, const U& u, const string& hint = {}) {
@andreysolovyev381
andreysolovyev381 / Log_Duration macros.cpp
Created October 4, 2019 08:18
c++ provides out-of-the box profiler for a piece of code in {}
#include <chrono>
#include <iostream>
#include <string>
using namespace std::chrono;
class LogDuration {
public:
explicit LogDuration(const string& msg = "")
: message(msg + ": ")
@andreysolovyev381
andreysolovyev381 / IteratorRange template.cpp
Created October 4, 2019 08:04
c++ IteratorRange Template (Random Access)
//Iterator range
template <typename Iterator>
struct IteratorRange {
IteratorRange(Iterator First, Iterator Last) : first(First), last(Last) {}
Iterator first , last;
Iterator begin () const {
return first;
}
Iterator end () const {
return last;}