docs icon indicating copy to clipboard operation
docs copied to clipboard

HOWTO: Train on C++ kata locally

Open hobovsky opened this issue 4 years ago • 2 comments

Show how to set up local environment to create C++ kata or train on them.

hobovsky avatar Dec 30 '20 13:12 hobovsky

https://github.com/codewars/docs/pull/311#discussion_r624580345

To make it easier to test locally, the solution template can be changed to the following that can be reused:

// main.cpp
#include <igloo/igloo_alt.h>
#include <igloo/CodewarsTestListener.h>
using namespace igloo;

// Use `#include` to "copy" contents here
#include "preloaded.h" // use empty file if there's no preloaded
#include "solution.cpp"
#include "tests.cpp"

int main(int, const char *[]) {
  NullTestResultsOutput output;
  TestRunner runner(output);
  CodewarsTestListener listener;
  runner.AddListener(&listener);
  runner.Run();
}

hobovsky avatar May 02 '21 10:05 hobovsky

I have set up a Jetbrains Resharper for C++ template with some default includes for new katas like

#include <string>
#include <sstream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <chrono>
#include <cmath>

#include "igloo\igloo_alt.h"
using namespace snowhouse;
using namespace igloo;

// code here
$END$

// test here
Describe(_Tests) {
	It(Is_Ultra_Fast) {
		const auto begin = std::chrono::steady_clock::now();
		// performance test here
		const auto end = std::chrono::steady_clock::now();
		auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count();
		Assert::That(ms, IsLessThan(4000));
	}
};

roboter-basteln avatar Nov 18 '21 20:11 roboter-basteln