LINUX.ORG.RU

gtest parametrized tests


0

1

Зравствуйте! Пытаюсь сделать параметризированные тесты с gtest по мануалу с https://google.github.io/googletest/advanced.html, ругается на inaccessible имена

$ tree .
.
├── CMakeLists.txt
├── test.cpp
├── test.h
└── test_test.cpp
$ cat test.cpp
#include "test.h"

int test_func(int n) {
    return n * n;
}
$ cat test.h
#ifndef TEST_H_PCMBX5R8
#define TEST_H_PCMBX5R8

int test_func(int);

#endif /* end of include guard: TEST_H_PCMBX5R8 */
$ cat test_test.cpp 
#include "test.h"

#include <gtest/gtest.h>

class TestF : ::testing::TestWithParam<int> {};

TEST_P(TestF, SomeTest) {ASSERT_EQ(GetParam(), 1);}

INSTANTIATE_TEST_CASE_P(SomeTests, TestF, ::testing::Values(1));

int main(int argc, char *argv[]) {
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}
$ mkdir build
$ cd build
$ cmake ..
-- The C compiler identification is GNU 11.1.0
-- The CXX compiler identification is GNU 11.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mikhail/Projects/poc

Вывод make: https://pastebin.com/pdc7qaFB

Воспроизводится на

  • Ubuntu 20.04/5.4.0-81-generic/gcc=9.3.0/cmake=3.16.3

  • archlinux/5.12.8-arch1-1/gcc=11.1.0/cmake=3.21.2

ЧЯДНТ?