1
0
mirror of https://github.com/ThrowTheSwitch/Unity.git synced 2026-01-24 08:51:36 +01:00
Files
Unity/extras/fixture/test/unity_output_Spy.c
mvandervoord 57178b9295 - tweaked parameterized tests to be C99 standards compliant
- fixed a few bugs in fixtures to get it to pass against our standard compilers
- added extern of OUTPUT_CHAR method to keep compilers from complaining

git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@107 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
2010-12-01 01:56:24 +00:00

57 lines
1.0 KiB
C

//- Copyright (c) 2010 James Grenning and Contributed to Unity Project
/* ==========================================
Unity Project - A Test Framework for C
Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
[Released under MIT License. Please refer to license.txt for details]
========================================== */
#include "unity_output_Spy.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static int size;
static int count;
static char* buffer;
static int spy_enable;
void UnityOutputCharSpy_Create(int s)
{
size = s;
count = 0;
spy_enable = 0;
buffer = malloc(size);
memset(buffer, 0, size);
}
void UnityOutputCharSpy_Destroy()
{
size = 0;
free(buffer);
}
int UnityOutputCharSpy_OutputChar(int c)
{
if (spy_enable)
{
if (count < (size-1))
buffer[count++] = c;
}
else
{
putchar(c);
}
return c;
}
const char * UnityOutputCharSpy_Get()
{
return buffer;
}
void UnityOutputCharSpy_Enable(int enable)
{
spy_enable = enable;
}