From 9a3e59423e4188395b99da0fb26d62c60a75a6dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=BE=D1=80=D0=B5=D0=B2=20=D0=90=D0=BB=D0=B5=D0=BA?= =?UTF-8?q?=D1=81=D0=B0=D0=BD=D0=B4=D1=80?= Date: Fri, 20 Oct 2023 10:25:04 +0300 Subject: [PATCH] Clang format test.cpp on create --- leetcode.py | 3 +++ .../find-the-middle-index-in-array/test.cpp | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/leetcode.py b/leetcode.py index 54f17e31..01a6101f 100644 --- a/leetcode.py +++ b/leetcode.py @@ -1,5 +1,6 @@ import json import re +import subprocess from argparse import ArgumentParser from dataclasses import dataclass from glob import glob @@ -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: diff --git a/solutions/find-the-middle-index-in-array/test.cpp b/solutions/find-the-middle-index-in-array/test.cpp index d1831401..c82de880 100644 --- a/solutions/find-the-middle-index-in-array/test.cpp +++ b/solutions/find-the-middle-index-in-array/test.cpp @@ -4,14 +4,26 @@ TEST_CASE("Simple") { struct TestCase { - std::vector nums;int expected; + std::vector nums; + int expected; }; std::vector 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); }