Skip to content

Commit

Permalink
Clang format test.cpp on create
Browse files Browse the repository at this point in the history
  • Loading branch information
hikjik committed Oct 20, 2023
1 parent 6e0953c commit 9a3e594
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions leetcode.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import re
import subprocess
from argparse import ArgumentParser
from dataclasses import dataclass
from glob import glob
Expand Down Expand Up @@ -550,6 +551,8 @@ def create_test_file(task_path: Path, task: Task) -> None:
with open(task_path / TEST_FILE, "w") as file:
file.write(content)

subprocess.run(["clang-format", "-i", task_path / TEST_FILE])


def create_cmake_file(task_path: Path, task: Task) -> None:
with open(task_path / CMAKE_LISTS_FILE, "w") as file:
Expand Down
18 changes: 15 additions & 3 deletions solutions/find-the-middle-index-in-array/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,26 @@

TEST_CASE("Simple") {
struct TestCase {
std::vector<int> nums;int expected;
std::vector<int> nums;
int expected;
};

std::vector<TestCase> test_cases{
{.nums{2,3,-1,8,4},.expected=3,},{.nums{1,-1,4},.expected=2,},{.nums{2,5},.expected=-1,},
{
.nums{2, 3, -1, 8, 4},
.expected = 3,
},
{
.nums{1, -1, 4},
.expected = 2,
},
{
.nums{2, 5},
.expected = -1,
},
};

for (const auto &[nums,expected] : test_cases) {
for (const auto &[nums, expected] : test_cases) {
const auto actual = Solution::findMiddleIndex(nums);
REQUIRE(expected == actual);
}
Expand Down

0 comments on commit 9a3e594

Please sign in to comment.