mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 21:09:41 +00:00
New translations test-framework.mdx (Russian)
[ci skip]
This commit is contained in:
@@ -1,33 +1,33 @@
|
|||||||
---
|
---
|
||||||
sidebar_label: Test framework (EXPECT, TEST, ...)
|
sidebar_label: Тестовая инфраструктура (EXPECT, TEST, ...)
|
||||||
---
|
---
|
||||||
|
|
||||||
# Test Framework
|
# Тестовая инфраструктура
|
||||||
|
|
||||||
DCR has a built-in minimal test framework for C.
|
DCR имеет встроенный минималистичный фреймворк для тестирования на C/C++.
|
||||||
|
|
||||||
## Macros
|
## Макросы
|
||||||
|
|
||||||
### `EXPECT(expr)`
|
### `EXPECT(expr, ...)`
|
||||||
|
|
||||||
Asserts that an expression is true.
|
Проверяет, что выражение истинно.
|
||||||
|
|
||||||
```c
|
```c
|
||||||
EXPECT(1 + 1 == 2);
|
EXPECT(1 + 1 == 2);
|
||||||
EXPECT(ptr != NULL);
|
EXPECT(ptr != NULL, "ptr should not be NULL");
|
||||||
```
|
```
|
||||||
|
|
||||||
### `SKIP(reason)`
|
### `SKIP(...)`
|
||||||
|
|
||||||
Skips a test with a message.
|
Пропускает тест с опциональным сообщением.
|
||||||
|
|
||||||
```c
|
```c
|
||||||
SKIP("not implemented on Windows");
|
SKIP("not implemented on Windows yet");
|
||||||
```
|
```
|
||||||
|
|
||||||
### `TEST(name)`
|
### `TEST(name)`
|
||||||
|
|
||||||
Defines a test.
|
Определяет тест.
|
||||||
|
|
||||||
```c
|
```c
|
||||||
TEST(addition) {
|
TEST(addition) {
|
||||||
@@ -36,34 +36,34 @@ TEST(addition) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### `TEST_CASE(name)`
|
### `TEST_CASE(name, ...)`
|
||||||
|
|
||||||
Registers a test case.
|
Registers a test case.
|
||||||
|
|
||||||
```c
|
```c
|
||||||
TEST_CASE(math) {
|
TEST_CASE(math, a, b) {
|
||||||
EXPECT(1 + 1 == 2);
|
EXPECT(a + b == b + a);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Initialization
|
## Инициализация
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
dcr test --init
|
dcr test --init
|
||||||
```
|
```
|
||||||
|
|
||||||
Creates:
|
Создаются файлы:
|
||||||
|
|
||||||
* `tests/dcr_test.h` — framework header (do not edit)
|
* `tests/dcr_test.h` — заголовочный файл фреймворка
|
||||||
* `tests/test.c` — template with example test
|
* `tests/test.c` — шаблон с примером теста
|
||||||
|
|
||||||
## Structure
|
## Структура tests/
|
||||||
|
|
||||||
```
|
```
|
||||||
tests/
|
tests/
|
||||||
├── dcr_test.h # framework (do not edit)
|
├── dcr_test.h # фреймворк (не редактировать)
|
||||||
├── test.c # main tests
|
├── test.c # основные тесты
|
||||||
└── ... # additional .c test files
|
└── ... # дополнительные .c файлы с тестами
|
||||||
```
|
```
|
||||||
|
|
||||||
Only `.c` files are compiled (`.cpp` is not supported).
|
Only `.c` files are compiled (`.cpp` is not supported).
|
||||||
|
|||||||
Reference in New Issue
Block a user