Adding all tracks, I guess
This commit is contained in:
parent
51aa078388
commit
fab045379a
53
c/hello-world/README.md
Normal file
53
c/hello-world/README.md
Normal file
@ -0,0 +1,53 @@
|
||||
# Hello World
|
||||
|
||||
The classical introductory exercise. Just say "Hello, World!".
|
||||
|
||||
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
|
||||
the traditional first program for beginning programming in a new language
|
||||
or environment.
|
||||
|
||||
The objectives are simple:
|
||||
|
||||
- Write a function that returns the string "Hello, World!".
|
||||
- Run the test suite and make sure that it succeeds.
|
||||
- Submit your solution and check it at the website.
|
||||
|
||||
If everything goes well, you will be ready to fetch your first real exercise.
|
||||
|
||||
## Getting Started
|
||||
|
||||
Make sure you have read the
|
||||
[C page](http://exercism.io/languages/c) on the Exercism site. This covers
|
||||
the basic information on setting up the development environment expected
|
||||
by the exercises.
|
||||
|
||||
|
||||
## Passing the Tests
|
||||
|
||||
Get the first test compiling, linking and passing by following the [three
|
||||
rules of test-driven development][3-tdd-rules].
|
||||
|
||||
The included makefile can be used to create and run the tests using the `test`
|
||||
task.
|
||||
|
||||
make test
|
||||
|
||||
Create just the functions you need to satisfy any compiler errors and get the
|
||||
test to fail. Then write just enough code to get the test to pass. Once you've
|
||||
done that, move onto the next test.
|
||||
|
||||
[3-tdd-rules]: http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd
|
||||
|
||||
As you progress through the tests, take the time to refactor your
|
||||
implementation for readability and expressiveness and then go on to the next
|
||||
test.
|
||||
|
||||
Try to use standard C99 facilities in preference to writing your own
|
||||
low-level algorithms or facilities by hand.
|
||||
|
||||
## Source
|
||||
|
||||
This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)
|
||||
|
||||
## Submitting Incomplete Solutions
|
||||
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
25
c/hello-world/makefile
Normal file
25
c/hello-world/makefile
Normal file
@ -0,0 +1,25 @@
|
||||
CFLAGS = -std=c99
|
||||
CFLAGS += -g
|
||||
CFLAGS += -Wall
|
||||
CFLAGS += -Wextra
|
||||
CFLAGS += -pedantic
|
||||
CFLAGS += -Werror
|
||||
|
||||
VFLAGS = --quiet
|
||||
VFLAGS += --tool=memcheck
|
||||
VFLAGS += --leak-check=full
|
||||
VFLAGS += --error-exitcode=1
|
||||
|
||||
test: tests.out
|
||||
@./tests.out
|
||||
|
||||
memcheck: tests.out
|
||||
@valgrind $(VFLAGS) ./tests.out
|
||||
@echo "Memory check passed"
|
||||
|
||||
clean:
|
||||
rm -rf *.o *.out *.out.dSYM
|
||||
|
||||
tests.out: test/test_hello_world.c src/hello_world.c src/hello_world.h
|
||||
@echo Compiling $@
|
||||
@$(CC) $(CFLAGS) src/hello_world.c test/vendor/unity.c test/test_hello_world.c -o tests.out
|
5
c/hello-world/src/hello_world.c
Normal file
5
c/hello-world/src/hello_world.c
Normal file
@ -0,0 +1,5 @@
|
||||
#include "hello_world.h"
|
||||
|
||||
const char *hello(void)
|
||||
{
|
||||
}
|
6
c/hello-world/src/hello_world.h
Normal file
6
c/hello-world/src/hello_world.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef HELLO_WORLD_H
|
||||
#define HELLO_WORLD_H
|
||||
|
||||
const char *hello(void);
|
||||
|
||||
#endif
|
27
c/hello-world/test/test_hello_world.c
Normal file
27
c/hello-world/test/test_hello_world.c
Normal file
@ -0,0 +1,27 @@
|
||||
#include <stddef.h>
|
||||
#include "vendor/unity.h"
|
||||
#include "../src/hello_world.h"
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
}
|
||||
|
||||
void test_hello(void)
|
||||
{
|
||||
TEST_ASSERT_EQUAL_STRING("Hello, World!", hello());
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
UnityBegin("test/test_hello_world.c");
|
||||
|
||||
RUN_TEST(test_hello);
|
||||
|
||||
UnityEnd();
|
||||
|
||||
return 0;
|
||||
}
|
1300
c/hello-world/test/vendor/unity.c
vendored
Normal file
1300
c/hello-world/test/vendor/unity.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
274
c/hello-world/test/vendor/unity.h
vendored
Normal file
274
c/hello-world/test/vendor/unity.h
vendored
Normal file
@ -0,0 +1,274 @@
|
||||
/* ==========================================
|
||||
Unity Project - A Test Framework for C
|
||||
Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||
[Released under MIT License. Please refer to license.txt for details]
|
||||
========================================== */
|
||||
|
||||
#ifndef UNITY_FRAMEWORK_H
|
||||
#define UNITY_FRAMEWORK_H
|
||||
#define UNITY
|
||||
|
||||
#include "unity_internals.h"
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Configuration Options
|
||||
//-------------------------------------------------------
|
||||
// All options described below should be passed as a compiler flag to all files using Unity. If you must add #defines, place them BEFORE the #include above.
|
||||
|
||||
// Integers/longs/pointers
|
||||
// - Unity attempts to automatically discover your integer sizes
|
||||
// - define UNITY_EXCLUDE_STDINT_H to stop attempting to look in <stdint.h>
|
||||
// - define UNITY_EXCLUDE_LIMITS_H to stop attempting to look in <limits.h>
|
||||
// - define UNITY_EXCLUDE_SIZEOF to stop attempting to use sizeof in macros
|
||||
// - If you cannot use the automatic methods above, you can force Unity by using these options:
|
||||
// - define UNITY_SUPPORT_64
|
||||
// - define UNITY_INT_WIDTH
|
||||
// - UNITY_LONG_WIDTH
|
||||
// - UNITY_POINTER_WIDTH
|
||||
|
||||
// Floats
|
||||
// - define UNITY_EXCLUDE_FLOAT to disallow floating point comparisons
|
||||
// - define UNITY_FLOAT_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_FLOAT
|
||||
// - define UNITY_FLOAT_TYPE to specify doubles instead of single precision floats
|
||||
// - define UNITY_FLOAT_VERBOSE to print floating point values in errors (uses sprintf)
|
||||
// - define UNITY_INCLUDE_DOUBLE to allow double floating point comparisons
|
||||
// - define UNITY_EXCLUDE_DOUBLE to disallow double floating point comparisons (default)
|
||||
// - define UNITY_DOUBLE_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_DOUBLE
|
||||
// - define UNITY_DOUBLE_TYPE to specify something other than double
|
||||
// - define UNITY_DOUBLE_VERBOSE to print floating point values in errors (uses sprintf)
|
||||
|
||||
// Output
|
||||
// - by default, Unity prints to standard out with putchar. define UNITY_OUTPUT_CHAR(a) with a different function if desired
|
||||
|
||||
// Optimization
|
||||
// - by default, line numbers are stored in unsigned shorts. Define UNITY_LINE_TYPE with a different type if your files are huge
|
||||
// - by default, test and failure counters are unsigned shorts. Define UNITY_COUNTER_TYPE with a different type if you want to save space or have more than 65535 Tests.
|
||||
|
||||
// Test Cases
|
||||
// - define UNITY_SUPPORT_TEST_CASES to include the TEST_CASE macro, though really it's mostly about the runner generator script
|
||||
|
||||
// Parameterized Tests
|
||||
// - you'll want to create a define of TEST_CASE(...) which basically evaluates to nothing
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Basic Fail and Ignore
|
||||
//-------------------------------------------------------
|
||||
|
||||
#define TEST_FAIL_MESSAGE(message) UNITY_TEST_FAIL(__LINE__, message)
|
||||
#define TEST_FAIL() UNITY_TEST_FAIL(__LINE__, NULL)
|
||||
#define TEST_IGNORE_MESSAGE(message) UNITY_TEST_IGNORE(__LINE__, message)
|
||||
#define TEST_IGNORE() UNITY_TEST_IGNORE(__LINE__, NULL)
|
||||
#define TEST_ONLY()
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Test Asserts (simple)
|
||||
//-------------------------------------------------------
|
||||
|
||||
//Boolean
|
||||
#define TEST_ASSERT(condition) UNITY_TEST_ASSERT( (condition), __LINE__, " Expression Evaluated To FALSE")
|
||||
#define TEST_ASSERT_TRUE(condition) UNITY_TEST_ASSERT( (condition), __LINE__, " Expected TRUE Was FALSE")
|
||||
#define TEST_ASSERT_UNLESS(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expression Evaluated To TRUE")
|
||||
#define TEST_ASSERT_FALSE(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expected FALSE Was TRUE")
|
||||
#define TEST_ASSERT_NULL(pointer) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, " Expected NULL")
|
||||
#define TEST_ASSERT_NOT_NULL(pointer) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, " Expected Non-NULL")
|
||||
|
||||
//Integers (of all sizes)
|
||||
#define TEST_ASSERT_EQUAL_INT(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_INT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT8((expected), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_INT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_INT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_INT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal")
|
||||
#define TEST_ASSERT_EQUAL_UINT(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_UINT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_UINT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_UINT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT32( (expected), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_UINT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT64( (expected), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_HEX(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_HEX8(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX8( (expected), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_HEX16(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_HEX32(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_HEX64(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_BITS(mask, expected, actual) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_BITS_HIGH(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (_UU32)(-1), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_BITS_LOW(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (_UU32)(0), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_BIT_HIGH(bit, actual) UNITY_TEST_ASSERT_BITS(((_UU32)1 << bit), (_UU32)(-1), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_BIT_LOW(bit, actual) UNITY_TEST_ASSERT_BITS(((_UU32)1 << bit), (_UU32)(0), (actual), __LINE__, NULL)
|
||||
|
||||
//Integer Ranges (of all sizes)
|
||||
#define TEST_ASSERT_INT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_INT8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_INT16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT16_WITHIN(delta, expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_INT32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT32_WITHIN(delta, expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_INT64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_UINT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT_WITHIN(delta, expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_UINT8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT8_WITHIN(delta, expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_UINT16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT16_WITHIN(delta, expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_UINT32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT32_WITHIN(delta, expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_UINT64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_HEX_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_HEX8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX8_WITHIN(delta, expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_HEX16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_HEX32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_HEX64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, __LINE__, NULL)
|
||||
|
||||
//Structs and Strings
|
||||
#define TEST_ASSERT_EQUAL_PTR(expected, actual) UNITY_TEST_ASSERT_EQUAL_PTR((expected), (actual), __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_STRING(expected, actual) UNITY_TEST_ASSERT_EQUAL_STRING(expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len) UNITY_TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_MEMORY(expected, actual, len) UNITY_TEST_ASSERT_EQUAL_MEMORY(expected, actual, len, __LINE__, NULL)
|
||||
|
||||
//Arrays
|
||||
#define TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_INT16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_INT32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_HEX_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements, __LINE__, NULL)
|
||||
|
||||
//Floating Point (If Enabled)
|
||||
#define TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_FLOAT(expected, actual) UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_FLOAT_IS_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_FLOAT_IS_NEG_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_FLOAT_IS_NAN(actual) UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_FLOAT_IS_DETERMINATE(actual) UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE(actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_FLOAT_IS_NOT_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF(actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_FLOAT_IS_NOT_NAN(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN(actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual, __LINE__, NULL)
|
||||
|
||||
//Double (If Enabled)
|
||||
#define TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_DOUBLE(expected, actual) UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, __LINE__, NULL)
|
||||
#define TEST_ASSERT_DOUBLE_IS_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_DOUBLE_IS_NEG_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_DOUBLE_IS_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual) UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_DOUBLE_IS_NOT_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF(actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual, __LINE__, NULL)
|
||||
#define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, __LINE__, NULL)
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Test Asserts (with additional messages)
|
||||
//-------------------------------------------------------
|
||||
|
||||
//Boolean
|
||||
#define TEST_ASSERT_MESSAGE(condition, message) UNITY_TEST_ASSERT( (condition), __LINE__, message)
|
||||
#define TEST_ASSERT_TRUE_MESSAGE(condition, message) UNITY_TEST_ASSERT( (condition), __LINE__, message)
|
||||
#define TEST_ASSERT_UNLESS_MESSAGE(condition, message) UNITY_TEST_ASSERT( !(condition), __LINE__, message)
|
||||
#define TEST_ASSERT_FALSE_MESSAGE(condition, message) UNITY_TEST_ASSERT( !(condition), __LINE__, message)
|
||||
#define TEST_ASSERT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, message)
|
||||
#define TEST_ASSERT_NOT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, message)
|
||||
|
||||
//Integers (of all sizes)
|
||||
#define TEST_ASSERT_EQUAL_INT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_INT8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT8((expected), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_INT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_INT32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_INT64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_UINT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_UINT8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_UINT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_UINT32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT32( (expected), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_UINT64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT64( (expected), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_HEX_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_HEX8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX8( (expected), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_HEX16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_HEX32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_HEX64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_BITS_MESSAGE(mask, expected, actual, message) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_BITS_HIGH_MESSAGE(mask, actual, message) UNITY_TEST_ASSERT_BITS((mask), (_UU32)(-1), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_BITS_LOW_MESSAGE(mask, actual, message) UNITY_TEST_ASSERT_BITS((mask), (_UU32)(0), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_BIT_HIGH_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((_UU32)1 << bit), (_UU32)(-1), (actual), __LINE__, message)
|
||||
#define TEST_ASSERT_BIT_LOW_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((_UU32)1 << bit), (_UU32)(0), (actual), __LINE__, message)
|
||||
|
||||
//Integer Ranges (of all sizes)
|
||||
#define TEST_ASSERT_INT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_INT8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_INT16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT16_WITHIN(delta, expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_INT32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT32_WITHIN(delta, expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_INT64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_UINT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT_WITHIN(delta, expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_UINT8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT8_WITHIN(delta, expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_UINT16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT16_WITHIN(delta, expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_UINT32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT32_WITHIN(delta, expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_UINT64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_HEX_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_HEX8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX8_WITHIN(delta, expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_HEX16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_HEX32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_HEX64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, __LINE__, message)
|
||||
|
||||
//Structs and Strings
|
||||
#define TEST_ASSERT_EQUAL_PTR_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_STRING(expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(expected, actual, len, message) UNITY_TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_MEMORY_MESSAGE(expected, actual, len, message) UNITY_TEST_ASSERT_EQUAL_MEMORY(expected, actual, len, __LINE__, message)
|
||||
|
||||
//Arrays
|
||||
#define TEST_ASSERT_EQUAL_INT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_INT8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_INT16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY(expected, actual, num_elements, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_INT32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY(expected, actual, num_elements, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_INT64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_UINT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, actual, num_elements, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_UINT16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_UINT32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_UINT64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_HEX_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_HEX8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_HEX16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_HEX32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_HEX64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_PTR_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_STRING_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_MEMORY_ARRAY_MESSAGE(expected, actual, len, num_elements, message) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements, __LINE__, message)
|
||||
|
||||
//Floating Point (If Enabled)
|
||||
#define TEST_ASSERT_FLOAT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_FLOAT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_FLOAT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, __LINE__, message)
|
||||
#define TEST_ASSERT_FLOAT_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, __LINE__, message)
|
||||
#define TEST_ASSERT_FLOAT_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, __LINE__, message)
|
||||
#define TEST_ASSERT_FLOAT_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, __LINE__, message)
|
||||
#define TEST_ASSERT_FLOAT_IS_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE(actual, __LINE__, message)
|
||||
#define TEST_ASSERT_FLOAT_IS_NOT_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF(actual, __LINE__, message)
|
||||
#define TEST_ASSERT_FLOAT_IS_NOT_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual, __LINE__, message)
|
||||
#define TEST_ASSERT_FLOAT_IS_NOT_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN(actual, __LINE__, message)
|
||||
#define TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual, __LINE__, message)
|
||||
|
||||
//Double (If Enabled)
|
||||
#define TEST_ASSERT_DOUBLE_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_DOUBLE_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, __LINE__, message)
|
||||
#define TEST_ASSERT_EQUAL_DOUBLE_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, __LINE__, message)
|
||||
#define TEST_ASSERT_DOUBLE_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, __LINE__, message)
|
||||
#define TEST_ASSERT_DOUBLE_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, __LINE__, message)
|
||||
#define TEST_ASSERT_DOUBLE_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, __LINE__, message)
|
||||
#define TEST_ASSERT_DOUBLE_IS_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual, __LINE__, message)
|
||||
#define TEST_ASSERT_DOUBLE_IS_NOT_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF(actual, __LINE__, message)
|
||||
#define TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual, __LINE__, message)
|
||||
#define TEST_ASSERT_DOUBLE_IS_NOT_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual, __LINE__, message)
|
||||
#define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, __LINE__, message)
|
||||
|
||||
//end of UNITY_FRAMEWORK_H
|
||||
#endif
|
701
c/hello-world/test/vendor/unity_internals.h
vendored
Normal file
701
c/hello-world/test/vendor/unity_internals.h
vendored
Normal file
@ -0,0 +1,701 @@
|
||||
/* ==========================================
|
||||
Unity Project - A Test Framework for C
|
||||
Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||
[Released under MIT License. Please refer to license.txt for details]
|
||||
========================================== */
|
||||
|
||||
#ifndef UNITY_INTERNALS_H
|
||||
#define UNITY_INTERNALS_H
|
||||
|
||||
#ifdef UNITY_INCLUDE_CONFIG_H
|
||||
#include "unity_config.h"
|
||||
#endif
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
// Unity Attempts to Auto-Detect Integer Types
|
||||
// Attempt 1: UINT_MAX, ULONG_MAX, etc in <stdint.h>
|
||||
// Attempt 2: UINT_MAX, ULONG_MAX, etc in <limits.h>
|
||||
// Attempt 3: Deduced from sizeof() macros
|
||||
#ifndef UNITY_EXCLUDE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_EXCLUDE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_EXCLUDE_SIZEOF
|
||||
#ifndef UINT_MAX
|
||||
#define UINT_MAX (sizeof(unsigned int) * 256 - 1)
|
||||
#endif
|
||||
#ifndef ULONG_MAX
|
||||
#define ULONG_MAX (sizeof(unsigned long) * 256 - 1)
|
||||
#endif
|
||||
#ifndef UINTPTR_MAX
|
||||
//apparently this is not a constant expression: (sizeof(unsigned int *) * 256 - 1) so we have to just let this fall through
|
||||
#endif
|
||||
#endif
|
||||
//-------------------------------------------------------
|
||||
// Guess Widths If Not Specified
|
||||
//-------------------------------------------------------
|
||||
|
||||
// Determine the size of an int, if not already specificied.
|
||||
// We cannot use sizeof(int), because it is not yet defined
|
||||
// at this stage in the trnslation of the C program.
|
||||
// Therefore, infer it from UINT_MAX if possible.
|
||||
#ifndef UNITY_INT_WIDTH
|
||||
#ifdef UINT_MAX
|
||||
#if (UINT_MAX == 0xFFFF)
|
||||
#define UNITY_INT_WIDTH (16)
|
||||
#elif (UINT_MAX == 0xFFFFFFFF)
|
||||
#define UNITY_INT_WIDTH (32)
|
||||
#elif (UINT_MAX == 0xFFFFFFFFFFFFFFFF)
|
||||
#define UNITY_INT_WIDTH (64)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#ifndef UNITY_INT_WIDTH
|
||||
#define UNITY_INT_WIDTH (32)
|
||||
#endif
|
||||
|
||||
// Determine the size of a long, if not already specified,
|
||||
// by following the process used above to define
|
||||
// UNITY_INT_WIDTH.
|
||||
#ifndef UNITY_LONG_WIDTH
|
||||
#ifdef ULONG_MAX
|
||||
#if (ULONG_MAX == 0xFFFF)
|
||||
#define UNITY_LONG_WIDTH (16)
|
||||
#elif (ULONG_MAX == 0xFFFFFFFF)
|
||||
#define UNITY_LONG_WIDTH (32)
|
||||
#elif (ULONG_MAX == 0xFFFFFFFFFFFFFFFF)
|
||||
#define UNITY_LONG_WIDTH (64)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#ifndef UNITY_LONG_WIDTH
|
||||
#define UNITY_LONG_WIDTH (32)
|
||||
#endif
|
||||
|
||||
// Determine the size of a pointer, if not already specified,
|
||||
// by following the process used above to define
|
||||
// UNITY_INT_WIDTH.
|
||||
#ifndef UNITY_POINTER_WIDTH
|
||||
#ifdef UINTPTR_MAX
|
||||
#if (UINTPTR_MAX+0 <= 0xFFFF)
|
||||
#define UNITY_POINTER_WIDTH (16)
|
||||
#elif (UINTPTR_MAX+0 <= 0xFFFFFFFF)
|
||||
#define UNITY_POINTER_WIDTH (32)
|
||||
#elif (UINTPTR_MAX+0 <= 0xFFFFFFFFFFFFFFFF)
|
||||
#define UNITY_POINTER_WIDTH (64)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#ifndef UNITY_POINTER_WIDTH
|
||||
#ifdef INTPTR_MAX
|
||||
#if (INTPTR_MAX+0 <= 0x7FFF)
|
||||
#define UNITY_POINTER_WIDTH (16)
|
||||
#elif (INTPTR_MAX+0 <= 0x7FFFFFFF)
|
||||
#define UNITY_POINTER_WIDTH (32)
|
||||
#elif (INTPTR_MAX+0 <= 0x7FFFFFFFFFFFFFFF)
|
||||
#define UNITY_POINTER_WIDTH (64)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#ifndef UNITY_POINTER_WIDTH
|
||||
#define UNITY_POINTER_WIDTH UNITY_LONG_WIDTH
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Int Support (Define types based on detected sizes)
|
||||
//-------------------------------------------------------
|
||||
|
||||
#if (UNITY_INT_WIDTH == 32)
|
||||
typedef unsigned char _UU8;
|
||||
typedef unsigned short _UU16;
|
||||
typedef unsigned int _UU32;
|
||||
typedef signed char _US8;
|
||||
typedef signed short _US16;
|
||||
typedef signed int _US32;
|
||||
#elif (UNITY_INT_WIDTH == 16)
|
||||
typedef unsigned char _UU8;
|
||||
typedef unsigned int _UU16;
|
||||
typedef unsigned long _UU32;
|
||||
typedef signed char _US8;
|
||||
typedef signed int _US16;
|
||||
typedef signed long _US32;
|
||||
#else
|
||||
#error Invalid UNITY_INT_WIDTH specified! (16 or 32 are supported)
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------
|
||||
// 64-bit Support
|
||||
//-------------------------------------------------------
|
||||
|
||||
#ifndef UNITY_SUPPORT_64
|
||||
#if UNITY_LONG_WIDTH > 32
|
||||
#define UNITY_SUPPORT_64
|
||||
#endif
|
||||
#endif
|
||||
#ifndef UNITY_SUPPORT_64
|
||||
#if UNITY_POINTER_WIDTH > 32
|
||||
#define UNITY_SUPPORT_64
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_SUPPORT_64
|
||||
|
||||
//No 64-bit Support
|
||||
typedef _UU32 _U_UINT;
|
||||
typedef _US32 _U_SINT;
|
||||
|
||||
#else
|
||||
|
||||
//64-bit Support
|
||||
#if (UNITY_LONG_WIDTH == 32)
|
||||
typedef unsigned long long _UU64;
|
||||
typedef signed long long _US64;
|
||||
#elif (UNITY_LONG_WIDTH == 64)
|
||||
typedef unsigned long _UU64;
|
||||
typedef signed long _US64;
|
||||
#else
|
||||
#error Invalid UNITY_LONG_WIDTH specified! (32 or 64 are supported)
|
||||
#endif
|
||||
typedef _UU64 _U_UINT;
|
||||
typedef _US64 _U_SINT;
|
||||
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Pointer Support
|
||||
//-------------------------------------------------------
|
||||
|
||||
#if (UNITY_POINTER_WIDTH == 32)
|
||||
typedef _UU32 _UP;
|
||||
#define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX32
|
||||
#elif (UNITY_POINTER_WIDTH == 64)
|
||||
typedef _UU64 _UP;
|
||||
#define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX64
|
||||
#elif (UNITY_POINTER_WIDTH == 16)
|
||||
typedef _UU16 _UP;
|
||||
#define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX16
|
||||
#else
|
||||
#error Invalid UNITY_POINTER_WIDTH specified! (16, 32 or 64 are supported)
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_PTR_ATTRIBUTE
|
||||
#define UNITY_PTR_ATTRIBUTE
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Float Support
|
||||
//-------------------------------------------------------
|
||||
|
||||
#ifdef UNITY_EXCLUDE_FLOAT
|
||||
|
||||
//No Floating Point Support
|
||||
#undef UNITY_INCLUDE_FLOAT
|
||||
#undef UNITY_FLOAT_PRECISION
|
||||
#undef UNITY_FLOAT_TYPE
|
||||
#undef UNITY_FLOAT_VERBOSE
|
||||
|
||||
#else
|
||||
|
||||
#ifndef UNITY_INCLUDE_FLOAT
|
||||
#define UNITY_INCLUDE_FLOAT
|
||||
#endif
|
||||
|
||||
//Floating Point Support
|
||||
#ifndef UNITY_FLOAT_PRECISION
|
||||
#define UNITY_FLOAT_PRECISION (0.00001f)
|
||||
#endif
|
||||
#ifndef UNITY_FLOAT_TYPE
|
||||
#define UNITY_FLOAT_TYPE float
|
||||
#endif
|
||||
typedef UNITY_FLOAT_TYPE _UF;
|
||||
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Double Float Support
|
||||
//-------------------------------------------------------
|
||||
|
||||
//unlike FLOAT, we DON'T include by default
|
||||
#ifndef UNITY_EXCLUDE_DOUBLE
|
||||
#ifndef UNITY_INCLUDE_DOUBLE
|
||||
#define UNITY_EXCLUDE_DOUBLE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef UNITY_EXCLUDE_DOUBLE
|
||||
|
||||
//No Floating Point Support
|
||||
#undef UNITY_DOUBLE_PRECISION
|
||||
#undef UNITY_DOUBLE_TYPE
|
||||
#undef UNITY_DOUBLE_VERBOSE
|
||||
|
||||
#ifdef UNITY_INCLUDE_DOUBLE
|
||||
#undef UNITY_INCLUDE_DOUBLE
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
//Double Floating Point Support
|
||||
#ifndef UNITY_DOUBLE_PRECISION
|
||||
#define UNITY_DOUBLE_PRECISION (1e-12f)
|
||||
#endif
|
||||
#ifndef UNITY_DOUBLE_TYPE
|
||||
#define UNITY_DOUBLE_TYPE double
|
||||
#endif
|
||||
typedef UNITY_DOUBLE_TYPE _UD;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef UNITY_DOUBLE_VERBOSE
|
||||
#ifndef UNITY_FLOAT_VERBOSE
|
||||
#define UNITY_FLOAT_VERBOSE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Output Method: stdout (DEFAULT)
|
||||
//-------------------------------------------------------
|
||||
#ifndef UNITY_OUTPUT_CHAR
|
||||
//Default to using putchar, which is defined in stdio.h
|
||||
#include <stdio.h>
|
||||
#define UNITY_OUTPUT_CHAR(a) putchar(a)
|
||||
#else
|
||||
//If defined as something else, make sure we declare it here so it's ready for use
|
||||
extern int UNITY_OUTPUT_CHAR(int);
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_OUTPUT_START
|
||||
#define UNITY_OUTPUT_START()
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_OUTPUT_COMPLETE
|
||||
#define UNITY_OUTPUT_COMPLETE()
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Footprint
|
||||
//-------------------------------------------------------
|
||||
|
||||
#ifndef UNITY_LINE_TYPE
|
||||
#define UNITY_LINE_TYPE _U_UINT
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_COUNTER_TYPE
|
||||
#define UNITY_COUNTER_TYPE _U_UINT
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Language Features Available
|
||||
//-------------------------------------------------------
|
||||
#if !defined(UNITY_WEAK_ATTRIBUTE) && !defined(UNITY_WEAK_PRAGMA)
|
||||
# ifdef __GNUC__ // includes clang
|
||||
# if !(defined(__WIN32__) && defined(__clang__))
|
||||
# define UNITY_WEAK_ATTRIBUTE __attribute__((weak))
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef UNITY_NO_WEAK
|
||||
# undef UNITY_WEAK_ATTRIBUTE
|
||||
# undef UNITY_WEAK_PRAGMA
|
||||
#endif
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Internal Structs Needed
|
||||
//-------------------------------------------------------
|
||||
|
||||
typedef void (*UnityTestFunction)(void);
|
||||
|
||||
#define UNITY_DISPLAY_RANGE_INT (0x10)
|
||||
#define UNITY_DISPLAY_RANGE_UINT (0x20)
|
||||
#define UNITY_DISPLAY_RANGE_HEX (0x40)
|
||||
#define UNITY_DISPLAY_RANGE_AUTO (0x80)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
#if (UNITY_INT_WIDTH == 16)
|
||||
UNITY_DISPLAY_STYLE_INT = 2 + UNITY_DISPLAY_RANGE_INT + UNITY_DISPLAY_RANGE_AUTO,
|
||||
#elif (UNITY_INT_WIDTH == 32)
|
||||
UNITY_DISPLAY_STYLE_INT = 4 + UNITY_DISPLAY_RANGE_INT + UNITY_DISPLAY_RANGE_AUTO,
|
||||
#elif (UNITY_INT_WIDTH == 64)
|
||||
UNITY_DISPLAY_STYLE_INT = 8 + UNITY_DISPLAY_RANGE_INT + UNITY_DISPLAY_RANGE_AUTO,
|
||||
#endif
|
||||
UNITY_DISPLAY_STYLE_INT8 = 1 + UNITY_DISPLAY_RANGE_INT,
|
||||
UNITY_DISPLAY_STYLE_INT16 = 2 + UNITY_DISPLAY_RANGE_INT,
|
||||
UNITY_DISPLAY_STYLE_INT32 = 4 + UNITY_DISPLAY_RANGE_INT,
|
||||
#ifdef UNITY_SUPPORT_64
|
||||
UNITY_DISPLAY_STYLE_INT64 = 8 + UNITY_DISPLAY_RANGE_INT,
|
||||
#endif
|
||||
|
||||
#if (UNITY_INT_WIDTH == 16)
|
||||
UNITY_DISPLAY_STYLE_UINT = 2 + UNITY_DISPLAY_RANGE_UINT + UNITY_DISPLAY_RANGE_AUTO,
|
||||
#elif (UNITY_INT_WIDTH == 32)
|
||||
UNITY_DISPLAY_STYLE_UINT = 4 + UNITY_DISPLAY_RANGE_UINT + UNITY_DISPLAY_RANGE_AUTO,
|
||||
#elif (UNITY_INT_WIDTH == 64)
|
||||
UNITY_DISPLAY_STYLE_UINT = 8 + UNITY_DISPLAY_RANGE_UINT + UNITY_DISPLAY_RANGE_AUTO,
|
||||
#endif
|
||||
UNITY_DISPLAY_STYLE_UINT8 = 1 + UNITY_DISPLAY_RANGE_UINT,
|
||||
UNITY_DISPLAY_STYLE_UINT16 = 2 + UNITY_DISPLAY_RANGE_UINT,
|
||||
UNITY_DISPLAY_STYLE_UINT32 = 4 + UNITY_DISPLAY_RANGE_UINT,
|
||||
#ifdef UNITY_SUPPORT_64
|
||||
UNITY_DISPLAY_STYLE_UINT64 = 8 + UNITY_DISPLAY_RANGE_UINT,
|
||||
#endif
|
||||
UNITY_DISPLAY_STYLE_HEX8 = 1 + UNITY_DISPLAY_RANGE_HEX,
|
||||
UNITY_DISPLAY_STYLE_HEX16 = 2 + UNITY_DISPLAY_RANGE_HEX,
|
||||
UNITY_DISPLAY_STYLE_HEX32 = 4 + UNITY_DISPLAY_RANGE_HEX,
|
||||
#ifdef UNITY_SUPPORT_64
|
||||
UNITY_DISPLAY_STYLE_HEX64 = 8 + UNITY_DISPLAY_RANGE_HEX,
|
||||
#endif
|
||||
UNITY_DISPLAY_STYLE_UNKNOWN
|
||||
} UNITY_DISPLAY_STYLE_T;
|
||||
|
||||
#ifndef UNITY_EXCLUDE_FLOAT
|
||||
typedef enum _UNITY_FLOAT_TRAIT_T
|
||||
{
|
||||
UNITY_FLOAT_IS_NOT_INF = 0,
|
||||
UNITY_FLOAT_IS_INF,
|
||||
UNITY_FLOAT_IS_NOT_NEG_INF,
|
||||
UNITY_FLOAT_IS_NEG_INF,
|
||||
UNITY_FLOAT_IS_NOT_NAN,
|
||||
UNITY_FLOAT_IS_NAN,
|
||||
UNITY_FLOAT_IS_NOT_DET,
|
||||
UNITY_FLOAT_IS_DET,
|
||||
} UNITY_FLOAT_TRAIT_T;
|
||||
#endif
|
||||
|
||||
struct _Unity
|
||||
{
|
||||
const char* TestFile;
|
||||
const char* CurrentTestName;
|
||||
UNITY_LINE_TYPE CurrentTestLineNumber;
|
||||
UNITY_COUNTER_TYPE NumberOfTests;
|
||||
UNITY_COUNTER_TYPE TestFailures;
|
||||
UNITY_COUNTER_TYPE TestIgnores;
|
||||
UNITY_COUNTER_TYPE CurrentTestFailed;
|
||||
UNITY_COUNTER_TYPE CurrentTestIgnored;
|
||||
jmp_buf AbortFrame;
|
||||
};
|
||||
|
||||
extern struct _Unity Unity;
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Test Suite Management
|
||||
//-------------------------------------------------------
|
||||
|
||||
void UnityBegin(const char* filename);
|
||||
int UnityEnd(void);
|
||||
void UnityConcludeTest(void);
|
||||
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum);
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Test Output
|
||||
//-------------------------------------------------------
|
||||
|
||||
void UnityPrint(const char* string);
|
||||
void UnityPrintMask(const _U_UINT mask, const _U_UINT number);
|
||||
void UnityPrintNumberByStyle(const _U_SINT number, const UNITY_DISPLAY_STYLE_T style);
|
||||
void UnityPrintNumber(const _U_SINT number);
|
||||
void UnityPrintNumberUnsigned(const _U_UINT number);
|
||||
void UnityPrintNumberHex(const _U_UINT number, const char nibbles);
|
||||
|
||||
#ifdef UNITY_FLOAT_VERBOSE
|
||||
void UnityPrintFloat(const _UF number);
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Test Assertion Fuctions
|
||||
//-------------------------------------------------------
|
||||
// Use the macros below this section instead of calling
|
||||
// these directly. The macros have a consistent naming
|
||||
// convention and will pull in file and line information
|
||||
// for you.
|
||||
|
||||
void UnityAssertEqualNumber(const _U_SINT expected,
|
||||
const _U_SINT actual,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber,
|
||||
const UNITY_DISPLAY_STYLE_T style);
|
||||
|
||||
void UnityAssertEqualIntArray(UNITY_PTR_ATTRIBUTE const void* expected,
|
||||
UNITY_PTR_ATTRIBUTE const void* actual,
|
||||
const _UU32 num_elements,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber,
|
||||
const UNITY_DISPLAY_STYLE_T style);
|
||||
|
||||
void UnityAssertBits(const _U_SINT mask,
|
||||
const _U_SINT expected,
|
||||
const _U_SINT actual,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber);
|
||||
|
||||
void UnityAssertEqualString(const char* expected,
|
||||
const char* actual,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber);
|
||||
|
||||
void UnityAssertEqualStringLen(const char* expected,
|
||||
const char* actual,
|
||||
const _UU32 length,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber);
|
||||
|
||||
void UnityAssertEqualStringArray( const char** expected,
|
||||
const char** actual,
|
||||
const _UU32 num_elements,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber);
|
||||
|
||||
void UnityAssertEqualMemory( UNITY_PTR_ATTRIBUTE const void* expected,
|
||||
UNITY_PTR_ATTRIBUTE const void* actual,
|
||||
const _UU32 length,
|
||||
const _UU32 num_elements,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber);
|
||||
|
||||
void UnityAssertNumbersWithin(const _U_SINT delta,
|
||||
const _U_SINT expected,
|
||||
const _U_SINT actual,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber,
|
||||
const UNITY_DISPLAY_STYLE_T style);
|
||||
|
||||
void UnityFail(const char* message, const UNITY_LINE_TYPE line);
|
||||
|
||||
void UnityIgnore(const char* message, const UNITY_LINE_TYPE line);
|
||||
|
||||
#ifndef UNITY_EXCLUDE_FLOAT
|
||||
void UnityAssertFloatsWithin(const _UF delta,
|
||||
const _UF expected,
|
||||
const _UF actual,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber);
|
||||
|
||||
void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const _UF* expected,
|
||||
UNITY_PTR_ATTRIBUTE const _UF* actual,
|
||||
const _UU32 num_elements,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber);
|
||||
|
||||
void UnityAssertFloatSpecial(const _UF actual,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber,
|
||||
const UNITY_FLOAT_TRAIT_T style);
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_EXCLUDE_DOUBLE
|
||||
void UnityAssertDoublesWithin(const _UD delta,
|
||||
const _UD expected,
|
||||
const _UD actual,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber);
|
||||
|
||||
void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const _UD* expected,
|
||||
UNITY_PTR_ATTRIBUTE const _UD* actual,
|
||||
const _UU32 num_elements,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber);
|
||||
|
||||
void UnityAssertDoubleSpecial(const _UD actual,
|
||||
const char* msg,
|
||||
const UNITY_LINE_TYPE lineNumber,
|
||||
const UNITY_FLOAT_TRAIT_T style);
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Error Strings We Might Need
|
||||
//-------------------------------------------------------
|
||||
|
||||
extern const char UnityStrErrFloat[];
|
||||
extern const char UnityStrErrDouble[];
|
||||
extern const char UnityStrErr64[];
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Test Running Macros
|
||||
//-------------------------------------------------------
|
||||
|
||||
#define TEST_PROTECT() (setjmp(Unity.AbortFrame) == 0)
|
||||
|
||||
#define TEST_ABORT() {longjmp(Unity.AbortFrame, 1);}
|
||||
|
||||
//This tricky series of macros gives us an optional line argument to treat it as RUN_TEST(func, num=__LINE__)
|
||||
#ifndef RUN_TEST
|
||||
#ifdef __STDC_VERSION__
|
||||
#if __STDC_VERSION__ >= 199901L
|
||||
#define RUN_TEST(...) UnityDefaultTestRun(RUN_TEST_FIRST(__VA_ARGS__), RUN_TEST_SECOND(__VA_ARGS__))
|
||||
#define RUN_TEST_FIRST(...) RUN_TEST_FIRST_HELPER(__VA_ARGS__, throwaway)
|
||||
#define RUN_TEST_FIRST_HELPER(first,...) first, #first
|
||||
#define RUN_TEST_SECOND(...) RUN_TEST_SECOND_HELPER(__VA_ARGS__, __LINE__, throwaway)
|
||||
#define RUN_TEST_SECOND_HELPER(first,second,...) second
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//If we can't do the tricky version, we'll just have to require them to always include the line number
|
||||
#ifndef RUN_TEST
|
||||
#ifdef CMOCK
|
||||
#define RUN_TEST(func, num) UnityDefaultTestRun(func, #func, num)
|
||||
#else
|
||||
#define RUN_TEST(func) UnityDefaultTestRun(func, #func, __LINE__)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define TEST_LINE_NUM (Unity.CurrentTestLineNumber)
|
||||
#define TEST_IS_IGNORED (Unity.CurrentTestIgnored)
|
||||
#define UNITY_NEW_TEST(a) \
|
||||
Unity.CurrentTestName = a; \
|
||||
Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)(__LINE__); \
|
||||
Unity.NumberOfTests++;
|
||||
|
||||
#ifndef UNITY_BEGIN
|
||||
#define UNITY_BEGIN() UnityBegin(__FILE__)
|
||||
#endif
|
||||
|
||||
#ifndef UNITY_END
|
||||
#define UNITY_END() UnityEnd()
|
||||
#endif
|
||||
|
||||
#define UNITY_UNUSED(x) (void)(sizeof(x))
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Basic Fail and Ignore
|
||||
//-------------------------------------------------------
|
||||
|
||||
#define UNITY_TEST_FAIL(line, message) UnityFail( (message), (UNITY_LINE_TYPE)line);
|
||||
#define UNITY_TEST_IGNORE(line, message) UnityIgnore( (message), (UNITY_LINE_TYPE)line);
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Test Asserts
|
||||
//-------------------------------------------------------
|
||||
|
||||
#define UNITY_TEST_ASSERT(condition, line, message) if (condition) {} else {UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, message);}
|
||||
#define UNITY_TEST_ASSERT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) == NULL), (UNITY_LINE_TYPE)line, message)
|
||||
#define UNITY_TEST_ASSERT_NOT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) != NULL), (UNITY_LINE_TYPE)line, message)
|
||||
|
||||
#define UNITY_TEST_ASSERT_EQUAL_INT(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_INT8(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US8 )(expected), (_U_SINT)(_US8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT8)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_INT16(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US16)(expected), (_U_SINT)(_US16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT16)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_INT32(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US32)(expected), (_U_SINT)(_US32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT32)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_UINT(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_UINT8(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_UU8 )(expected), (_U_SINT)(_UU8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT8)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_UINT16(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_UU16)(expected), (_U_SINT)(_UU16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT16)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_UINT32(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_UU32)(expected), (_U_SINT)(_UU32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT32)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX8(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US8 )(expected), (_U_SINT)(_US8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX8)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX16(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US16)(expected), (_U_SINT)(_US16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX16)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX32(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_US32)(expected), (_U_SINT)(_US32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX32)
|
||||
#define UNITY_TEST_ASSERT_BITS(mask, expected, actual, line, message) UnityAssertBits((_U_SINT)(mask), (_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line)
|
||||
|
||||
#define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
|
||||
#define UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_US8 )(delta), (_U_SINT)(_US8 )(expected), (_U_SINT)(_US8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT8)
|
||||
#define UNITY_TEST_ASSERT_INT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_US16)(delta), (_U_SINT)(_US16)(expected), (_U_SINT)(_US16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT16)
|
||||
#define UNITY_TEST_ASSERT_INT32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_US32)(delta), (_U_SINT)(_US32)(expected), (_U_SINT)(_US32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT32)
|
||||
#define UNITY_TEST_ASSERT_UINT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
|
||||
#define UNITY_TEST_ASSERT_UINT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU8 )(delta), (_U_SINT)(_U_UINT)(_UU8 )(expected), (_U_SINT)(_U_UINT)(_UU8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT8)
|
||||
#define UNITY_TEST_ASSERT_UINT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU16)(delta), (_U_SINT)(_U_UINT)(_UU16)(expected), (_U_SINT)(_U_UINT)(_UU16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT16)
|
||||
#define UNITY_TEST_ASSERT_UINT32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU32)(delta), (_U_SINT)(_U_UINT)(_UU32)(expected), (_U_SINT)(_U_UINT)(_UU32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT32)
|
||||
#define UNITY_TEST_ASSERT_HEX8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU8 )(delta), (_U_SINT)(_U_UINT)(_UU8 )(expected), (_U_SINT)(_U_UINT)(_UU8 )(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX8)
|
||||
#define UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU16)(delta), (_U_SINT)(_U_UINT)(_UU16)(expected), (_U_SINT)(_U_UINT)(_UU16)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX16)
|
||||
#define UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(_U_UINT)(_UU32)(delta), (_U_SINT)(_U_UINT)(_UU32)(expected), (_U_SINT)(_U_UINT)(_UU32)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX32)
|
||||
|
||||
#define UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(_UP)(expected), (_U_SINT)(_UP)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_POINTER)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_STRING(expected, actual, line, message) UnityAssertEqualString((const char*)(expected), (const char*)(actual), (message), (UNITY_LINE_TYPE)line)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len, line, message) UnityAssertEqualStringLen((const char*)(expected), (const char*)(actual), (_UU32)(len), (message), (UNITY_LINE_TYPE)line)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_MEMORY(expected, actual, len, line, message) UnityAssertEqualMemory((UNITY_PTR_ATTRIBUTE void*)(expected), (UNITY_PTR_ATTRIBUTE void*)(actual), (_UU32)(len), 1, (message), (UNITY_LINE_TYPE)line)
|
||||
|
||||
#define UNITY_TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT8)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT16)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT32)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT8)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT16)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT32)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX8)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX16)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(expected), (UNITY_PTR_ATTRIBUTE const void*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX32)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const void*)(_UP*)(expected), (const void*)(_UP*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_POINTER)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualStringArray((const char**)(expected), (const char**)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((UNITY_PTR_ATTRIBUTE void*)(expected), (UNITY_PTR_ATTRIBUTE void*)(actual), (_UU32)(len), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line)
|
||||
|
||||
#ifdef UNITY_SUPPORT_64
|
||||
#define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT64)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_UINT64(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT64)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX64(expected, actual, line, message) UnityAssertEqualNumber((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX64)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const _U_SINT*)(expected), (UNITY_PTR_ATTRIBUTE const _U_SINT*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT64)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const _U_SINT*)(expected), (UNITY_PTR_ATTRIBUTE const _U_SINT*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT64)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_PTR_ATTRIBUTE const _U_SINT*)(expected), (UNITY_PTR_ATTRIBUTE const _U_SINT*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX64)
|
||||
#define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_INT64)
|
||||
#define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_UINT64)
|
||||
#define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((_U_SINT)(delta), (_U_SINT)(expected), (_U_SINT)(actual), NULL, (UNITY_LINE_TYPE)line, UNITY_DISPLAY_STYLE_HEX64)
|
||||
#else
|
||||
#define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_UINT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64)
|
||||
#define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64)
|
||||
#define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64)
|
||||
#define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErr64)
|
||||
#endif
|
||||
|
||||
#ifdef UNITY_EXCLUDE_FLOAT
|
||||
#define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
|
||||
#define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
|
||||
#define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
|
||||
#define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
|
||||
#define UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
|
||||
#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
|
||||
#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
|
||||
#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
|
||||
#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrFloat)
|
||||
#else
|
||||
#define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UnityAssertFloatsWithin((_UF)(delta), (_UF)(expected), (_UF)(actual), (message), (UNITY_LINE_TYPE)line)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((_UF)(expected) * (_UF)UNITY_FLOAT_PRECISION, (_UF)expected, (_UF)actual, (UNITY_LINE_TYPE)line, message)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualFloatArray((_UF*)(expected), (_UF*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line)
|
||||
#define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_INF)
|
||||
#define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NEG_INF)
|
||||
#define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NAN)
|
||||
#define UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_DET)
|
||||
#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_INF)
|
||||
#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_NEG_INF)
|
||||
#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_NAN)
|
||||
#define UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual, line, message) UnityAssertFloatSpecial((_UF)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_DET)
|
||||
#endif
|
||||
|
||||
#ifdef UNITY_EXCLUDE_DOUBLE
|
||||
#define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
|
||||
#define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
|
||||
#define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
|
||||
#define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
|
||||
#define UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
|
||||
#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
|
||||
#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
|
||||
#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
|
||||
#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)line, UnityStrErrDouble)
|
||||
#else
|
||||
#define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UnityAssertDoublesWithin((_UD)(delta), (_UD)(expected), (_UD)(actual), (message), (UNITY_LINE_TYPE)line)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((_UD)(expected) * (_UD)UNITY_DOUBLE_PRECISION, (_UD)expected, (_UD)actual, (UNITY_LINE_TYPE)line, message)
|
||||
#define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray((_UD*)(expected), (_UD*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line)
|
||||
#define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_INF)
|
||||
#define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NEG_INF)
|
||||
#define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NAN)
|
||||
#define UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_DET)
|
||||
#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_INF)
|
||||
#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_NEG_INF)
|
||||
#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_NAN)
|
||||
#define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, line, message) UnityAssertDoubleSpecial((_UD)(actual), (message), (UNITY_LINE_TYPE)line, UNITY_FLOAT_IS_NOT_DET)
|
||||
#endif
|
||||
|
||||
//End of UNITY_INTERNALS_H
|
||||
#endif
|
13
cfml/hello-world/HelloWorld.cfc
Normal file
13
cfml/hello-world/HelloWorld.cfc
Normal file
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Your implmentation of the Hello World exercise
|
||||
*/
|
||||
component {
|
||||
|
||||
/**
|
||||
* @returns A string greeting the world
|
||||
*/
|
||||
function hello() {
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
19
cfml/hello-world/HelloWorldTest.cfc
Normal file
19
cfml/hello-world/HelloWorldTest.cfc
Normal file
@ -0,0 +1,19 @@
|
||||
component extends="testbox.system.BaseSpec" {
|
||||
|
||||
function beforeAll(){
|
||||
SUT = createObject( 'HelloWorld' );
|
||||
}
|
||||
|
||||
function run(){
|
||||
|
||||
describe( "My HelloWorld class", function(){
|
||||
|
||||
it( 'Say Hi!', function(){
|
||||
expect( SUT.hello() ).toBe( 'Hello, World!' );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
37
cfml/hello-world/README.md
Normal file
37
cfml/hello-world/README.md
Normal file
@ -0,0 +1,37 @@
|
||||
# Hello World
|
||||
|
||||
The classical introductory exercise. Just say "Hello, World!".
|
||||
|
||||
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
|
||||
the traditional first program for beginning programming in a new language
|
||||
or environment.
|
||||
|
||||
The objectives are simple:
|
||||
|
||||
- Write a function that returns the string "Hello, World!".
|
||||
- Run the test suite and make sure that it succeeds.
|
||||
- Submit your solution and check it at the website.
|
||||
|
||||
If everything goes well, you will be ready to fetch your first real exercise.
|
||||
|
||||
* * * *
|
||||
|
||||
To run the code in this exercise, you will only need to have [CommandBox CLI installed](https://ortus.gitbooks.io/commandbox-documentation/content/setup/installation.html). This binary runs CFML code from the command line.
|
||||
|
||||
To run the tests, `cd` into the exercise folder and run the following:
|
||||
|
||||
```bash
|
||||
box task run TestRunner
|
||||
# Or start up a test watcher that will rerun when files change
|
||||
box task run TestRunner --:watcher
|
||||
```
|
||||
|
||||
The tests leverage a library called TestBox which supports xUnit and BDD style of testing. All test suites will be written in the [BDD style](https://testbox.ortusbooks.com/content/primers/bdd/specs.html) which uses closures to define test specs. You won't need to worry about installing TestBox. The CLI test runner will take care of that for you. You just need to be connected to the internet the first time you run it. You can read more about it here:
|
||||
|
||||
[https://testbox.ortusbooks.com/content/](https://testbox.ortusbooks.com/content/)
|
||||
## Source
|
||||
|
||||
This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)
|
||||
|
||||
## Submitting Incomplete Solutions
|
||||
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
103
cfml/hello-world/TestRunner.cfc
Normal file
103
cfml/hello-world/TestRunner.cfc
Normal file
@ -0,0 +1,103 @@
|
||||
/**
|
||||
* I am a CommandBox task runner which you can use to test your implementation of this exercise against the
|
||||
* provided test suite. To use me, open the CommandBox CLI and run this:
|
||||
*
|
||||
* CommandBox> task run TestRunner
|
||||
*
|
||||
* To start up a test watcher that will automatically rerun the test suite every time you save a file change, run this:
|
||||
*
|
||||
* CommandBox> task run TestRunner --watcher
|
||||
*
|
||||
*/
|
||||
component {
|
||||
|
||||
/**
|
||||
* @solution Runs the tests against the solution
|
||||
* @watcher Start up a file watch that re-runs the tests on file changes. Use Ctrl-C to stop
|
||||
*/
|
||||
function run( boolean solution=false, boolean watcher=false ) {
|
||||
|
||||
ensureTestBox();
|
||||
|
||||
if( watcher ) {
|
||||
|
||||
// Tabula rasa
|
||||
command( 'cls' ).run();
|
||||
|
||||
// Start watcher
|
||||
watch()
|
||||
.paths( '*.cfc' )
|
||||
.inDirectory( getCWD() )
|
||||
.withDelay( 500 )
|
||||
.onChange( function() {
|
||||
|
||||
// Clear the screen
|
||||
command( 'cls' )
|
||||
.run();
|
||||
|
||||
// This is neccessary so changes to tests get picked up right away.
|
||||
pagePoolClear();
|
||||
|
||||
runTests( solution );
|
||||
|
||||
} )
|
||||
.start();
|
||||
|
||||
} else {
|
||||
runTests( solution );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure the TestBox framework is installed
|
||||
*/
|
||||
private function ensureTestBox() {
|
||||
var excerciseRoot = getCWD();
|
||||
var testBoxRoot = excerciseRoot & '/testbox';
|
||||
|
||||
if( !directoryExists( testBoxRoot ) ) {
|
||||
|
||||
print.boldYellowLine( 'Installing some missing dependencies for you!' ).toConsole();
|
||||
command( 'install' )
|
||||
.inWorkingDirectory( excerciseRoot )
|
||||
.run();
|
||||
}
|
||||
|
||||
// Bootstrap TestBox framework
|
||||
filesystemUtil.createMapping( '/testbox', testBoxRoot );
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke TestBox to run the test suite
|
||||
*/
|
||||
private function runTests( boolean solution=false ) {
|
||||
|
||||
// Create TestBox and run the tests
|
||||
testData = new testbox.system.TestBox()
|
||||
.runRaw( directory = {
|
||||
// Find all CFCs...
|
||||
mapping = filesystemUtil.makePathRelative( getCWD() ),
|
||||
// ... in this directory ...
|
||||
recurse = false,
|
||||
// ... whose name ends in "test"
|
||||
filter = function( path ) {
|
||||
return path.reFind( ( solution ? 'Solution' : '' ) & 'Test.cfc$' );
|
||||
}
|
||||
} )
|
||||
.getMemento();
|
||||
|
||||
// Print out the results with ANSI formatting for the CLI
|
||||
getInstance( 'CLIRenderer@testbox-commands' )
|
||||
.render( print, testData, true );
|
||||
|
||||
print.toConsole();
|
||||
|
||||
// Set proper exit code
|
||||
if( testData.totalFail || testData.totalError ) {
|
||||
setExitCode( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
8
cfml/hello-world/box.json
Normal file
8
cfml/hello-world/box.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"dependencies":{
|
||||
"testbox":"^2.5.0+107"
|
||||
},
|
||||
"installPaths":{
|
||||
"testbox":"testbox"
|
||||
}
|
||||
}
|
37
cfml/hello-world/index.cfm
Normal file
37
cfml/hello-world/index.cfm
Normal file
@ -0,0 +1,37 @@
|
||||
<!---
|
||||
|
||||
This file will only be used if you want to start up a web server in this directory. You can do so by running:
|
||||
|
||||
$> box
|
||||
CommandBox> install
|
||||
CommandBox> server start
|
||||
|
||||
However, this is not necessary unless you really just want to use the HTML reporters on TestBox.
|
||||
Ideally, you'll skip the need for this file entirely and just run the tests directly frm the CLI like this:
|
||||
|
||||
CommandBox> task run TestRunner
|
||||
|
||||
--->
|
||||
<cfsetting showDebugOutput="false">
|
||||
<cfparam name="url.reporter" default="simple">
|
||||
<cfscript>
|
||||
// get a list of all CFCs in this folder whose name looks like "XXXTest.cfc"
|
||||
// And turn it into compnent path relative to the web root
|
||||
url.bundles = directoryList(
|
||||
path=expandPath( '/' ),
|
||||
filter='*Test.cfc' )
|
||||
.map( function( path ) {
|
||||
return path
|
||||
.replaceNoCase( expandPath( '/' ), '' )
|
||||
.left( -4 )
|
||||
} )
|
||||
.toList();
|
||||
</cfscript>
|
||||
|
||||
<!--- Ensure TestBox --->
|
||||
<cfif fileExists( "/testbox/system/runners/HTMLRunner.cfm" )>
|
||||
<!--- Include the TestBox HTML Runner --->
|
||||
<cfinclude template="/testbox/system/runners/HTMLRunner.cfm">
|
||||
<cfelse>
|
||||
Oops, you don't have TestBox installed yet! Please run <b>box install</b> from the root of your excercise folder and refresh this page.
|
||||
</cfif>
|
68
common-lisp/hello-world/README.md
Normal file
68
common-lisp/hello-world/README.md
Normal file
@ -0,0 +1,68 @@
|
||||
# Hello World
|
||||
|
||||
The classical introductory exercise. Just say "Hello, World!".
|
||||
|
||||
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
|
||||
the traditional first program for beginning programming in a new language
|
||||
or environment.
|
||||
|
||||
The objectives are simple:
|
||||
|
||||
- Write a function that returns the string "Hello, World!".
|
||||
- Run the test suite and make sure that it succeeds.
|
||||
- Submit your solution and check it at the website.
|
||||
|
||||
If everything goes well, you will be ready to fetch your first real exercise.
|
||||
|
||||
## Setup
|
||||
|
||||
Check out [Exercism Help](http://exercism.io/languages/common-lisp) for instructions to
|
||||
get started writing Common Lisp. That page will explain how to install and setup
|
||||
a Lisp implementation and how to run the tests.
|
||||
|
||||
## Formatting
|
||||
|
||||
While Common Lisp doesn't care about indentation and layout of code,
|
||||
nor whether you use spaces or tabs, this is an important consideration
|
||||
for submissions to exercism.io. Excercism.io's code widget cannot
|
||||
handle mixing of tab and space characters well so using only spaces is recommended to make
|
||||
the code more readable to the human reviewers. Please review your
|
||||
editors settings on how to accomplish this. Below are instructions for
|
||||
popular editors for Common Lisp.
|
||||
|
||||
### VIM
|
||||
|
||||
Use the following commands to ensure VIM uses only spaces for
|
||||
indentation:
|
||||
|
||||
```vimscript
|
||||
:set tabstop=2
|
||||
:set shiftwidth=2
|
||||
:set expandtab
|
||||
```
|
||||
|
||||
(or as a oneliner `:set tabstop=2 shiftwidth=2 expandtab`). This can
|
||||
be added to your `~/.vimrc` file to use it all the time.
|
||||
|
||||
### Emacs
|
||||
|
||||
Emacs is very well suited for editing Common Lisp and has many
|
||||
powerful add-on packages available. The only thing that one needs to
|
||||
do with a stock emacs to make it work well with exercism.io is to
|
||||
evaluate the following code:
|
||||
|
||||
`(setq indent-tab-mode nil)`
|
||||
|
||||
This can be placed in your `~/.emacs` (or `~/.emacs.d/init.el`) in
|
||||
order to have it set whenever Emacs is launched.
|
||||
|
||||
One suggested add-on for Emacs and Common Lisp is
|
||||
[SLIME](https://github.com/slime/slime) which offers tight integration
|
||||
with the REPL; making iterative coding and testing very easy.
|
||||
|
||||
## Source
|
||||
|
||||
This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)
|
||||
|
||||
## Submitting Incomplete Solutions
|
||||
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
21
common-lisp/hello-world/hello-world-test.lisp
Normal file
21
common-lisp/hello-world/hello-world-test.lisp
Normal file
@ -0,0 +1,21 @@
|
||||
(ql:quickload "lisp-unit")
|
||||
#-xlisp-test (load "hello-world")
|
||||
|
||||
(defpackage #:hello-world-test
|
||||
(:use #:common-lisp #:lisp-unit))
|
||||
|
||||
(in-package #:hello-world-test)
|
||||
|
||||
(define-test hello-world-test
|
||||
(assert-equal "Hello World!" (hw:hello-world)))
|
||||
|
||||
(define-test hello-alice-test
|
||||
(assert-equal "Hello Alice!" (hw:hello-world "Alice")))
|
||||
|
||||
(define-test hello-bob-test
|
||||
(assert-equal "Hello Bob!" (hw:hello-world "Bob")))
|
||||
|
||||
#-xlisp-test
|
||||
(let ((*print-errors* t)
|
||||
(*print-failures* t))
|
||||
(run-tests :all))
|
6
common-lisp/hello-world/hello-world.lisp
Normal file
6
common-lisp/hello-world/hello-world.lisp
Normal file
@ -0,0 +1,6 @@
|
||||
(defpackage #:hello-world
|
||||
(:use #:common-lisp)
|
||||
(:export #:hello-world)
|
||||
(:nicknames #:hw))
|
||||
|
||||
(in-package #:hello-world)
|
15
csharp/reverse-string/README.md
Normal file
15
csharp/reverse-string/README.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Reverse String
|
||||
|
||||
Reverse a string
|
||||
|
||||
For example:
|
||||
input: "cool"
|
||||
output: "looc"
|
||||
|
||||
|
||||
## Source
|
||||
|
||||
Introductory challenge to reverse an input string [https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb](https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb)
|
||||
|
||||
## Submitting Incomplete Solutions
|
||||
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
9
csharp/reverse-string/ReverseString.cs
Normal file
9
csharp/reverse-string/ReverseString.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
public static class ReverseString
|
||||
{
|
||||
public static string Reverse(string input)
|
||||
{
|
||||
throw new NotImplementedException("You need to implement this function.");
|
||||
}
|
||||
}
|
17
csharp/reverse-string/ReverseString.csproj
Normal file
17
csharp/reverse-string/ReverseString.csproj
Normal file
@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Example.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
|
||||
<PackageReference Include="xunit" Version="2.3.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
36
csharp/reverse-string/ReverseStringTest.cs
Normal file
36
csharp/reverse-string/ReverseStringTest.cs
Normal file
@ -0,0 +1,36 @@
|
||||
// This file was auto-generated based on version 1.1.0 of the canonical data.
|
||||
|
||||
using Xunit;
|
||||
|
||||
public class ReverseStringTest
|
||||
{
|
||||
[Fact]
|
||||
public void An_empty_string()
|
||||
{
|
||||
Assert.Equal("", ReverseString.Reverse(""));
|
||||
}
|
||||
|
||||
[Fact(Skip = "Remove to run test")]
|
||||
public void A_word()
|
||||
{
|
||||
Assert.Equal("tobor", ReverseString.Reverse("robot"));
|
||||
}
|
||||
|
||||
[Fact(Skip = "Remove to run test")]
|
||||
public void A_capitalized_word()
|
||||
{
|
||||
Assert.Equal("nemaR", ReverseString.Reverse("Ramen"));
|
||||
}
|
||||
|
||||
[Fact(Skip = "Remove to run test")]
|
||||
public void A_sentence_with_punctuation()
|
||||
{
|
||||
Assert.Equal("!yrgnuh m'I", ReverseString.Reverse("I'm hungry!"));
|
||||
}
|
||||
|
||||
[Fact(Skip = "Remove to run test")]
|
||||
public void A_palindrome()
|
||||
{
|
||||
Assert.Equal("racecar", ReverseString.Reverse("racecar"));
|
||||
}
|
||||
}
|
31
dart/hello-world/README.md
Normal file
31
dart/hello-world/README.md
Normal file
@ -0,0 +1,31 @@
|
||||
# Hello World
|
||||
|
||||
The classical introductory exercise. Just say "Hello, World!".
|
||||
|
||||
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
|
||||
the traditional first program for beginning programming in a new language
|
||||
or environment.
|
||||
|
||||
The objectives are simple:
|
||||
|
||||
- Write a function that returns the string "Hello, World!".
|
||||
- Run the test suite and make sure that it succeeds.
|
||||
- Submit your solution and check it at the website.
|
||||
|
||||
If everything goes well, you will be ready to fetch your first real exercise.
|
||||
|
||||
|
||||
To run the tests:
|
||||
|
||||
```sh
|
||||
$ pub run test
|
||||
```
|
||||
|
||||
For more detailed info about the Dart track see the [help page](http://exercism.io/languages/dart).
|
||||
|
||||
## Source
|
||||
|
||||
This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)
|
||||
|
||||
## Submitting Incomplete Solutions
|
||||
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
5
dart/hello-world/lib/hello_world.dart
Normal file
5
dart/hello-world/lib/hello_world.dart
Normal file
@ -0,0 +1,5 @@
|
||||
class HelloWorld {
|
||||
String hello() {
|
||||
// Put your code here
|
||||
}
|
||||
}
|
3
dart/hello-world/pubspec.yaml
Normal file
3
dart/hello-world/pubspec.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
name: 'hello_world'
|
||||
dev_dependencies:
|
||||
test: '<0.13.0'
|
8
dart/hello-world/test/hello_world_test.dart
Normal file
8
dart/hello-world/test/hello_world_test.dart
Normal file
@ -0,0 +1,8 @@
|
||||
import 'package:test/test.dart';
|
||||
import 'package:hello_world/hello_world.dart';
|
||||
|
||||
void main() {
|
||||
test("Say Hi!", () {
|
||||
expect(new HelloWorld().hello(), equals("Hello, World!"));
|
||||
});
|
||||
}
|
3
fsharp/hello-world/HelloWorld.fs
Normal file
3
fsharp/hello-world/HelloWorld.fs
Normal file
@ -0,0 +1,3 @@
|
||||
module HelloWorld
|
||||
|
||||
let hello: string = failwith "You need to implement this function."
|
23
fsharp/hello-world/HelloWorld.fsproj
Normal file
23
fsharp/hello-world/HelloWorld.fsproj
Normal file
@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="HelloWorld.fs" />
|
||||
<Compile Include="HelloWorldTest.fs" />
|
||||
<Compile Include="Program.fs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
|
||||
<PackageReference Include="xunit" Version="2.3.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
|
||||
<PackageReference Include="FsUnit.xUnit" Version="3.1.0" />
|
||||
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
1
fsharp/hello-world/Program.fs
Normal file
1
fsharp/hello-world/Program.fs
Normal file
@ -0,0 +1 @@
|
||||
module Program = let [<EntryPoint>] main _ = 0
|
22
julia/hello-world/README.md
Normal file
22
julia/hello-world/README.md
Normal file
@ -0,0 +1,22 @@
|
||||
# Hello World
|
||||
|
||||
The classical introductory exercise. Just say "Hello, World!".
|
||||
|
||||
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
|
||||
the traditional first program for beginning programming in a new language
|
||||
or environment.
|
||||
|
||||
The objectives are simple:
|
||||
|
||||
- Write a function that returns the string "Hello, World!".
|
||||
- Run the test suite and make sure that it succeeds.
|
||||
- Submit your solution and check it at the website.
|
||||
|
||||
If everything goes well, you will be ready to fetch your first real exercise.
|
||||
## Source
|
||||
|
||||
This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)
|
||||
|
||||
|
||||
## Submitting Incomplete Solutions
|
||||
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
3
julia/hello-world/hello-world.jl
Normal file
3
julia/hello-world/hello-world.jl
Normal file
@ -0,0 +1,3 @@
|
||||
function hello()
|
||||
|
||||
end
|
7
julia/hello-world/runtests.jl
Normal file
7
julia/hello-world/runtests.jl
Normal file
@ -0,0 +1,7 @@
|
||||
using Base.Test
|
||||
|
||||
include("hello-world.jl")
|
||||
|
||||
@testset "Say Hi!" begin
|
||||
@test hello() == "Hello, World!"
|
||||
end
|
5
lua/hello-world/.busted
Normal file
5
lua/hello-world/.busted
Normal file
@ -0,0 +1,5 @@
|
||||
return {
|
||||
default = {
|
||||
ROOT = { '.' }
|
||||
}
|
||||
}
|
11
ocaml/hello-world/jbuild
Normal file
11
ocaml/hello-world/jbuild
Normal file
@ -0,0 +1,11 @@
|
||||
(jbuild_version 1)
|
||||
|
||||
(executable
|
||||
((name test)
|
||||
(libraries (base oUnit))
|
||||
))
|
||||
|
||||
(alias
|
||||
((name runtest)
|
||||
(deps (test.exe))
|
||||
(action (run ${<}))))
|
41
plsql/hello-world/README.md
Normal file
41
plsql/hello-world/README.md
Normal file
@ -0,0 +1,41 @@
|
||||
# Hello World
|
||||
|
||||
The classical introductory exercise. Just say "Hello, World!".
|
||||
|
||||
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
|
||||
the traditional first program for beginning programming in a new language
|
||||
or environment.
|
||||
|
||||
The objectives are simple:
|
||||
|
||||
- Write a function that returns the string "Hello, World!".
|
||||
- Run the test suite and make sure that it succeeds.
|
||||
- Submit your solution and check it at the website.
|
||||
|
||||
If everything goes well, you will be ready to fetch your first real exercise.
|
||||
|
||||
## Setup
|
||||
|
||||
Go through the setup instructions for PL/SQL to get ready to code:
|
||||
|
||||
http://exercism.io/languages/plsql
|
||||
|
||||
## Running the Tests
|
||||
|
||||
Execute the tests by calling the `run` method in the respective `ut_<exercise>#` package.
|
||||
The necessary code should be contained at the end of the test package.
|
||||
As an example, the test for the _hamming_ exercise would be run using
|
||||
|
||||
```
|
||||
begin
|
||||
ut_hamming#.run;
|
||||
end;
|
||||
/
|
||||
```
|
||||
|
||||
## Source
|
||||
|
||||
This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)
|
||||
|
||||
## Submitting Incomplete Solutions
|
||||
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
20
plsql/hello-world/hello_world#.plsql
Normal file
20
plsql/hello-world/hello_world#.plsql
Normal file
@ -0,0 +1,20 @@
|
||||
CREATE OR REPLACE PACKAGE hello_world# IS
|
||||
FUNCTION hello(
|
||||
i_name varchar2 := ''
|
||||
)
|
||||
RETURN varchar2;
|
||||
|
||||
END hello_world#;
|
||||
/
|
||||
|
||||
CREATE OR REPLACE PACKAGE BODY hello_world# IS
|
||||
FUNCTION hello(
|
||||
i_name varchar2 := ''
|
||||
)
|
||||
RETURN varchar2
|
||||
AS
|
||||
BEGIN
|
||||
RETURN NULL;
|
||||
END hello;
|
||||
END hello_world#;
|
||||
/
|
60
plsql/hello-world/ut_hello_world#.plsql
Normal file
60
plsql/hello-world/ut_hello_world#.plsql
Normal file
@ -0,0 +1,60 @@
|
||||
CREATE OR REPLACE PACKAGE ut_hello_world#
|
||||
IS
|
||||
PROCEDURE run;
|
||||
END ut_hello_world#;
|
||||
/
|
||||
|
||||
CREATE OR REPLACE PACKAGE BODY ut_hello_world#
|
||||
IS
|
||||
|
||||
PROCEDURE TEST (
|
||||
i_descn varchar2,
|
||||
i_exp varchar2,
|
||||
i_act varchar2
|
||||
)
|
||||
IS
|
||||
BEGIN
|
||||
IF i_exp = i_act THEN
|
||||
dbms_output.put_line('SUCCESS: ' || i_descn);
|
||||
ELSE
|
||||
dbms_output.put_line(
|
||||
'FAILURE: ' || i_descn ||
|
||||
': expected ''' || NVL('' || i_exp, 'NULL') ||
|
||||
''', but got ''' || NVL('' || i_act, 'null') || '''!'
|
||||
);
|
||||
END IF;
|
||||
END TEST;
|
||||
|
||||
PROCEDURE run
|
||||
IS
|
||||
BEGIN
|
||||
TEST(
|
||||
i_descn => 'no name',
|
||||
i_exp => 'Hello, World!',
|
||||
i_act => hello_world#.hello()
|
||||
);
|
||||
|
||||
TEST(
|
||||
i_descn => 'sample name',
|
||||
i_exp => 'Hello, Alice!',
|
||||
i_act => hello_world#.hello('Alice')
|
||||
);
|
||||
|
||||
TEST(
|
||||
i_descn => 'other sample name',
|
||||
i_exp => 'Hello, Bob!',
|
||||
i_act => hello_world#.hello('Bob')
|
||||
);
|
||||
EXCEPTION
|
||||
WHEN others THEN
|
||||
dbms_output.put_line('Test execution failed.');
|
||||
dbms_output.put_line(sqlerrm);
|
||||
END run;
|
||||
|
||||
END ut_hello_world#;
|
||||
/
|
||||
|
||||
BEGIN
|
||||
ut_hello_world#.run;
|
||||
END;
|
||||
/
|
21
prolog/hello-world/README.md
Normal file
21
prolog/hello-world/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Hello World
|
||||
|
||||
The classical introductory exercise. Just say "Hello, World!".
|
||||
|
||||
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
|
||||
the traditional first program for beginning programming in a new language
|
||||
or environment.
|
||||
|
||||
The objectives are simple:
|
||||
|
||||
- Write a function that returns the string "Hello World!".
|
||||
- Run the test suite and make sure that it succeeds.
|
||||
- Submit your solution and check it at the website.
|
||||
|
||||
If everything goes well, you will be ready to fetch your first real exercise.
|
||||
## Source
|
||||
|
||||
This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)
|
||||
|
||||
## Submitting Incomplete Solutions
|
||||
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
9
prolog/hello-world/hello_world.pl
Normal file
9
prolog/hello-world/hello_world.pl
Normal file
@ -0,0 +1,9 @@
|
||||
% Please visit http://exercism.io/languages/prolog/installation
|
||||
% for instructions on setting up prolog.
|
||||
% Visit http://exercism.io/languages/prolog/tests
|
||||
% for help running the tests for prolog exercises.
|
||||
|
||||
% Replace the goal below with
|
||||
% your implementation.
|
||||
|
||||
hello_world(false).
|
31
prolog/hello-world/hello_world_tests.plt
Normal file
31
prolog/hello-world/hello_world_tests.plt
Normal file
@ -0,0 +1,31 @@
|
||||
% Please visit http://exercism.io/languages/prolog/installation
|
||||
% for instructions on setting up prolog.
|
||||
% Visit http://exercism.io/languages/prolog/tests
|
||||
% for help running the tests for prolog exercises.
|
||||
|
||||
% The goal below allows tests to be skipped
|
||||
% unless the "--all" flag is passed at
|
||||
% the command line.
|
||||
|
||||
pending :-
|
||||
current_prolog_flag(argv, ['--all'|_]).
|
||||
pending :-
|
||||
write('\nA TEST IS PENDING!\n'),
|
||||
fail.
|
||||
|
||||
:- begin_tests(hello_world).
|
||||
|
||||
test(hello_world, condition(true)) :-
|
||||
hello_world('Hello World!').
|
||||
|
||||
% Once the first test passes, un-skip the following test by
|
||||
% changing `pending` in `condition(pending)` to `true`.
|
||||
% Repeat for each test until they are all passing.
|
||||
|
||||
test(hello_world_with_a_name, condition(pending)) :-
|
||||
hello_world('Alice', 'Hello Alice!').
|
||||
|
||||
test(hello_world_another_name, condition(pending)) :-
|
||||
hello_world('Bob', 'Hello Bob!').
|
||||
|
||||
:- end_tests(hello_world).
|
56
python/reverse-string/README.md
Normal file
56
python/reverse-string/README.md
Normal file
@ -0,0 +1,56 @@
|
||||
# Reverse String
|
||||
|
||||
Reverse a string
|
||||
|
||||
For example:
|
||||
input: "cool"
|
||||
output: "looc"
|
||||
|
||||
## Exception messages
|
||||
|
||||
Sometimes it is necessary to raise an exception. When you do this, you should include a meaningful error message to
|
||||
indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. Not
|
||||
every exercise will require you to raise an exception, but for those that do, the tests will only pass if you include
|
||||
a message.
|
||||
|
||||
To raise a message with an exception, just write it as an argument to the exception type. For example, instead of
|
||||
`raise Exception`, you should write:
|
||||
|
||||
```python
|
||||
raise Exception("Meaningful message indicating the source of the error")
|
||||
```
|
||||
|
||||
## Running the tests
|
||||
|
||||
To run the tests, run the appropriate command below ([why they are different](https://github.com/pytest-dev/pytest/issues/1629#issue-161422224)):
|
||||
|
||||
- Python 2.7: `py.test reverse_string_test.py`
|
||||
- Python 3.4+: `pytest reverse_string_test.py`
|
||||
|
||||
Alternatively, you can tell Python to run the pytest module (allowing the same command to be used regardless of Python version):
|
||||
`python -m pytest reverse_string_test.py`
|
||||
|
||||
### Common `pytest` options
|
||||
|
||||
- `-v` : enable verbose output
|
||||
- `-x` : stop running tests on first failure
|
||||
- `--ff` : run failures from previous test before running other test cases
|
||||
|
||||
For other options, see `python -m pytest -h`
|
||||
|
||||
## Submitting Exercises
|
||||
|
||||
Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/python/reverse-string` directory.
|
||||
|
||||
You can find your Exercism workspace by running `exercism debug` and looking for the line that starts with `Workspace`.
|
||||
|
||||
For more detailed information about running tests, code style and linting,
|
||||
please see the [help page](http://exercism.io/languages/python).
|
||||
|
||||
## Source
|
||||
|
||||
Introductory challenge to reverse an input string [https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb](https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb)
|
||||
|
||||
## Submitting Incomplete Solutions
|
||||
|
||||
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
2
python/reverse-string/reverse_string.py
Normal file
2
python/reverse-string/reverse_string.py
Normal file
@ -0,0 +1,2 @@
|
||||
def reverse(input=''):
|
||||
pass
|
26
python/reverse-string/reverse_string_test.py
Normal file
26
python/reverse-string/reverse_string_test.py
Normal file
@ -0,0 +1,26 @@
|
||||
import unittest
|
||||
|
||||
from reverse_string import reverse
|
||||
|
||||
|
||||
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0
|
||||
|
||||
class ReverseStringTest(unittest.TestCase):
|
||||
def test_empty_string(self):
|
||||
self.assertEqual(reverse(''), '')
|
||||
|
||||
def test_a_word(self):
|
||||
self.assertEqual(reverse('robot'), 'tobor')
|
||||
|
||||
def test_a_capitalized_word(self):
|
||||
self.assertEqual(reverse('Ramen'), 'nemaR')
|
||||
|
||||
def test_a_sentence_with_punctuation(self):
|
||||
self.assertEqual(reverse('I\'m hungry!'), '!yrgnuh m\'I')
|
||||
|
||||
def test_a_palindrome(self):
|
||||
self.assertEqual(reverse('racecar'), 'racecar')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
51
sml/hello-world/README.md
Normal file
51
sml/hello-world/README.md
Normal file
@ -0,0 +1,51 @@
|
||||
# Hello World
|
||||
|
||||
The classical introductory exercise. Just say "Hello, World!".
|
||||
|
||||
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
|
||||
the traditional first program for beginning programming in a new language
|
||||
or environment.
|
||||
|
||||
The objectives are simple:
|
||||
|
||||
- Write a function that returns the string "Hello, World!".
|
||||
- Run the test suite and make sure that it succeeds.
|
||||
- Submit your solution and check it at the website.
|
||||
|
||||
If everything goes well, you will be ready to fetch your first real exercise.
|
||||
|
||||
## Loading your exercise implementation in PolyML
|
||||
|
||||
```
|
||||
$ poly --use {exercise}.sml
|
||||
```
|
||||
|
||||
Or:
|
||||
|
||||
```
|
||||
$ poly
|
||||
> use "{exercise}.sml";
|
||||
```
|
||||
|
||||
**Note:** You have to replace {exercise}.
|
||||
|
||||
## Running the tests
|
||||
|
||||
```
|
||||
$ poly -q --use test.sml
|
||||
```
|
||||
|
||||
## Feedback, Issues, Pull Requests
|
||||
|
||||
The [exercism/sml](https://github.com/exercism/sml) repository on
|
||||
GitHub is the home for all of the Standard ML exercises.
|
||||
|
||||
If you have feedback about an exercise, or want to help implementing a new
|
||||
one, head over there and create an issue. We'll do our best to help you!
|
||||
|
||||
## Source
|
||||
|
||||
This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)
|
||||
|
||||
## Submitting Incomplete Solutions
|
||||
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
2
sml/hello-world/hello-world.sml
Normal file
2
sml/hello-world/hello-world.sml
Normal file
@ -0,0 +1,2 @@
|
||||
fun hello (): string =
|
||||
raise Fail "'hello' is not implemented"
|
15
sml/hello-world/test.sml
Normal file
15
sml/hello-world/test.sml
Normal file
@ -0,0 +1,15 @@
|
||||
(* version 1.0.0 *)
|
||||
|
||||
use "hello-world.sml";
|
||||
use "testlib.sml";
|
||||
|
||||
infixr |>
|
||||
fun x |> f = f x
|
||||
|
||||
val testsuite =
|
||||
describe "hello-world" [
|
||||
test "Say Hi!"
|
||||
(fn _ => hello () |> Expect.equalTo "Hello, World!")
|
||||
]
|
||||
|
||||
val _ = Test.run testsuite
|
159
sml/hello-world/testlib.sml
Normal file
159
sml/hello-world/testlib.sml
Normal file
@ -0,0 +1,159 @@
|
||||
structure Expect =
|
||||
struct
|
||||
datatype expectation = Pass | Fail of string * string
|
||||
|
||||
local
|
||||
fun failEq b a =
|
||||
Fail ("Expected: " ^ b, "Got: " ^ a)
|
||||
|
||||
fun failExn b a =
|
||||
Fail ("Expected: " ^ b, "Raised: " ^ a)
|
||||
|
||||
fun exnName (e: exn): string = General.exnName e
|
||||
in
|
||||
fun truthy a =
|
||||
if a
|
||||
then Pass
|
||||
else failEq "true" "false"
|
||||
|
||||
fun falsy a =
|
||||
if a
|
||||
then failEq "false" "true"
|
||||
else Pass
|
||||
|
||||
fun equalTo b a =
|
||||
if a = b
|
||||
then Pass
|
||||
else failEq (PolyML.makestring b) (PolyML.makestring a)
|
||||
|
||||
fun nearTo b a =
|
||||
if Real.== (a, b)
|
||||
then Pass
|
||||
else failEq (Real.toString b) (Real.toString a)
|
||||
|
||||
fun anyError f =
|
||||
(
|
||||
f ();
|
||||
failExn "an exception" "Nothing"
|
||||
) handle _ => Pass
|
||||
|
||||
fun error e f =
|
||||
(
|
||||
f ();
|
||||
failExn (exnName e) "Nothing"
|
||||
) handle e' => if exnMessage e' = exnMessage e
|
||||
then Pass
|
||||
else failExn (exnMessage e) (exnMessage e')
|
||||
end
|
||||
end
|
||||
|
||||
structure TermColor =
|
||||
struct
|
||||
datatype color = Red | Green | Yellow | Normal
|
||||
|
||||
fun f Red = "\027[31m"
|
||||
| f Green = "\027[32m"
|
||||
| f Yellow = "\027[33m"
|
||||
| f Normal = "\027[0m"
|
||||
|
||||
fun colorize color s = (f color) ^ s ^ (f Normal)
|
||||
|
||||
val redit = colorize Red
|
||||
|
||||
val greenit = colorize Green
|
||||
|
||||
val yellowit = colorize Yellow
|
||||
end
|
||||
|
||||
structure Test =
|
||||
struct
|
||||
datatype testnode = TestGroup of string * testnode list
|
||||
| Test of string * (unit -> Expect.expectation)
|
||||
|
||||
local
|
||||
datatype evaluation = Success of string
|
||||
| Failure of string * string * string
|
||||
| Error of string * string
|
||||
|
||||
fun indent n s = (implode (List.tabulate (n, fn _ => #" "))) ^ s
|
||||
|
||||
fun fmt indentlvl ev =
|
||||
let
|
||||
val check = TermColor.greenit "\226\156\148 " (* ✔ *)
|
||||
val cross = TermColor.redit "\226\156\150 " (* ✖ *)
|
||||
val indentlvl = indentlvl * 2
|
||||
in
|
||||
case ev of
|
||||
Success descr => indent indentlvl (check ^ descr)
|
||||
| Failure (descr, exp, got) =>
|
||||
String.concatWith "\n" [indent indentlvl (cross ^ descr),
|
||||
indent (indentlvl + 2) exp,
|
||||
indent (indentlvl + 2) got]
|
||||
| Error (descr, reason) =>
|
||||
String.concatWith "\n" [indent indentlvl (cross ^ descr),
|
||||
indent (indentlvl + 2) (TermColor.redit reason)]
|
||||
end
|
||||
|
||||
fun eval (TestGroup _) = raise Fail "Only a 'Test' can be evaluated"
|
||||
| eval (Test (descr, thunk)) =
|
||||
(
|
||||
case thunk () of
|
||||
Expect.Pass => ((1, 0, 0), Success descr)
|
||||
| Expect.Fail (s, s') => ((0, 1, 0), Failure (descr, s, s'))
|
||||
)
|
||||
handle e => ((0, 0, 1), Error (descr, "Unexpected error: " ^ exnMessage e))
|
||||
|
||||
fun flatten depth testnode =
|
||||
let
|
||||
fun sum (x, y, z) (a, b, c) = (x + a, y + b, z + c)
|
||||
|
||||
fun aux (t, (counter, acc)) =
|
||||
let
|
||||
val (counter', texts) = flatten (depth + 1) t
|
||||
in
|
||||
(sum counter' counter, texts :: acc)
|
||||
end
|
||||
in
|
||||
case testnode of
|
||||
TestGroup (descr, ts) =>
|
||||
let
|
||||
val (counter, texts) = foldr aux ((0, 0, 0), []) ts
|
||||
in
|
||||
(counter, (indent (depth * 2) descr) :: List.concat texts)
|
||||
end
|
||||
| Test _ =>
|
||||
let
|
||||
val (counter, evaluation) = eval testnode
|
||||
in
|
||||
(counter, [fmt depth evaluation])
|
||||
end
|
||||
end
|
||||
|
||||
fun println s = print (s ^ "\n")
|
||||
in
|
||||
fun run suite =
|
||||
let
|
||||
val ((succeeded, failed, errored), texts) = flatten 0 suite
|
||||
|
||||
val summary = String.concatWith ", " [
|
||||
TermColor.greenit ((Int.toString succeeded) ^ " passed"),
|
||||
TermColor.redit ((Int.toString failed) ^ " failed"),
|
||||
TermColor.redit ((Int.toString errored) ^ " errored"),
|
||||
(Int.toString (succeeded + failed + errored)) ^ " total"
|
||||
]
|
||||
|
||||
val status = if failed = 0 andalso errored = 0
|
||||
then OS.Process.success
|
||||
else OS.Process.failure
|
||||
|
||||
in
|
||||
List.app println texts;
|
||||
println "";
|
||||
println ("Tests: " ^ summary);
|
||||
OS.Process.exit status
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
fun describe description tests = Test.TestGroup (description, tests)
|
||||
fun test description thunk = Test.Test (description, thunk)
|
7
typescript/hello-world/hello-world.ts
Normal file
7
typescript/hello-world/hello-world.ts
Normal file
@ -0,0 +1,7 @@
|
||||
class HelloWorld {
|
||||
static hello( /* Parameters go here */ ) {
|
||||
// Your code here
|
||||
}
|
||||
}
|
||||
|
||||
export default HelloWorld
|
Loading…
Reference in New Issue
Block a user