docs
docs copied to clipboard
HOWTO: Train on C++ kata locally
Show how to set up local environment to create C++ kata or train on them.
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();
}
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));
}
};