style: 更新 .clang-format 规则并重新格式化所有源文件
- 重构模块使用新的代码风格 - 老代码 (src 目录下的代码) 继续使用之前的代码风格 通过在需要不同代码风格的目录下放对应 .clang-format 配置文件实现
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
#include "config/loader.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config/loader.h"
|
||||
#include "helpers.h"
|
||||
|
||||
static void test_config_loader_loads_explicit_override(const char *fixture_path) {
|
||||
static void test_config_loader_loads_explicit_override(
|
||||
const char *fixture_path
|
||||
) {
|
||||
config_test_clear_env();
|
||||
|
||||
config_loader_t loader = {0};
|
||||
@@ -22,9 +23,12 @@ static void test_config_loader_loads_explicit_override(const char *fixture_path)
|
||||
}
|
||||
|
||||
static void test_config_loader_override_has_priority_over_env(
|
||||
const char *fixture_path) {
|
||||
const char *fixture_path
|
||||
) {
|
||||
config_test_clear_env();
|
||||
assert(setenv("ZDWM_CONFIG_LIB", "/tmp/definitely-missing-config.so", 1) == 0);
|
||||
assert(
|
||||
setenv("ZDWM_CONFIG_LIB", "/tmp/definitely-missing-config.so", 1) == 0
|
||||
);
|
||||
|
||||
config_loader_t loader = {0};
|
||||
assert(config_loader_load(&loader, fixture_path));
|
||||
@@ -37,7 +41,8 @@ static void test_config_loader_override_has_priority_over_env(
|
||||
}
|
||||
|
||||
static void test_config_loader_uses_zdwm_config_lib_env(
|
||||
const char *fixture_path) {
|
||||
const char *fixture_path
|
||||
) {
|
||||
config_test_clear_env();
|
||||
assert(setenv("ZDWM_CONFIG_LIB", fixture_path, 1) == 0);
|
||||
|
||||
@@ -54,15 +59,22 @@ static void test_config_loader_uses_zdwm_config_lib_env(
|
||||
static void test_config_loader_uses_xdg_config_home(const char *fixture_path) {
|
||||
config_test_clear_env();
|
||||
|
||||
char temp_root[PATH_MAX] = {0};
|
||||
char config_dir[PATH_MAX] = {0};
|
||||
char temp_root[PATH_MAX] = {0};
|
||||
char config_dir[PATH_MAX] = {0};
|
||||
char config_path[PATH_MAX] = {0};
|
||||
|
||||
config_test_make_temp_dir(temp_root, sizeof(temp_root),
|
||||
"zdwm-config-loader-xdg");
|
||||
config_test_make_temp_dir(
|
||||
temp_root,
|
||||
sizeof(temp_root),
|
||||
"zdwm-config-loader-xdg"
|
||||
);
|
||||
config_test_join_path(config_dir, sizeof(config_dir), temp_root, "zdwm");
|
||||
config_test_join_path(config_path, sizeof(config_path), config_dir,
|
||||
"config.so");
|
||||
config_test_join_path(
|
||||
config_path,
|
||||
sizeof(config_path),
|
||||
config_dir,
|
||||
"config.so"
|
||||
);
|
||||
config_test_mkdir(config_dir);
|
||||
config_test_symlink(fixture_path, config_path);
|
||||
assert(setenv("XDG_CONFIG_HOME", temp_root, 1) == 0);
|
||||
@@ -83,17 +95,24 @@ static void test_config_loader_uses_xdg_config_home(const char *fixture_path) {
|
||||
static void test_config_loader_uses_home_fallback(const char *fixture_path) {
|
||||
config_test_clear_env();
|
||||
|
||||
char temp_root[PATH_MAX] = {0};
|
||||
char temp_root[PATH_MAX] = {0};
|
||||
char config_root[PATH_MAX] = {0};
|
||||
char zdwm_dir[PATH_MAX] = {0};
|
||||
char zdwm_dir[PATH_MAX] = {0};
|
||||
char config_path[PATH_MAX] = {0};
|
||||
|
||||
config_test_make_temp_dir(temp_root, sizeof(temp_root),
|
||||
"zdwm-config-loader-home");
|
||||
config_test_make_temp_dir(
|
||||
temp_root,
|
||||
sizeof(temp_root),
|
||||
"zdwm-config-loader-home"
|
||||
);
|
||||
config_test_join_path(config_root, sizeof(config_root), temp_root, ".config");
|
||||
config_test_join_path(zdwm_dir, sizeof(zdwm_dir), config_root, "zdwm");
|
||||
config_test_join_path(config_path, sizeof(config_path), zdwm_dir,
|
||||
"config.so");
|
||||
config_test_join_path(
|
||||
config_path,
|
||||
sizeof(config_path),
|
||||
zdwm_dir,
|
||||
"config.so"
|
||||
);
|
||||
config_test_mkdir(config_root);
|
||||
config_test_mkdir(zdwm_dir);
|
||||
config_test_symlink(fixture_path, config_path);
|
||||
@@ -116,13 +135,20 @@ static void test_config_loader_uses_home_fallback(const char *fixture_path) {
|
||||
static void test_config_loader_allows_missing_implicit_library(void) {
|
||||
config_test_clear_env();
|
||||
|
||||
char temp_root[PATH_MAX] = {0};
|
||||
char temp_root[PATH_MAX] = {0};
|
||||
char expected_path[PATH_MAX] = {0};
|
||||
|
||||
config_test_make_temp_dir(temp_root, sizeof(temp_root),
|
||||
"zdwm-config-loader-missing");
|
||||
config_test_join_path(expected_path, sizeof(expected_path), temp_root,
|
||||
"zdwm/config.so");
|
||||
config_test_make_temp_dir(
|
||||
temp_root,
|
||||
sizeof(temp_root),
|
||||
"zdwm-config-loader-missing"
|
||||
);
|
||||
config_test_join_path(
|
||||
expected_path,
|
||||
sizeof(expected_path),
|
||||
temp_root,
|
||||
"zdwm/config.so"
|
||||
);
|
||||
assert(setenv("XDG_CONFIG_HOME", temp_root, 1) == 0);
|
||||
|
||||
config_loader_t loader = {0};
|
||||
@@ -147,7 +173,8 @@ static void test_config_loader_rejects_missing_explicit_library(void) {
|
||||
}
|
||||
|
||||
static void test_config_loader_rejects_library_without_setup(
|
||||
const char *fixture_path) {
|
||||
const char *fixture_path
|
||||
) {
|
||||
config_test_clear_env();
|
||||
|
||||
config_loader_t loader = {0};
|
||||
|
||||
Reference in New Issue
Block a user