Permalink
Browse files

Update test framework and test data

  • Loading branch information...
metopa committed May 2, 2018
1 parent c41bf8f commit 007d3509f6d7ba16627f9f0cb27a854d5d398f6c
Showing 1,397 changed files with 78,334 additions and 74,391 deletions.
@@ -4,13 +4,14 @@
using std::vector;
vector<double> GenerateFirstKABSqrt2(int k) {
// Implement this placeholder.
// TODO - you fill in here.
return {};
}
int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"k"};
return GenericTestMain(args, "a_b_sqrt2.tsv", &GenerateFirstKABSqrt2,
DefaultComparator{}, param_names);
return GenericTestMain(args, "a_b_sqrt2.cc", "a_b_sqrt2.tsv",
&GenerateFirstKABSqrt2, DefaultComparator{},
param_names);
}
@@ -9,7 +9,7 @@ using std::vector;
int FindMissingElement(vector<int>::const_iterator stream_begin,
const vector<int>::const_iterator& stream_end) {
// Implement this placeholder.
// TODO - you fill in here.
return 0;
}
@@ -24,7 +24,7 @@ int FindMissingElementWrapper(const vector<int>& stream) {
int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"stream"};
return GenericTestMain(args, "absent_value_array.tsv",
&FindMissingElementWrapper, DefaultComparator{},
param_names);
return GenericTestMain(args, "absent_value_array.cc",
"absent_value_array.tsv", &FindMissingElementWrapper,
DefaultComparator{}, param_names);
}
@@ -9,27 +9,27 @@ using std::string;
class ClientsCreditsInfo {
public:
void Insert(const string& client_id, int c) {
// Implement this placeholder.
// TODO - you fill in here.
return;
}
bool Remove(const string& client_id) {
// Implement this placeholder.
// TODO - you fill in here.
return true;
}
int Lookup(const string& client_id) const {
// Implement this placeholder.
// TODO - you fill in here.
return 0;
}
void AddAll(int C) {
// Implement this placeholder.
// TODO - you fill in here.
return;
}
string Max() const {
// Implement this placeholder.
// TODO - you fill in here.
return "";
}
};
@@ -91,6 +91,7 @@ void ClientsCreditsInfoTester(const std::vector<Operation>& ops) {
int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"ops"};
return GenericTestMain(args, "adding_credits.tsv", &ClientsCreditsInfoTester,
DefaultComparator{}, param_names);
return GenericTestMain(args, "adding_credits.cc", "adding_credits.tsv",
&ClientsCreditsInfoTester, DefaultComparator{},
param_names);
}
@@ -4,13 +4,14 @@
using std::vector;
bool CanReachEnd(const vector<int>& max_advance_steps) {
// Implement this placeholder.
// TODO - you fill in here.
return true;
}
int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"max_advance_steps"};
return GenericTestMain(args, "advance_by_offsets.tsv", &CanReachEnd,
return GenericTestMain(args, "advance_by_offsets.cc",
"advance_by_offsets.tsv", &CanReachEnd,
DefaultComparator{}, param_names);
}
@@ -9,7 +9,7 @@
using std::vector;
void Rearrange(vector<int>* A_ptr) {
// Implement this placeholder.
// TODO - you fill in here.
return;
}
@@ -60,6 +60,6 @@ void RearrangeWrapper(TimedExecutor& executor, vector<int> A) {
int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"executor", "A"};
return GenericTestMain(args, "alternating_array.tsv", &RearrangeWrapper,
DefaultComparator{}, param_names);
return GenericTestMain(args, "alternating_array.cc", "alternating_array.tsv",
&RearrangeWrapper, DefaultComparator{}, param_names);
}
@@ -6,14 +6,14 @@ using std::string;
using std::vector;
vector<vector<string>> FindAnagrams(const vector<string>& dictionary) {
// Implement this placeholder.
// TODO - you fill in here.
return {};
}
int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"dictionary"};
return GenericTestMain(
args, "anagrams.tsv", &FindAnagrams,
args, "anagrams.cc", "anagrams.tsv", &FindAnagrams,
&UnorderedComparator<std::vector<std::vector<std::string>>>, param_names);
}
@@ -4,7 +4,7 @@
using std::vector;
void ApplyPermutation(vector<int>* perm_ptr, vector<int>* A_ptr) {
// Implement this placeholder.
// TODO - you fill in here.
return;
}
@@ -16,7 +16,7 @@ vector<int> ApplyPermutationWrapper(vector<int> perm, vector<int> A) {
int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"perm", "A"};
return GenericTestMain(args, "apply_permutation.tsv",
return GenericTestMain(args, "apply_permutation.cc", "apply_permutation.tsv",
&ApplyPermutationWrapper, DefaultComparator{},
param_names);
}
@@ -4,13 +4,13 @@
using std::vector;
bool IsArbitrageExist(vector<vector<double>> graph) {
// Implement this placeholder.
// TODO - you fill in here.
return true;
}
int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"graph"};
return GenericTestMain(args, "arbitrage.tsv", &IsArbitrageExist,
DefaultComparator{}, param_names);
return GenericTestMain(args, "arbitrage.cc", "arbitrage.tsv",
&IsArbitrageExist, DefaultComparator{}, param_names);
}
@@ -2,7 +2,7 @@
#include <memory>
#include <random>
#include "test_framework/binary_tree_utils.h"
#include "test_framework/test_utils_serialization_traits.h"
#include "test_framework/serialization_traits.h"
#pragma once
@@ -1,6 +1,6 @@
#include <memory>
#include "test_framework/binary_tree_utils.h"
#include "test_framework/test_utils_serialization_traits.h"
#include "test_framework/serialization_traits.h"
#pragma once
@@ -1,14 +1,14 @@
#include "test_framework/generic_test.h"
int ComputeBinomialCoefficient(int n, int k) {
// Implement this placeholder.
// TODO - you fill in here.
return 0;
}
int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"n", "k"};
return GenericTestMain(args, "binomial_coefficients.tsv",
&ComputeBinomialCoefficient, DefaultComparator{},
param_names);
return GenericTestMain(
args, "binomial_coefficients.cc", "binomial_coefficients.tsv",
&ComputeBinomialCoefficient, DefaultComparator{}, param_names);
}
@@ -4,13 +4,13 @@
using std::vector;
int CalculateBonus(const vector<int>& productivity) {
// Implement this placeholder.
// TODO - you fill in here.
return 0;
}
int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"productivity"};
return GenericTestMain(args, "bonus.tsv", &CalculateBonus,
return GenericTestMain(args, "bonus.cc", "bonus.tsv", &CalculateBonus,
DefaultComparator{}, param_names);
}
@@ -8,13 +8,14 @@ using std::vector;
unique_ptr<BstNode<int>> RebuildBSTFromPreorder(
const vector<int>& preorder_sequence) {
// Implement this placeholder.
// TODO - you fill in here.
return nullptr;
}
int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"preorder_sequence"};
return GenericTestMain(args, "bst_from_preorder.tsv", &RebuildBSTFromPreorder,
DefaultComparator{}, param_names);
return GenericTestMain(args, "bst_from_preorder.cc", "bst_from_preorder.tsv",
&RebuildBSTFromPreorder, DefaultComparator{},
param_names);
}
@@ -12,7 +12,7 @@ using std::vector;
unique_ptr<BstNode<int>> BuildMinHeightBSTFromSortedArray(
const vector<int>& A) {
// Implement this placeholder.
// TODO - you fill in here.
return nullptr;
}
@@ -30,7 +30,8 @@ int BuildMinHeightBSTFromSortedArrayWrapper(TimedExecutor& executor,
int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"executor", "A"};
return GenericTestMain(args, "bst_from_sorted_array.tsv",
return GenericTestMain(args, "bst_from_sorted_array.cc",
"bst_from_sorted_array.tsv",
&BuildMinHeightBSTFromSortedArrayWrapper,
DefaultComparator{}, param_names);
}
@@ -7,13 +7,13 @@ using std::shared_ptr;
shared_ptr<BstNode<int>> MergeTwoBSTs(shared_ptr<BstNode<int>> A,
shared_ptr<BstNode<int>> B) {
// Implement this placeholder.
// TODO - you fill in here.
return nullptr;
}
int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"A", "B"};
return GenericTestMain(args, "bst_merge.tsv", &MergeTwoBSTs,
return GenericTestMain(args, "bst_merge.cc", "bst_merge.tsv", &MergeTwoBSTs,
DefaultComparator{}, param_names);
}
@@ -1,6 +1,6 @@
#include <memory>
#include "test_framework/binary_tree_utils.h"
#include "test_framework/test_utils_serialization_traits.h"
#include "test_framework/serialization_traits.h"
#pragma once
@@ -1,6 +1,6 @@
#include <memory>
#include "test_framework/binary_tree_utils.h"
#include "test_framework/test_utils_serialization_traits.h"
#include "test_framework/serialization_traits.h"
#pragma once
@@ -10,15 +10,15 @@ using std::shared_ptr;
shared_ptr<BstNode<int>> BSTToDoublyLinkedList(
const shared_ptr<BstNode<int>>& tree) {
// Implement this placeholder.
// TODO - you fill in here.
return nullptr;
}
std::vector<int> BSTToDoublyLinkedListWrapper(
TimedExecutor& executor, const std::shared_ptr<BstNode<int>>& tree) {
auto list = executor.Run([&] { return BSTToDoublyLinkedList(tree); });
if (list->left) {
if (list && list->left) {
throw TestFailure(
"Function must return the head of the list. Left link must be null");
}
@@ -36,7 +36,7 @@ std::vector<int> BSTToDoublyLinkedListWrapper(
int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"executor", "tree"};
return GenericTestMain(args, "bst_to_sorted_list.tsv",
&BSTToDoublyLinkedListWrapper, DefaultComparator{},
param_names);
return GenericTestMain(
args, "bst_to_sorted_list.cc", "bst_to_sorted_list.tsv",
&BSTToDoublyLinkedListWrapper, DefaultComparator{}, param_names);
}
@@ -4,13 +4,14 @@
using std::vector;
double BuyAndSellStockOnce(const vector<double>& prices) {
// Implement this placeholder.
// TODO - you fill in here.
return 0.0;
}
int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"prices"};
return GenericTestMain(args, "buy_and_sell_stock.tsv", &BuyAndSellStockOnce,
return GenericTestMain(args, "buy_and_sell_stock.cc",
"buy_and_sell_stock.tsv", &BuyAndSellStockOnce,
DefaultComparator{}, param_names);
}
@@ -4,14 +4,14 @@
using std::vector;
double BuyAndSellStockKTimes(const vector<double>& prices, int k) {
// Implement this placeholder.
// TODO - you fill in here.
return 0.0;
}
int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"prices", "k"};
return GenericTestMain(args, "buy_and_sell_stock_k_times.tsv",
&BuyAndSellStockKTimes, DefaultComparator{},
param_names);
return GenericTestMain(
args, "buy_and_sell_stock_k_times.cc", "buy_and_sell_stock_k_times.tsv",
&BuyAndSellStockKTimes, DefaultComparator{}, param_names);
}
@@ -4,14 +4,14 @@
using std::vector;
double BuyAndSellStockTwice(const vector<double>& prices) {
// Implement this placeholder.
// TODO - you fill in here.
return 0.0;
}
int main(int argc, char* argv[]) {
std::vector<std::string> args{argv + 1, argv + argc};
std::vector<std::string> param_names{"prices"};
return GenericTestMain(args, "buy_and_sell_stock_twice.tsv",
&BuyAndSellStockTwice, DefaultComparator{},
param_names);
return GenericTestMain(args, "buy_and_sell_stock_twice.cc",
"buy_and_sell_stock_twice.tsv", &BuyAndSellStockTwice,
DefaultComparator{}, param_names);
}
Oops, something went wrong.

0 comments on commit 007d350

Please sign in to comment.