Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/classroom/autograding.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"tests": [
{
"name": "just_simple_test",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я сделал семейство заведомо позитивных и заведомо негативных тестовых файлов.
Нужно как-то учесть это в скрипте CI.

"setup": "",
"run": "CI=1 cmake . && make just_simple_test",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше, наверно, не через окружение (мало ли, будет конфликтовать), а через дефайны комстроки?
cmake . -Ddisable_gtest=1 && .....

"input": "",
"output": "",
"comparison": "included",
"timeout": 1,
"points": null
},
{
"name": "test_using_simple_test",
"setup": "",
"run": "CI=1 cmake . && make test_using_simple_test",
"input": "",
"output": "",
"comparison": "included",
"timeout": 1,
"points": null
}
]
}
22 changes: 22 additions & 0 deletions .github/workflows/classroom.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: GitHub Classroom Workflow

on: [push]

permissions:
checks: write
actions: read
contents: read

jobs:
build:
name: Test in autograding env
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: education/autograding@v1
manual-run:
name: Test in step env
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: cmake . && make all
13 changes: 8 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra-semi -O1 -g -fsanitize=address -fno-omit-frame-pointer")
endif()

if(DEFINED ENV{CI})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше не через ENV управлять, наверное.

А также можно попробовать сделать локальную сборку GTest

message("Skipping gtest part")
else()
find_package(GTest REQUIRED)
include(GoogleTest)

find_package(GTest REQUIRED)
include(GoogleTest)
add_executable(test_using_gtest test_using_gtest.cpp gtest_compatible_test.h)
target_link_libraries(test_using_gtest GTest::gtest GTest::gtest_main)
endif()

add_executable(just_simple_test just_simple_test.cpp simple_test.h)

add_executable(test_using_simple_test test_using_simple_test.cpp gtest_compatible_test.h simple_test.h)

add_executable(test_using_gtest test_using_gtest.cpp gtest_compatible_test.h)
target_link_libraries(test_using_gtest GTest::gtest GTest::gtest_main)
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Original repository: https://github.com/nickolaym/simple_test
## Macros

### TEST
```

```c++
TEST(suite, name, [enabled]) {
test body goes here;
}
Expand All @@ -24,7 +25,8 @@ TEST(suite, name, [enabled]) {
- `enabled` is optional bool expression (runtime constant, evaluated before main())

introduces auxillary object test_name and function
```

```c++
void func_name() {
test body goes here;
}
Expand All @@ -36,7 +38,8 @@ Please don't catch(...) inside it without special need.
GTest compatibility: if suite or name starts with `DISABLED`, the test will skip.

### ASSERT_..., EXPECT_...
```

```c++
ASSERT_CMP(a, op, b)
EXPECT_CMP(a, op, b)
ASSERT_EQ, ASSERT_LT, ASSERT_LE, ... as in GTest
Expand Down Expand Up @@ -72,7 +75,7 @@ So, they should be printable.

To print extra messages if an assetion fails, use following syntax:

```
```c++
ASSERT_BLABLABLA() << common << C++ << stream << args;

ASSERTION_FAULT(common, C++, stream, args);
Expand All @@ -82,7 +85,7 @@ Note that if the assertion passes, nothing will evaluate.

### Show green assertions

```
```c++
SHOW_GREEN_ASSERTIONS(flag)
```
where `flag` is boolean
Expand All @@ -98,7 +101,8 @@ See examples in just_simple_test.cpp
Just implementation of `int main()`

Feel free to call a subsequent function from your `main()` with your fixtures:
```

```c++
int main(int argc, char** argv) {
...
int result = simple_test::testing_main(argc, argv);
Expand All @@ -109,7 +113,7 @@ int main(int argc, char** argv) {

#### Arguments

```
```c++
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь баш, а не C++

your_test_application [-h] [--help] [-l] [--list] {patterns}
```

Expand Down
4 changes: 2 additions & 2 deletions just_simple_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ TEST(should_fail, vector_capacity) {
std::vector<int> xs;
xs.reserve(100500);
xs.clear();
EXPECT_CMP(xs.capacity(), ==, 0) << " ahaha ? ahaha!";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я перенёс и отрефакторил этот файл, пожалуйста, отребейзься на свежий мастер

ASSERT_CMP(xs.size(), ==, 1) << " ahaha ? ahaha!";
EXPECT_CMP(xs.capacity(), ==, 0ul) << " ahaha ? ahaha!";
ASSERT_CMP(xs.size(), ==, 1ul) << " ahaha ? ahaha!";
}

TEST(should_fail, lots_of_failed_expectations) {
Expand Down