我了解googletest适用于C ++单元测试。但是,我希望我也可以将其用于C单元测试。我使用以下CmakeList.txt文件创建了一个Hello world项目,该文件显然不起作用。
问题之一是/ usr / bin / cc抱怨找不到C ++语法,例如“ include
cmake_minimum_required(VERSION 3.10)
project(untitled C CXX)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_VERBOSE_MAKEFILE 1)
include_directories(../googletest/googletest/include)
add_executable(untitled main.c)
link_libraries(untitled gtest gtest_main)
main.c
#include <stdio.h>
#include <gtest/gtest.h>
int return_one()
{
return 1;
}
TEST(test_case, test_name)
{
ASSERT_EQ(return_one(), 1);
}