I understand googletest is for C++ Unit testing. However, I hope that I can use it for C Unit testing as well. I created a Hello world project with the following CmakeList.txt file which obviously didn't work.
One of the issue was /usr/bin/cc complained about C++ syntax such as "include < limits >" not found. I guess it though it was supposed to be limits.h to be C stylistically correct.
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);
}