mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-12 20:32:15 +00:00
Add CMake and Unity test framework for c99
This commit is contained in:
parent
92bb72732e
commit
2cce0e4a4a
31
c99/CMakeLists.txt
Normal file
31
c99/CMakeLists.txt
Normal file
@ -0,0 +1,31 @@
|
||||
cmake_minimum_required(VERSION 2.8.4)
|
||||
project(GildedRose_c99)
|
||||
|
||||
enable_testing()
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(unity
|
||||
GIT_REPOSITORY https://github.com/ThrowTheSwitch/Unity.git
|
||||
GIT_TAG master
|
||||
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/unity-src"
|
||||
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/unity-build"
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/unity-src/src/unity.c
|
||||
DEPENDS unity
|
||||
COMMAND "")
|
||||
|
||||
|
||||
add_executable( GildedRose_Unity
|
||||
GildedRose.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/unity-src/src/unity.c
|
||||
test_unity_gildedrose.c
|
||||
)
|
||||
target_include_directories(GildedRose_Unity PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/unity-src/src/)
|
||||
set_property(TARGET GildedRose_Unity PROPERTY C_STANDARD 99)
|
||||
add_dependencies(GildedRose_Unity unity)
|
||||
|
||||
add_test(NAME GildedRose_Unity COMMAND GildedRose_Unity)
|
||||
8
c99/run-once-cmake.sh
Executable file
8
c99/run-once-cmake.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ ! -d build ]]; then
|
||||
mkdir -p build
|
||||
fi
|
||||
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=DEBUG && cmake --build . && ctest --output-on-failure
|
||||
18
c99/test_unity_gildedrose.c
Normal file
18
c99/test_unity_gildedrose.c
Normal file
@ -0,0 +1,18 @@
|
||||
#include "unity.h"
|
||||
#include "GildedRose.h"
|
||||
|
||||
void test_NameOfItem(void)
|
||||
{
|
||||
Item items[1];
|
||||
init_item(items, "Foo", 0, 0);
|
||||
update_quality(items, 1);
|
||||
TEST_ASSERT_EQUAL_STRING( "fixme", items[0].name );
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
UNITY_BEGIN();
|
||||
RUN_TEST(test_NameOfItem);
|
||||
return UNITY_END();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user