Skip to content

Commit

Permalink
Update on 01/01/2018
Browse files Browse the repository at this point in the history
  • Loading branch information
tsunghsienlee committed Jan 2, 2018
1 parent 345adde commit 795a744
Show file tree
Hide file tree
Showing 14 changed files with 1,137 additions and 1,130 deletions.
198 changes: 99 additions & 99 deletions epi_judge_cpp/CMakeFiles/CMakeOutput.log

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions epi_judge_cpp/test_framework/test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ std::vector<std::vector<std::string>> SplitTsvFile(
* This function removes all such comments.
*/
std::string FilterBracketComments(const std::string& type) {
static std::regex bracket_enclosed_comment(R"((\[[^\]]*\]))");
auto result = std::regex_replace(type, bracket_enclosed_comment, "");
static const std::regex bracket_enclosed_comment(R"((\[[^\]]*\]))");
std::string result = std::regex_replace(type, bracket_enclosed_comment, "");
result.erase(std::remove_if(std::begin(result), std::end(result), isspace),
std::end(result));
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,9 +734,10 @@ struct BinaryTreeSerializationTraits;
* @tparam HasParent - affects the parent pointer initialization.
*/
template <template <typename...> class SmartPtrT,
template <typename...> class NodeT, typename KeyT,
bool HasParent, typename... MsvcWorkaround>
struct BinaryTreeSerializationTraits<SmartPtrT<NodeT<KeyT>, MsvcWorkaround...>, HasParent> {
template <typename...> class NodeT, typename KeyT, bool HasParent,
typename... MsvcWorkaround>
struct BinaryTreeSerializationTraits<
SmartPtrT<NodeT<KeyT>, MsvcWorkaround...>, HasParent> {
using key_traits = SerializationTraits<KeyT>;
using node_type = NodeT<typename key_traits::serialization_type>;
using serialization_type = SmartPtrT<node_type>;
Expand Down
4 changes: 2 additions & 2 deletions epi_judge_java/epi/Anagrams.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public static List<List<String>> findAnagrams(List<String> dictionary) {
}

@EpiTestComparator
public static BiPredicate < List<List<String>>,
List < List<String>>> comp = (expected, result) -> {
public static BiPredicate<List<List<String>>, List<List<String>>> comp =
(expected, result) -> {
if (result == null) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions epi_judge_java/epi/Combinations.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public static List<List<Integer>> combinations(int n, int k) {
}

@EpiTestComparator
public static BiPredicate < List<List<Integer>>,
List < List<Integer>>> comp = (expected, result) -> {
public static BiPredicate<List<List<Integer>>, List<List<Integer>>> comp =
(expected, result) -> {
if (result == null) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions epi_judge_java/epi/EnumeratePalindromicDecompositions.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public static List<List<String>> palindromeDecompositions(String input) {
}

@EpiTestComparator
public static BiPredicate < List<List<String>>,
List < List<String>>> comp = (expected, result) -> {
public static BiPredicate<List<List<String>>, List<List<String>>> comp =
(expected, result) -> {
if (result == null) {
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions epi_judge_java/epi/GraphClone.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ private static void checkGraph(GraphVertex node, List<GraphVertex> g) {
vertexSet.add(node);
while (!q.isEmpty()) {
GraphVertex vertex = q.remove();
assert(vertex.label < g.size());
assert (vertex.label < g.size());
List<Integer> label1 = copyLabels(vertex.edges),
label2 = copyLabels(g.get(vertex.label).edges);
Collections.sort(label1);
Collections.sort(label2);
assert(label1.size() == label2.size());
assert(Arrays.equals(label1.toArray(), label2.toArray()));
assert (label1.size() == label2.size());
assert (Arrays.equals(label1.toArray(), label2.toArray()));
for (GraphVertex e : vertex.edges) {
if (!vertexSet.contains(e)) {
vertexSet.add(e);
Expand Down
4 changes: 2 additions & 2 deletions epi_judge_java/epi/NQueens.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public static List<List<Integer>> nQueens(int n) {
}

@EpiTestComparator
public static BiPredicate < List<List<Integer>>,
List < List<Integer>>> comp = (expected, result) -> {
public static BiPredicate<List<List<Integer>>, List<List<Integer>>> comp =
(expected, result) -> {
if (result == null) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions epi_judge_java/epi/Permutations.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public static List<List<Integer>> permutations(List<Integer> A) {
}

@EpiTestComparator
public static BiPredicate < List<List<Integer>>,
List < List<Integer>>> comp = (expected, result) -> {
public static BiPredicate<List<List<Integer>>, List<List<Integer>>> comp =
(expected, result) -> {
if (result == null) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions epi_judge_java/epi/PowerSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public static List<List<Integer>> generatePowerSet(List<Integer> inputSet) {
}

@EpiTestComparator
public static BiPredicate < List<List<Integer>>,
List < List<Integer>>> comp = (expected, result) -> {
public static BiPredicate<List<List<Integer>>, List<List<Integer>>> comp =
(expected, result) -> {
if (result == null) {
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion epi_judge_java/epi/test_framework/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ public static boolean doubleComparison(Double d1, Double d2) {
* This method removes all such comments.
*/
public static String filterBracketComments(String s) {
return s.replaceAll("(\\[[^\\]]*\\])", "").replaceAll(" ", "");
final String BRACKET_ENCLOSED_COMMENT = "(\\[[^\\]]*\\])";
return s.replaceAll(BRACKET_ENCLOSED_COMMENT, "").replaceAll(" ", "");
}
}
18 changes: 11 additions & 7 deletions epi_judge_python/test_framework/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ def get_default_test_data_dir_path():
env_result = os.getenv(ENV_KEY, '')
if env_result:
if not os.path.isdir(env_result):
raise RuntimeError('{} environment variable is set to "{}", but it\'s not a directory'
.format(ENV_KEY, env_result))
raise RuntimeError(
'{} environment variable is set to "{}", but it\'s not a directory'
.format(ENV_KEY, env_result))
return env_result

path = DIR_NAME
Expand All @@ -124,7 +125,9 @@ def get_default_test_data_dir_path():
return path
path = os.path.join(os.path.pardir, path)

raise RuntimeError('Can\'t find test data directory. Specify it with {} environment variable (you may need to restart PC) or start the program with "--test_data_dir <path>" command-line option'.format(ENV_KEY))
raise RuntimeError(
'Can\'t find test data directory. Specify it with {} environment variable (you may need to restart PC) or start the program with "--test_data_dir <path>" command-line option'.
format(ENV_KEY))


def completely_sorted(x):
Expand All @@ -146,7 +149,8 @@ def unordered_compare(a, b):


def equal_to(a, b):
"""Expected value comparator.
"""
Expected value comparator.
Compares float values with math.isclose(),
binary trees with equal_binary_trees(),
Expand All @@ -169,9 +173,9 @@ def equal_to(a, b):


def filter_bracket_comments(s):
"""Serialized type name can contain multiple comments,
enclosed into brackets.
This function removes all such comments."""
"""
Serialized type name can contain multiple comments, enclosed into brackets. This function removes all such comments.
"""
bracket_enclosed_comment = r"(\[[^\]]*\])"
return re.sub(bracket_enclosed_comment, '', s, 0).replace(' ', '')

Expand Down
11 changes: 4 additions & 7 deletions epi_judge_python/test_framework/test_utils_generic_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@ def generic_test_main(filename,
:param res_printer - function for customized printing
"""
parser = argparse.ArgumentParser()
parser.add_argument(
'--test_data_dir',
nargs='?',
const=True,
type=str)
parser.add_argument('--test_data_dir', nargs='?', const=True, type=str)
parser.add_argument('--run_all_tests', default=False, action='store_true')
args = parser.parse_args()
if args.test_data_dir:
if not os.path.isdir(args.test_data_dir):
raise RuntimeError('--test_data_dir argument "{}" is not a directory'
.format(args.test_data_dir))
raise RuntimeError(
'--test_data_dir argument "{}" is not a directory'.format(
args.test_data_dir))
else:
args.test_data_dir = test_utils.get_default_test_data_dir_path()

Expand Down
Loading

0 comments on commit 795a744

Please sign in to comment.