Compare commits
70 Commits
68fc644ea6
...
v0.1
Author | SHA1 | Date | |
---|---|---|---|
694eb43eab | |||
694d40124f | |||
39778ce08d | |||
cfd44621d5 | |||
4be71317b0 | |||
49642553e1 | |||
1e11b5921d | |||
7343c3b9d9 | |||
9e8410d4cf | |||
bc0c4f33ad | |||
1098fa252f | |||
0b1905429c | |||
e7d3ea3697 | |||
577bde6e57 | |||
60b9ed9eb2 | |||
d13bf883b5 | |||
681e005a68 | |||
2ce89fb39a | |||
907bc26264 | |||
e243e862ae | |||
5e930b9847 | |||
ed3ec885c0 | |||
835bcfe121 | |||
9432496875 | |||
0731e40e6a | |||
35322de3ac | |||
c3d8d6f8e5 | |||
1f2bca5028 | |||
9a9e5cd3e0 | |||
4d828500af | |||
deac5ca5b8 | |||
e05ebeef2a | |||
bdca40bae4 | |||
b4cd46a1e7 | |||
a57acc1176 | |||
ffcf2fb013 | |||
c7a9c8215c | |||
ca4cf2cd68 | |||
e19fc8820a | |||
ee3f2919c6 | |||
653736622f | |||
e3afe52ab7 | |||
905acacd07 | |||
8763fa35dd | |||
feae5d560a | |||
ec268f6047 | |||
6fff5e5cc8 | |||
7b19e553f2 | |||
64ef797727 | |||
85e17ede84 | |||
8e5b39a6e4 | |||
4514d94be9 | |||
4080d1a80a | |||
a36ae22d52 | |||
ad8ac61b98 | |||
e5bb4dfd96 | |||
363188d7d6 | |||
139d6fcb22 | |||
92d9da14c2 | |||
b43fd46260 | |||
a6dc46149c | |||
120038ea8f | |||
8cf09e43c9 | |||
ecc12f6f3b | |||
a1f210fee1 | |||
2662f54c51 | |||
950c25bace | |||
1c0dd7aa0b | |||
5b345e6bf5 | |||
891d8bf7ef |
@@ -1,12 +1,13 @@
|
|||||||
---
|
---
|
||||||
BasedOnStyle: LLVM
|
|
||||||
AlignConsecutiveShortCaseStatements:
|
AlignConsecutiveShortCaseStatements:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
AcrossEmptyLines: true
|
AcrossEmptyLines: true
|
||||||
AcrossComments: true
|
AcrossComments: true
|
||||||
|
IndentCaseLabels: true
|
||||||
AllowShortBlocksOnASingleLine: Always
|
AllowShortBlocksOnASingleLine: Always
|
||||||
AllowShortCaseLabelsOnASingleLine: true
|
AllowShortCaseLabelsOnASingleLine: true
|
||||||
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
|
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
|
||||||
AllowShortLoopsOnASingleLine: true
|
AllowShortLoopsOnASingleLine: true
|
||||||
IndentWidth: 4
|
IndentWidth: 4
|
||||||
PointerAlignment: Left
|
PointerAlignment: Left
|
||||||
|
AlignAfterOpenBracket: BlockIndent
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,4 +3,6 @@
|
|||||||
tags
|
tags
|
||||||
*.out
|
*.out
|
||||||
.cache
|
.cache
|
||||||
|
build/*
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
|
vgcore.*
|
||||||
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "test/Unity"]
|
||||||
|
path = test/Unity
|
||||||
|
url = https://github.com/ThrowTheSwitch/Unity
|
91
Makefile
91
Makefile
@@ -3,8 +3,10 @@ NAME = scl
|
|||||||
TARGET = $(NAME).out
|
TARGET = $(NAME).out
|
||||||
|
|
||||||
SRC_DIR = src
|
SRC_DIR = src
|
||||||
|
INC_DIR = $(SRC_DIR)/include
|
||||||
BUILD_DIR = build
|
BUILD_DIR = build
|
||||||
OBJ_DIR = $(BUILD_DIR)/obj
|
OBJ_DIR = $(BUILD_DIR)/obj
|
||||||
|
GRAM_DIR = $(BUILD_DIR)/grammars
|
||||||
TEST_DIR = test
|
TEST_DIR = test
|
||||||
TEST_BUILD_DIR = $(BUILD_DIR)/test
|
TEST_BUILD_DIR = $(BUILD_DIR)/test
|
||||||
TEST_OBJ_DIR = $(TEST_BUILD_DIR)/obj
|
TEST_OBJ_DIR = $(TEST_BUILD_DIR)/obj
|
||||||
@@ -12,16 +14,24 @@ TEST_OBJ_DIR = $(TEST_BUILD_DIR)/obj
|
|||||||
CC = clang
|
CC = clang
|
||||||
LINK = clang
|
LINK = clang
|
||||||
CFLAGS = -Wall -DDBG -ggdb
|
CFLAGS = -Wall -DDBG -ggdb
|
||||||
LDFLAGS =
|
LDFLAGS = -lm
|
||||||
|
BATS = bats
|
||||||
|
BISON = bison
|
||||||
|
PRINT = echo -e
|
||||||
|
|
||||||
SRC_FILES = $(wildcard $(SRC_DIR)/*.c)
|
SRC_FILES = $(wildcard $(SRC_DIR)/*.c)
|
||||||
OBJ_FILES = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRC_FILES))
|
OBJ_FILES = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRC_FILES))
|
||||||
OBJ_FILES_NOMAIN = $(filter-out $(OBJ_DIR)/main.o, $(OBJ_FILES)) # Object files without main.c.
|
OBJ_FILES_NOMAIN = $(filter-out $(OBJ_DIR)/main.o, $(OBJ_FILES)) # Object files without main.c.
|
||||||
UNITY_C = $(TEST_DIR)/unity/unity.c
|
GRAM_FILES = $(GRAM_DIR)/grammar.tab.c $(GRAM_DIR)/grammar.tab.h
|
||||||
|
UNITY_DIR = $(TEST_DIR)/Unity
|
||||||
|
UNITY_C = $(UNITY_DIR)/src/unity.c
|
||||||
|
UNITY_H = $(UNITY_DIR)/src/unity.h
|
||||||
|
UNITY_OBJ = $(TEST_BUILD_DIR)/unity.o
|
||||||
TEST_SRC_FILES = $(wildcard $(TEST_DIR)/*.c)
|
TEST_SRC_FILES = $(wildcard $(TEST_DIR)/*.c)
|
||||||
TEST_OBJ_FILES = $(patsubst $(TEST_DIR)/%.c, $(TEST_OBJ_DIR)/%.o, $(TEST_SRC_FILES))
|
TEST_OBJ_FILES = $(patsubst $(TEST_DIR)/%.c, $(TEST_OBJ_DIR)/%.o, $(TEST_SRC_FILES))
|
||||||
|
TEST_BIN_FILES = $(patsubst $(TEST_DIR)/%.c, $(TEST_BUILD_DIR)/%.out, $(TEST_SRC_FILES))
|
||||||
|
TEST_VAL_DIR = $(TEST_DIR)/validation
|
||||||
|
|
||||||
# Stupid things.
|
|
||||||
RESETCOLOR = \033[0m
|
RESETCOLOR = \033[0m
|
||||||
WHITE = $(RESETCOLOR)\033[37m
|
WHITE = $(RESETCOLOR)\033[37m
|
||||||
WHITE_BOLD = $(RESETCOLOR)\033[37;1m
|
WHITE_BOLD = $(RESETCOLOR)\033[37;1m
|
||||||
@@ -32,37 +42,64 @@ release: clean
|
|||||||
release: CFLAGS = -Wall -O2
|
release: CFLAGS = -Wall -O2
|
||||||
release: $(TARGET)
|
release: $(TARGET)
|
||||||
|
|
||||||
|
# Run the target.
|
||||||
run: $(TARGET)
|
run: $(TARGET)
|
||||||
@ echo -e "$(WHITE_BOLD)Running... $(RESETCOLOR)./$(TARGET)"
|
./$(TARGET)
|
||||||
@ ./$(TARGET)
|
|
||||||
|
# Generate grammars with bison.
|
||||||
|
$(GRAM_FILES): $(SRC_DIR)/grammar.y
|
||||||
|
@ mkdir -p $(GRAM_DIR)
|
||||||
|
@ $(PRINT) "$(WHITE_BOLD)Generating grammars...$(RESETCOLOR)"
|
||||||
|
$(BISON) $< -o$(GRAM_DIR)/grammar.tab.c -H$(GRAM_DIR)/grammar.tab.h
|
||||||
|
|
||||||
|
# Compile grammars.
|
||||||
|
$(OBJ_DIR)/grammar.o: $(GRAM_DIR)/grammar.tab.c $(GRAM_DIR)/grammar.tab.h $(OBJ_DIR)/lexer.o
|
||||||
|
@ $(PRINT) "$(WHITE_BOLD)Compiling grammars...$(RESETCOLOR)"
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
# Lexer depends on grammars.
|
||||||
|
$(OBJ_DIR)/lexer.o: $(SRC_DIR)/lexer.c $(GRAM_FILES)
|
||||||
|
@ mkdir -p $(OBJ_DIR)
|
||||||
|
@ $(PRINT) "$(WHITE_BOLD)Compiling source object $(WHITE)$@$(WHITE_BOLD)... $(RESETCOLOR)"
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
# Compile project source objects.
|
||||||
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(INC_DIR)/%.h
|
||||||
|
@ mkdir -p $(OBJ_DIR)
|
||||||
|
@ $(PRINT) "$(WHITE_BOLD)Compiling source object $(WHITE)$@$(WHITE_BOLD)... $(RESETCOLOR)"
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
# Link to final binary.
|
# Link to final binary.
|
||||||
$(TARGET): $(OBJ_FILES)
|
$(TARGET): $(OBJ_DIR)/grammar.o $(OBJ_FILES)
|
||||||
@ echo -e "$(WHITE_BOLD)Linking $(WHITE)$(TARGET)$(WHITE_BOLD)...$(RESETCOLOR) $(CC) -o $(TARGET) $(OBJ_FILES) $(LDFLAGS)"
|
@ $(PRINT) "$(WHITE_BOLD)Linking $(WHITE)$@$(WHITE_BOLD)...$(RESETCOLOR)"
|
||||||
@ $(LINK) -o $(TARGET) $(OBJ_FILES) $(LDFLAGS)
|
$(LINK) -o $(TARGET) $(OBJ_FILES) $(OBJ_DIR)/grammar.o $(LDFLAGS)
|
||||||
|
|
||||||
# Compile project sources.
|
# Compile Unity object.
|
||||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(SRC_DIR)/include/%.h
|
$(UNITY_OBJ): $(UNITY_C) $(UNITY_H)
|
||||||
@ mkdir -p $(OBJ_DIR)
|
@ $(PRINT) "$(WHITE_BOLD)Compiling Unity...$(RESETCOLOR)"
|
||||||
@ echo -e "$(WHITE_BOLD)Compiling $(WHITE)$<$(WHITE_BOLD)... $(RESETCOLOR)$(CC) $(CFLAGS) -c $< -o $@"
|
$(CC) $(CFLAGS) -D UNITY_OUTPUT_COLOR -c $< -o $@
|
||||||
@ $(CC) $(CFLAGS) -c $< -o $@
|
|
||||||
|
|
||||||
# Compile test sources.
|
# Compile test object.
|
||||||
$(TEST_OBJ_DIR)/%.o: $(TEST_DIR)/%.c
|
$(TEST_OBJ_DIR)/test_%.o: $(TEST_DIR)/test_%.c
|
||||||
@ mkdir -p $(TEST_OBJ_DIR)
|
@ $(PRINT) "$(WHITE_BOLD)Compiling test object $(WHITE)$@$(WHITE_BOLD)...$(RESETCOLOR)"
|
||||||
@ echo -e "$(WHITE_BOLD)Compiling Test $(WHITE)$<$(WHITE_BOLD)... $(WHITE)$(CC) $(CFLAGS) -I$(SRC_DIR)/include -c $< -o $@$(RESETCOLOR)"
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
@ $(CC) $(CFLAGS) -I$(SRC_DIR)/include -c $< -o $@
|
|
||||||
|
# Link final test binary.
|
||||||
|
$(TEST_BUILD_DIR)/test_%.out: $(TEST_OBJ_DIR)/test_%.o $(OBJ_DIR)/%.o $(UNITY_OBJ)
|
||||||
|
@ $(PRINT) "$(WHITE_BOLD)Linking test binary $(WHITE)$@$(WHITE_BOLD)...$(RESETCOLOR)"
|
||||||
|
$(LINK) -o $@ $? $(LDFLAGS)
|
||||||
|
|
||||||
|
# Run the test files.
|
||||||
|
test: $(TARGET) $(TEST_BIN_FILES)
|
||||||
|
@ $(PRINT) "$(WHITE_BOLD)Running unit tests...$(RESETCOLOR)"
|
||||||
|
for test in $(TEST_BIN_FILES); do ./$${test}; done
|
||||||
|
@ $(PRINT) "$(WHITE_BOLD)Running validation tests...$(RESETCOLOR)"
|
||||||
|
$(BATS) $(TEST_VAL_DIR)
|
||||||
|
|
||||||
# Link the test executable.
|
|
||||||
test: $(TEST_OBJ_FILES) $(OBJ_FILES_NOMAIN) $(UNITY_C)
|
|
||||||
@ echo -e "$(WHITE_BOLD)Linking test binary$(WHITE)...$(RESETCOLOR)"
|
|
||||||
@ $(LINK) -DUNITY_OUTPUT_COLOR $(TEST_OBJ_FILES) $(OBJ_FILES_NOMAIN) $(UNITY_C) -o $(TEST_BUILD_DIR)/test.out
|
|
||||||
@ echo -e "$(WHITE_BOLD)Running tests$(WHITE)...$(RESETCOLOR)"
|
|
||||||
@ ./$(TEST_BUILD_DIR)/test.out
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@ echo -e "$(WHITE_BOLD)Cleaning up...$(WHITE) $(OBJ_DIR)/*.o $(TEST_OBJ_DIR)/*.o $(TEST_BUILD_DIR)/test.out $(TARGET)$(RESETCOLOR)"
|
@ $(PRINT) "$(WHITE_BOLD)Cleaning up...$(RESETCOLOR)"
|
||||||
@ rm -rf $(OBJ_DIR)/*.o $(TEST_OBJ_DIR)/*.o $(TEST_BUILD_DIR)/test.out $(TARGET)
|
rm -rf $(OBJ_DIR)/*.o $(TEST_OBJ_DIR)/*.o $(TEST_BUILD_DIR)/test.out $(TARGET) $(GRAM_DIR)/* $(UNITY_OBJ)
|
||||||
|
|
||||||
.PHONY: all clean test nocolor release run
|
.PHONY: all clean test nocolor release run
|
||||||
|
.PRECIOUS: $(TEST_OBJ_FILES)
|
||||||
|
63
README.md
63
README.md
@@ -1,3 +1,62 @@
|
|||||||
# SCL: Simple Calculator Language
|
# SCL: Simple CAS Language
|
||||||
|
|
||||||
A spiritual successor to halk.
|
Version v1.0-alpha
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://git.signorovitch.org/jacob/scl && cd scl
|
||||||
|
make release # Build.
|
||||||
|
./scl # Run.
|
||||||
|
```
|
||||||
|
|
||||||
|
If you wish to run tests, make sure to run `git clone --recurse-submodules` to
|
||||||
|
include the [Unity](https://github.com/ThrowTheSwitch/Unity) test framework.
|
||||||
|
|
||||||
|
## Current State
|
||||||
|
|
||||||
|
See [STATUS.md](STATUS.md). Currently, one is able to use `scl` as a basic,
|
||||||
|
interactive, four-function calculator.
|
||||||
|
|
||||||
|
## Syntax (Planned)
|
||||||
|
|
||||||
|
As one would expect, you can evaluate simple infix expressions:
|
||||||
|
|
||||||
|
```scl
|
||||||
|
> 1 + 1
|
||||||
|
= 2
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also define your own functions:
|
||||||
|
|
||||||
|
```scl
|
||||||
|
> f(x) = 2x
|
||||||
|
> f(2)
|
||||||
|
= 4
|
||||||
|
```
|
||||||
|
|
||||||
|
Symbolic algebra is done in the following manner:
|
||||||
|
|
||||||
|
```scl
|
||||||
|
> f(x) = x^4
|
||||||
|
> diff(f, x:sym, 2)
|
||||||
|
= 12x^2
|
||||||
|
```
|
||||||
|
|
||||||
|
SCL will dynamically decide on types, but you can state them explicitly as
|
||||||
|
well:
|
||||||
|
|
||||||
|
```scl
|
||||||
|
> f(x:int) = 2x
|
||||||
|
> f(2.2)
|
||||||
|
! f(x:int): x must be of type int.
|
||||||
|
```
|
||||||
|
|
||||||
|
Variables can be defined, with several attributes:
|
||||||
|
|
||||||
|
```scl
|
||||||
|
> a = 1 // Interpret type automatically.
|
||||||
|
> b:int = 1 // Must be int.
|
||||||
|
> c:const:int = 1 // Constant: value can never change.
|
||||||
|
> x:sym // Treated symbolicaly.
|
||||||
|
```
|
||||||
|
55
STATUS.md
Normal file
55
STATUS.md
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
# SCL Design Status
|
||||||
|
|
||||||
|
- [x] Data definitions
|
||||||
|
- [x] Token Definitions
|
||||||
|
- [x] AST Definitions
|
||||||
|
|
||||||
|
- [ ] Parser
|
||||||
|
- [x] Parse numbers
|
||||||
|
- [x] Parse floats
|
||||||
|
- [x] Parse negative numbers
|
||||||
|
- [x] Parse infix operators
|
||||||
|
- [x] Order of operations
|
||||||
|
- [x] Parse function application
|
||||||
|
- [x] Parse order of operations with parenthesis
|
||||||
|
- [ ] Parse variable invocation
|
||||||
|
- [ ] Parse variable definition
|
||||||
|
- [ ] Parse types
|
||||||
|
- [ ] Parse function definition
|
||||||
|
- [ ] Parse lists/arrays/vectors
|
||||||
|
- [ ] Parse blocks
|
||||||
|
- [ ] Parse control flow
|
||||||
|
- [ ] Parse `if` statements
|
||||||
|
- [ ] Parse `loop`s
|
||||||
|
- [ ] Parse `for` loops
|
||||||
|
- [ ] Parse `while` loops
|
||||||
|
- [ ] Parse `case` statements
|
||||||
|
- [ ] Parse `goto` statements
|
||||||
|
- [ ] Parse lambda function definition
|
||||||
|
- [ ] Parse function calling with positional arguments
|
||||||
|
- [ ] Parse variadic functions
|
||||||
|
- [ ] Parse infix function definition
|
||||||
|
|
||||||
|
- [ ] Executer
|
||||||
|
- [x] Exec function calls
|
||||||
|
- [ ] Exec variable use
|
||||||
|
- [ ] Exec variable definition
|
||||||
|
- [ ] Exec function definition
|
||||||
|
- [ ] Exec symbolic variables
|
||||||
|
- [ ] Exec control flow statements
|
||||||
|
- [ ] Exec variadic functions
|
||||||
|
- [ ] Exec lambda functions
|
||||||
|
- [ ] Exec lists
|
||||||
|
- [ ] Exec arrays
|
||||||
|
- [ ] Exec vectors
|
||||||
|
|
||||||
|
- [ ] Interface
|
||||||
|
- [ ] Interactive interpreter
|
||||||
|
- [ ] Use GNU readline
|
||||||
|
- [ ] Multi-line input
|
||||||
|
- [ ] Syntax highlighting
|
||||||
|
- [ ] Autocompletion/suggestion
|
||||||
|
- [ ] Command line interface
|
||||||
|
- [ ] Pass in a file
|
||||||
|
- [ ] Save AST to a file
|
||||||
|
- [ ] Run from AST file
|
117
src/ast.c
Normal file
117
src/ast.c
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "include/ast.h"
|
||||||
|
#include "include/dstr.h"
|
||||||
|
#include "include/util.h"
|
||||||
|
|
||||||
|
extern AST* root;
|
||||||
|
|
||||||
|
static char* asttype_names[] = {
|
||||||
|
[AST_TYPE_CALL] = "FUNC CALL",
|
||||||
|
[AST_TYPE_NUM] = "NUMBER",
|
||||||
|
[AST_TYPE_VREF] = "VAR REFERENCE"
|
||||||
|
};
|
||||||
|
|
||||||
|
AST* ast_init(ASTType type, void* data) {
|
||||||
|
AST* ast = malloc(sizeof(AST));
|
||||||
|
|
||||||
|
ast->type = type;
|
||||||
|
ast->data = data;
|
||||||
|
|
||||||
|
return ast;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ast_destroy(AST* ast) {
|
||||||
|
if (!ast) return;
|
||||||
|
|
||||||
|
switch (ast->type) {
|
||||||
|
case AST_TYPE_NUM: ast_num_data_destroy(ast->data); break;
|
||||||
|
case AST_TYPE_CALL: ast_call_data_destroy(ast->data); break;
|
||||||
|
default:
|
||||||
|
log_dbgf("Unknown ast type %d (max: %d)", ast->type, AST_TYPE_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(ast);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ast_print(AST* ast) { ast_print_i(ast, 0); }
|
||||||
|
|
||||||
|
void ast_print_i(AST* ast, int i) {
|
||||||
|
INDENT_BEGIN(i);
|
||||||
|
|
||||||
|
INDENT_TITLE("AST", ast);
|
||||||
|
INDENT_FIELD("type", "%s", asttype_names[ast->type]);
|
||||||
|
INDENT_FIELD_EXT_NONL_START("data");
|
||||||
|
switch (ast->type) {
|
||||||
|
case AST_TYPE_NUM:
|
||||||
|
printf("%s %lf\n", INDENT_spacing->buf, *(ASTNumData*)ast->data);
|
||||||
|
break;
|
||||||
|
case AST_TYPE_CALL: ast_call_print(ast->data, i + 2); break;
|
||||||
|
case AST_TYPE_VREF: ast_vref_print(ast->data, i + 2); break;
|
||||||
|
default: exit(1);
|
||||||
|
}
|
||||||
|
INDENT_FIELD_NONL_END;
|
||||||
|
INDENT_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASTNumData* ast_num_data_init(double val) {
|
||||||
|
talloc(ASTNumData, num);
|
||||||
|
|
||||||
|
*num = val;
|
||||||
|
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ast_num_data_destroy(ASTNumData* num) { free(num); }
|
||||||
|
|
||||||
|
void ast_num_print(ASTNumData* data, int i) {
|
||||||
|
INDENT_BEGIN(i);
|
||||||
|
|
||||||
|
INDENT_FIELD("data", "%lf", *data);
|
||||||
|
|
||||||
|
INDENT_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASTCallData* ast_call_data_init(char* to, size_t argc, AST** argv) {
|
||||||
|
talloc(ASTCallData, call);
|
||||||
|
|
||||||
|
log_dbgf("to: %s", to);
|
||||||
|
|
||||||
|
call->to = to;
|
||||||
|
call->argc = argc;
|
||||||
|
call->argv = argv;
|
||||||
|
|
||||||
|
return call;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ast_call_data_destroy(ASTCallData* call) {
|
||||||
|
if (!call) return;
|
||||||
|
free(call->to);
|
||||||
|
for (size_t i = 0; i < call->argc; i++) ast_destroy(call->argv[i]);
|
||||||
|
free(call->argv);
|
||||||
|
free(call);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ast_call_print(ASTCallData* data, int i) {
|
||||||
|
INDENT_BEGIN(i);
|
||||||
|
|
||||||
|
INDENT_TITLE("ASTCallData", data);
|
||||||
|
INDENT_FIELD("to", "%s", data->to);
|
||||||
|
INDENT_FIELD("argc", "%ld", data->argc);
|
||||||
|
INDENT_FIELD_LIST("argv", data->argv, data->argc, ast_print_i);
|
||||||
|
|
||||||
|
INDENT_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASTVrefData* ast_vref_data_init(char* to) {}
|
||||||
|
|
||||||
|
void ast_vref_data_destroy(ASTVrefData* vref) {}
|
||||||
|
|
||||||
|
void ast_vref_print(ASTVrefData* data, int i) {
|
||||||
|
INDENT_BEGIN(i);
|
||||||
|
|
||||||
|
INDENT_TITLE("ASTVrefData", data);
|
||||||
|
INDENT_FIELD("to", "%s", data->to);
|
||||||
|
|
||||||
|
INDENT_END;
|
||||||
|
}
|
35
src/dstr.c
35
src/dstr.c
@@ -1,13 +1,14 @@
|
|||||||
#include "include/dstr.h"
|
#include "include/dstr.h"
|
||||||
#include "include/util.h"
|
#include "include/util.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
Dstr* dstr_init(void) {
|
Dstr* dstr_init(void) {
|
||||||
Dstr* dstr = malloc(sizeof(Dstr));
|
Dstr* dstr = malloc(sizeof(Dstr));
|
||||||
|
|
||||||
dstr->bufsz = DSTR_INITSZ;
|
dstr->sz = DSTR_INITSZ;
|
||||||
dstr->buf = malloc(DSTR_INITSZ);
|
dstr->buf = malloc(DSTR_INITSZ);
|
||||||
*dstr->buf = '\0';
|
*dstr->buf = '\0';
|
||||||
dstr->ln = 0;
|
dstr->ln = 0;
|
||||||
@@ -20,13 +21,22 @@ void dstr_destroy(Dstr* dstr) {
|
|||||||
free(dstr);
|
free(dstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dstr_append(Dstr* dest, char* src, size_t ln) {
|
void dstr_destroypsv(Dstr* dstr) { free(dstr); }
|
||||||
while (dest->ln + ln + 1 > dest->bufsz) {
|
|
||||||
|
// Check whether the buffer is overflowing and resize it if necessary.
|
||||||
|
void check_resz(Dstr* dstr, size_t ln) {
|
||||||
|
while (dstr->ln + ln + 1 > dstr->sz) {
|
||||||
// Double the buffer size when overflown.
|
// Double the buffer size when overflown.
|
||||||
dest->bufsz *= 2;
|
dstr->sz *= 2;
|
||||||
dest->buf = realloc(dest->buf, dest->bufsz);
|
dstr->buf = realloc(dstr->buf, dstr->sz);
|
||||||
log_dbgf("dstr @ %p doubled from %ld to %ld", dest, dest->bufsz/2, dest->bufsz);
|
log_dbgf(
|
||||||
|
"dstr @ %p doubled from %ld to %ld", dstr, dstr->sz / 2, dstr->sz
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dstr_append(Dstr* dest, char* src, size_t ln) {
|
||||||
|
check_resz(dest, ln);
|
||||||
|
|
||||||
// Overwrites the \0 at the end of the string, keeps the null from the given
|
// Overwrites the \0 at the end of the string, keeps the null from the given
|
||||||
// string.
|
// string.
|
||||||
@@ -34,16 +44,11 @@ void dstr_append(Dstr* dest, char* src, size_t ln) {
|
|||||||
dest->ln += ln;
|
dest->ln += ln;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dstr_appendch(Dstr *dest, char ch) {
|
void dstr_appendch(Dstr* dest, char ch) {
|
||||||
if (dest->ln + 1 + 1 > dest->bufsz) {
|
check_resz(dest, 1);
|
||||||
// Double the buffer size when overflown.
|
|
||||||
dest->bufsz *= 2;
|
|
||||||
dest->buf = realloc(dest->buf, dest->bufsz);
|
|
||||||
log_dbgf("dstr @ %p doubled from %ld to %ld", dest, dest->bufsz/2, dest->bufsz);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Overwrites the preexisting null terminator, and adds one of its own.
|
// Overwrites the preexisting null terminator, and adds one of its own.
|
||||||
dest->buf[dest->ln] = ch;
|
dest->buf[dest->ln] = ch;
|
||||||
dest->buf[dest->ln+1] = '\0';
|
dest->buf[dest->ln + 1] = '\0';
|
||||||
dest->ln += 1;
|
dest->ln += 1;
|
||||||
}
|
}
|
||||||
|
70
src/exec.c
Normal file
70
src/exec.c
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "include/ast.h"
|
||||||
|
#include "include/exec.h"
|
||||||
|
#include "include/util.h"
|
||||||
|
|
||||||
|
extern AST* root;
|
||||||
|
|
||||||
|
ASTNumData exec_exp(AST* ast) {
|
||||||
|
log_dbg("Started execution.");
|
||||||
|
switch (ast->type) {
|
||||||
|
case AST_TYPE_CALL: return exec_call(ast);
|
||||||
|
case AST_TYPE_NUM: return *(ASTNumData*)ast->data;
|
||||||
|
default: printf("what\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ASTNumData exec_call(AST* ast) {
|
||||||
|
log_dbg("Started call execution.");
|
||||||
|
fflush(stdout);
|
||||||
|
ASTCallData* calldata = (ASTCallData*)ast->data;
|
||||||
|
if (calldata->argc >= 1) {
|
||||||
|
if (!strcmp(calldata->to, "sum")) {
|
||||||
|
double total = exec_exp(calldata->argv[0]);
|
||||||
|
|
||||||
|
for (
|
||||||
|
size_t i = 1;
|
||||||
|
i < calldata->argc;
|
||||||
|
total += exec_exp(calldata->argv[i++])
|
||||||
|
);
|
||||||
|
|
||||||
|
return total;
|
||||||
|
} else if (!strcmp(calldata->to, "sub")) {
|
||||||
|
double total = exec_exp(calldata->argv[0]);
|
||||||
|
|
||||||
|
for (
|
||||||
|
size_t i = 1;
|
||||||
|
i < calldata->argc;
|
||||||
|
total -= exec_exp(calldata->argv[i++])
|
||||||
|
);
|
||||||
|
|
||||||
|
return total;
|
||||||
|
} else if (!strcmp(calldata->to, "mul")) {
|
||||||
|
double total = exec_exp(calldata->argv[0]);
|
||||||
|
|
||||||
|
for (
|
||||||
|
size_t i = 1;
|
||||||
|
i < calldata->argc;
|
||||||
|
total *= exec_exp(calldata->argv[i++])
|
||||||
|
);
|
||||||
|
|
||||||
|
return total;
|
||||||
|
} else if (!strcmp(calldata->to, "div")) {
|
||||||
|
double total = exec_exp(calldata->argv[0]);
|
||||||
|
|
||||||
|
for (
|
||||||
|
size_t i = 1;
|
||||||
|
i < calldata->argc;
|
||||||
|
total /= exec_exp(calldata->argv[i++])
|
||||||
|
);
|
||||||
|
|
||||||
|
return total;
|
||||||
|
}}
|
||||||
|
return -1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
void exec_print(double n) { printf("= %lf\n", n); }
|
131
src/grammar.y
Normal file
131
src/grammar.y
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
%{
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "../../src/include/ast.h"
|
||||||
|
#include "../../src/include/lexer.h"
|
||||||
|
|
||||||
|
int yylex(void);
|
||||||
|
void yyerror(char const*);
|
||||||
|
|
||||||
|
AST* root = NULL;
|
||||||
|
%}
|
||||||
|
|
||||||
|
%code requires {
|
||||||
|
#include "../../src/include/ast.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
%union {
|
||||||
|
double fval;
|
||||||
|
char* strval;
|
||||||
|
AST* ast;
|
||||||
|
ArgArr* argarr;
|
||||||
|
}
|
||||||
|
|
||||||
|
%define parse.error verbose
|
||||||
|
|
||||||
|
%token LGROUP
|
||||||
|
%token RGROUP
|
||||||
|
%token SEP
|
||||||
|
|
||||||
|
%token<strval> WORD
|
||||||
|
%token<fval> NUM
|
||||||
|
|
||||||
|
%token SUB
|
||||||
|
%token PLUS
|
||||||
|
%token MULT
|
||||||
|
%token DIV
|
||||||
|
|
||||||
|
%token NL
|
||||||
|
|
||||||
|
%left PLUS SUB
|
||||||
|
%left MULT DIV
|
||||||
|
%precedence NEG
|
||||||
|
|
||||||
|
%type<ast> exp;
|
||||||
|
%type<argarr> arg;
|
||||||
|
%type<argarr> argstart;
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
input:
|
||||||
|
%empty
|
||||||
|
| exp { root = $1; }
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
argstart:
|
||||||
|
exp {
|
||||||
|
ArgArr* argarr = argarr_init();
|
||||||
|
argarr_add(argarr, $1);
|
||||||
|
$$ = argarr;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
arg:
|
||||||
|
argstart { $$ = $1; }
|
||||||
|
| arg SEP exp {
|
||||||
|
argarr_add($1, $3);
|
||||||
|
$$ = $1;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
exp:
|
||||||
|
NUM { $$ = ast_init(AST_TYPE_NUM, ast_num_data_init($1)); }
|
||||||
|
|
||||||
|
| SUB exp {
|
||||||
|
AST** argv = calloc(2, sizeof(AST*));
|
||||||
|
argv[0] = ast_init(AST_TYPE_NUM, ast_num_data_init(-1));
|
||||||
|
argv[1] = $2;
|
||||||
|
char* to = malloc(4);
|
||||||
|
strcpy(to, "mul");
|
||||||
|
$$ = ast_init(AST_TYPE_CALL, ast_call_data_init(to, 2, argv));
|
||||||
|
}
|
||||||
|
|
||||||
|
| LGROUP exp RGROUP { $$ = $2; }
|
||||||
|
|
||||||
|
// Variable reference.
|
||||||
|
//| WORD
|
||||||
|
|
||||||
|
| WORD LGROUP arg RGROUP {
|
||||||
|
size_t argc = $3->ln;
|
||||||
|
AST** argv = $3->buf;
|
||||||
|
argarr_destroypsv($3);
|
||||||
|
$$ = ast_init(AST_TYPE_CALL, ast_call_data_init($1, argc, argv));
|
||||||
|
}
|
||||||
|
|
||||||
|
| exp PLUS exp {
|
||||||
|
AST** argv = calloc(2, sizeof(AST*));
|
||||||
|
argv[0] = $1;
|
||||||
|
argv[1] = $3;
|
||||||
|
char* to = malloc(4);
|
||||||
|
strcpy(to, "sum");
|
||||||
|
$$ = ast_init(AST_TYPE_CALL, ast_call_data_init(to, 2, argv));
|
||||||
|
}
|
||||||
|
|
||||||
|
| exp SUB exp {
|
||||||
|
AST** argv = calloc(2, sizeof(AST*));
|
||||||
|
argv[0] = $1;
|
||||||
|
argv[1] = $3;
|
||||||
|
char* to = malloc(4);
|
||||||
|
strcpy(to, "sub");
|
||||||
|
$$ = ast_init(AST_TYPE_CALL, ast_call_data_init(to, 2, argv));
|
||||||
|
}
|
||||||
|
|
||||||
|
| exp MULT exp {
|
||||||
|
AST** argv = calloc(2, sizeof(AST*));
|
||||||
|
argv[0] = $1;
|
||||||
|
argv[1] = $3;
|
||||||
|
char* to = malloc(4);
|
||||||
|
strcpy(to, "mul");
|
||||||
|
$$ = ast_init(AST_TYPE_CALL, ast_call_data_init(to, 2, argv));
|
||||||
|
}
|
||||||
|
|
||||||
|
| exp DIV exp {
|
||||||
|
AST** argv = calloc(2, sizeof(AST*));
|
||||||
|
argv[0] = $1;
|
||||||
|
argv[1] = $3;
|
||||||
|
char* to = malloc(4);
|
||||||
|
strcpy(to, "div");
|
||||||
|
$$ = ast_init(AST_TYPE_CALL, ast_call_data_init(to, 2, argv));
|
||||||
|
}
|
||||||
|
%%
|
@@ -1,9 +1,13 @@
|
|||||||
#ifndef AST_H
|
#ifndef AST_H
|
||||||
#define AST_H
|
#define AST_H
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
AST_TYPE_NUM,
|
AST_TYPE_NUM, // A number.
|
||||||
AST_TYPE,CALL
|
AST_TYPE_CALL, // A function call.
|
||||||
|
AST_TYPE_VREF, // A variable reference.
|
||||||
|
AST_TYPE_MAX = AST_TYPE_CALL
|
||||||
} ASTType;
|
} ASTType;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -11,13 +15,33 @@ typedef struct {
|
|||||||
void* data;
|
void* data;
|
||||||
} AST;
|
} AST;
|
||||||
|
|
||||||
typedef struct {
|
AST* ast_init(ASTType type, void* data);
|
||||||
int val;
|
void ast_destroy(AST* ast);
|
||||||
} ASTTypeNum;
|
void ast_print(AST* ast);
|
||||||
|
void ast_print_i(AST* ast, int i);
|
||||||
|
|
||||||
|
typedef double ASTNumData;
|
||||||
|
|
||||||
|
ASTNumData* ast_num_data_init(double val);
|
||||||
|
void ast_num_data_destroy(ASTNumData* num);
|
||||||
|
void ast_num_print(ASTNumData*, int i);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char* to;
|
char* to; // What the call's to.
|
||||||
char** args;
|
size_t argc; // Argument count.
|
||||||
} ASTTypeCall;
|
AST** argv; // Argument vector.
|
||||||
|
} ASTCallData;
|
||||||
|
|
||||||
|
ASTCallData* ast_call_data_init(char* to, size_t argc, AST** argv);
|
||||||
|
void ast_call_data_destroy(ASTCallData* call);
|
||||||
|
void ast_call_print(ASTCallData*, int i);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char* to; // What the reference's to.
|
||||||
|
} ASTVrefData;
|
||||||
|
|
||||||
|
ASTVrefData* ast_vref_data_init(char* to);
|
||||||
|
void ast_vref_data_destroy(ASTVrefData* call);
|
||||||
|
void ast_vref_print(ASTVrefData*, int i);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -3,16 +3,18 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define DSTR_INITSZ 128
|
#define DSTR_INITSZ 2
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char* buf; // The buffer containing the string.
|
char* buf; // The buffer containing the string.
|
||||||
size_t bufsz; // The size of the buffer.
|
size_t sz; // The size of the buffer.
|
||||||
size_t ln; // The number of characters in the buffer.
|
size_t ln; // The number of characters in the buffer.
|
||||||
} Dstr;
|
} Dstr;
|
||||||
|
|
||||||
Dstr* dstr_init(void);
|
Dstr* dstr_init(void);
|
||||||
void dstr_destroy(Dstr* dstr);
|
void dstr_destroy(Dstr* dstr);
|
||||||
|
// Destroy Dstr structure but preserve ->buf.
|
||||||
|
void dstr_destroypsv(Dstr* dstr);
|
||||||
|
|
||||||
// Append ln characters of src to dest.
|
// Append ln characters of src to dest.
|
||||||
void dstr_append(Dstr* dest, char* src, size_t ln);
|
void dstr_append(Dstr* dest, char* src, size_t ln);
|
||||||
|
10
src/include/exec.h
Normal file
10
src/include/exec.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef EXEC_H
|
||||||
|
#define EXEC_H
|
||||||
|
|
||||||
|
#include "ast.h"
|
||||||
|
|
||||||
|
ASTNumData exec_exp(AST* ast);
|
||||||
|
ASTNumData exec_call(AST* ast);
|
||||||
|
void exec_print(double n);
|
||||||
|
|
||||||
|
#endif
|
@@ -1,70 +1,39 @@
|
|||||||
#ifndef LEXER_H
|
#ifndef LEXER_H
|
||||||
#define LEXER_H
|
#define LEXER_H
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "token.h"
|
#include "ast.h"
|
||||||
|
|
||||||
#define TOKENS_MAX 32
|
#define ARLN 8
|
||||||
#define ZERO_CHAR 30
|
|
||||||
|
|
||||||
// What the lexer is currently looking at.
|
extern char* inp;
|
||||||
typedef enum {
|
|
||||||
LEXER_STATE_CONFUSED, // Can't decide what it's looking at (also initial
|
|
||||||
// state).
|
|
||||||
LEXER_STATE_NUM, // Looking at a number.
|
|
||||||
LEXER_STATE_CALL, // Looking at a call.
|
|
||||||
LEXER_STATE_MAX = LEXER_STATE_CALL,
|
|
||||||
} LexerState;
|
|
||||||
|
|
||||||
static char* lexerstate_names[] = {
|
|
||||||
[LEXER_STATE_CONFUSED] = "CONFUSED",
|
|
||||||
[LEXER_STATE_NUM] = "NUM",
|
|
||||||
[LEXER_STATE_CALL] = "CALL",
|
|
||||||
};
|
|
||||||
|
|
||||||
// Lexer: converts text to tokens.
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
LexerState state; // What the lexer is looking at.
|
size_t sz;
|
||||||
size_t srcln; // The number of source chars.
|
size_t ln;
|
||||||
char* src; // The source text.
|
AST** buf;
|
||||||
char* cchar; // The current character.
|
} ArgArr;
|
||||||
size_t ntokens; // The number of tokens.
|
|
||||||
Token** tokens; // The tokens produced.
|
|
||||||
} Lexer;
|
|
||||||
|
|
||||||
// Create a lexer.
|
ArgArr* argarr_init();
|
||||||
Lexer* lexer_init(char* src);
|
void argarr_destroy(ArgArr* argarr);
|
||||||
|
// Destroy ArgArr structure but preserve -> buf.
|
||||||
|
void argarr_destroypsv(ArgArr* argarr);
|
||||||
|
void argarr_add(ArgArr* argarr, AST* arg);
|
||||||
|
|
||||||
// Destroy a lexer.
|
#include "../../build/grammars/grammar.tab.h"
|
||||||
void lexer_destroy(Lexer* lexer);
|
|
||||||
|
|
||||||
// Convert text to tokens.
|
extern YYSTYPE yylval;
|
||||||
void lexer_lex(Lexer* lexer);
|
|
||||||
|
|
||||||
// Lex in confused mode.
|
// Accumulate an integer.
|
||||||
void lexer_do_confused(Lexer* lexer);
|
int acc_int(int c);
|
||||||
|
|
||||||
// Lex in number mode.
|
// Accumulate a floating-point number.
|
||||||
void lexer_do_number(Lexer* lexer);
|
double acc_float(int c);
|
||||||
|
|
||||||
// Lex in call mode.
|
// Called by `yyparse()` (in bison-generated files.)
|
||||||
void lexer_do_call(Lexer* lexer);
|
int yylex();
|
||||||
|
void yyerror(char const* s);
|
||||||
// Increment the lexer's current character pointer.
|
|
||||||
void lexer_inc(Lexer* lexer);
|
|
||||||
|
|
||||||
// Add a token to the lexer.
|
|
||||||
void lexer_add_token(Lexer* lexer, Token* token);
|
|
||||||
|
|
||||||
// Print a representation of a Lexer.
|
|
||||||
void lexer_print(Lexer* lexer);
|
|
||||||
|
|
||||||
// Print a representation of a Lexer at specified indentation level.
|
|
||||||
void lexer_print_i(Lexer* lexer, int ilvl);
|
|
||||||
|
|
||||||
// Print a representation of a LexerState.
|
|
||||||
void lexerstate_print_raw(LexerState s);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,13 +0,0 @@
|
|||||||
#ifndef PARSER_H
|
|
||||||
#define PARSER_H
|
|
||||||
|
|
||||||
// Expression one of:
|
|
||||||
// - Operation
|
|
||||||
// - Number
|
|
||||||
|
|
||||||
// Operation contains:
|
|
||||||
// - Type
|
|
||||||
// - Expression 1
|
|
||||||
// - Expression 2
|
|
||||||
|
|
||||||
#endif
|
|
23
src/include/stack.h
Normal file
23
src/include/stack.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef STACK_H
|
||||||
|
#define STACK_H
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define STACK_MAX 64
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
size_t i; // Current index in the stack.
|
||||||
|
void* val[STACK_MAX]; // The stack itself.
|
||||||
|
} Stack;
|
||||||
|
|
||||||
|
Stack* stack_init();
|
||||||
|
// Destroy a stack.
|
||||||
|
// Note that `stack->i` must be `0`.
|
||||||
|
void stack_destroy(Stack* stack);
|
||||||
|
|
||||||
|
// Push a value to the stack.
|
||||||
|
void stack_push(Stack* stack, void* val);
|
||||||
|
// Pop a value from the stack.
|
||||||
|
void* stack_pop(Stack* stack);
|
||||||
|
|
||||||
|
#endif
|
@@ -1,39 +0,0 @@
|
|||||||
#ifndef TOKEN_H
|
|
||||||
#define TOKEN_H
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
TOKEN_TYPE_CALL,
|
|
||||||
TOKEN_TYPE_NUMBER,
|
|
||||||
TOKEN_TYPE_MAX = TOKEN_TYPE_NUMBER,
|
|
||||||
} TokenType;
|
|
||||||
|
|
||||||
// Token.
|
|
||||||
typedef struct {
|
|
||||||
TokenType type; // The type of the Token.
|
|
||||||
size_t valn; // The length of val.
|
|
||||||
char* val; // The text of the Token.
|
|
||||||
size_t len; // Length of the text of the Token.
|
|
||||||
} Token;
|
|
||||||
|
|
||||||
Token* token_init(TokenType type, char* val, size_t valn);
|
|
||||||
void token_destroy(Token* token);
|
|
||||||
|
|
||||||
// Prints out a representation of the Token.
|
|
||||||
void token_print(Token* token);
|
|
||||||
|
|
||||||
// Prints out a representation of the Token, with the specified indent level.
|
|
||||||
void token_print_i(Token* token, int ilevel);
|
|
||||||
|
|
||||||
// Prints out a representation of the TokenType.
|
|
||||||
void tokentype_print(TokenType t);
|
|
||||||
|
|
||||||
// Prints out a representation of the TokenType, with the specified indent
|
|
||||||
// level.
|
|
||||||
void tokentype_print_i(TokenType t, int ilevel);
|
|
||||||
|
|
||||||
// Prints a token's type. That's it.
|
|
||||||
void tokentype_print_raw(TokenType t);
|
|
||||||
|
|
||||||
#endif
|
|
@@ -18,28 +18,68 @@
|
|||||||
#define log_dbgf(msg, ...)
|
#define log_dbgf(msg, ...)
|
||||||
#endif // ifdef DBG else
|
#endif // ifdef DBG else
|
||||||
|
|
||||||
|
// Resent color code.
|
||||||
|
#define COL_RESET "\e[0m"
|
||||||
|
|
||||||
|
// Regular color codes.
|
||||||
|
#define COL_BLA "\e[0;30m"
|
||||||
|
#define COL_RED "\e[0;31m"
|
||||||
|
#define COL_GRE "\e[0;32m"
|
||||||
|
#define COL_YEL "\e[0;33m"
|
||||||
|
#define COL_BLU "\e[0;34m"
|
||||||
|
#define COL_MAG "\e[0;35m"
|
||||||
|
#define COL_CYA "\e[0;36m"
|
||||||
|
#define COL_WHI "\e[0;37m"
|
||||||
|
|
||||||
|
// Bold color codes.
|
||||||
|
#define COL_BBLA "\e[1;30m"
|
||||||
|
#define COL_BRED "\e[1;31m"
|
||||||
|
#define COL_BGRE "\e[1;32m"
|
||||||
|
#define COL_BYEL "\e[1;33m"
|
||||||
|
#define COL_BBLU "\e[1;34m"
|
||||||
|
#define COL_BMAG "\e[1;35m"
|
||||||
|
#define COL_BCYA "\e[1;36m"
|
||||||
|
#define COL_BWHI "\e[1;37m"
|
||||||
|
|
||||||
// Start in indent block.
|
// Start in indent block.
|
||||||
#define INDENT_BEGIN(ILVL) \
|
#define INDENT_BEGIN(ILVL) \
|
||||||
|
__attribute__((unused)) int INDENT_lvl = ILVL; \
|
||||||
Dstr* INDENT_spacing = dstr_init(); \
|
Dstr* INDENT_spacing = dstr_init(); \
|
||||||
for (int INDENT_j = 0; INDENT_j < ILVL; INDENT_j++) \
|
for (int INDENT_j = 0; INDENT_j < ILVL; INDENT_j++) \
|
||||||
dstr_appendch(INDENT_spacing, ' ');
|
dstr_appendch(INDENT_spacing, ' ');
|
||||||
|
|
||||||
// Print & indent the title of a section.
|
// Print & indent the title of a section.
|
||||||
#define INDENT_TITLE(THING, WHERE) \
|
#define INDENT_TITLE(THING, WHERE) \
|
||||||
printf("%s" THING " @ %p\n", INDENT_spacing->buf, WHERE);
|
printf("%s" COL_BCYA THING COL_RESET " @" COL_MAG " %p\n" COL_RESET, INDENT_spacing->buf, WHERE);
|
||||||
|
|
||||||
// Print & indent a thing.
|
// Print & indent a thing.
|
||||||
#define INDENT_FIELD(FIELD, VAL, ...) \
|
#define INDENT_FIELD(FIELD, VAL, ...) \
|
||||||
printf("%s " FIELD ": " VAL "\n", INDENT_spacing->buf, __VA_ARGS__);
|
printf("%s " COL_BWHI FIELD ": " COL_RESET COL_WHI VAL COL_RESET "\n", \
|
||||||
|
INDENT_spacing->buf, __VA_ARGS__);
|
||||||
|
|
||||||
// Print & indent a thing with a newline before the val.
|
// Print & indent a thing with a newline before the val.
|
||||||
#define INDENT_FIELD_NL(FIELD, VAL, ...) \
|
#define INDENT_FIELD_NL(FIELD, VAL, ...) \
|
||||||
printf("%s " FIELD ":\n %s " VAL "\n", INDENT_spacing->buf, \
|
printf("%s " COL_BWHI FIELD ":" COL_RESET "\n %s " COL_WHI VAL COL_RESET \
|
||||||
INDENT_spacing->buf, __VA_ARGS__);
|
"\n", \
|
||||||
|
INDENT_spacing->buf, INDENT_spacing->buf, __VA_ARGS__);
|
||||||
|
|
||||||
// Print & indent a thing without any newline.
|
// Print & indent a thing without any newline.
|
||||||
#define INDENT_FIELD_NONL(FIELD) printf("%s " FIELD ": ", INDENT_spacing->buf);
|
#define INDENT_FIELD_EXT_NONL_START(FIELD) \
|
||||||
|
printf("%s " COL_BWHI FIELD ":\n" COL_RESET COL_WHI, INDENT_spacing->buf);
|
||||||
|
#define INDENT_FIELD_NONL_END printf( "\n" COL_RESET);
|
||||||
|
|
||||||
#define INDENT_END dstr_destroy(INDENT_spacing);
|
// Print an array A of N things, by calling the function F.
|
||||||
|
#define INDENT_FIELD_LIST(FIELD, A, N, F) \
|
||||||
|
printf("%s " COL_BWHI FIELD ": [\n" COL_RESET, INDENT_spacing->buf); \
|
||||||
|
for (int INDENT_i = 0; INDENT_i < N; INDENT_i++) { \
|
||||||
|
F(A[INDENT_i], INDENT_lvl + 2); \
|
||||||
|
} \
|
||||||
|
printf(COL_BWHI "%s ]\n" COL_RESET, INDENT_spacing->buf);
|
||||||
|
|
||||||
|
// End an indent block.
|
||||||
|
#define INDENT_END printf(COL_RESET); dstr_destroy(INDENT_spacing);
|
||||||
|
|
||||||
|
// Allocate a pointer with a type.
|
||||||
|
#define talloc(T, X) T* X = malloc(sizeof(T));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
204
src/lexer.c
204
src/lexer.c
@@ -1,134 +1,120 @@
|
|||||||
|
#include <complex.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "include/lexer.h"
|
|
||||||
#include "include/dstr.h"
|
#include "include/dstr.h"
|
||||||
|
#include "include/lexer.h"
|
||||||
#include "include/util.h"
|
#include "include/util.h"
|
||||||
|
|
||||||
Lexer* lexer_init(char* src) {
|
ArgArr* argarr_init() {
|
||||||
Lexer* lexer = malloc(sizeof(Lexer));
|
ArgArr* argarr = malloc(sizeof(ArgArr));
|
||||||
|
|
||||||
lexer->src = src;
|
argarr->sz = ARLN * sizeof(AST*);
|
||||||
lexer->srcln = strlen(src);
|
argarr->ln = 0;
|
||||||
lexer->cchar = lexer->src;
|
argarr->buf = malloc(argarr->sz);
|
||||||
|
|
||||||
lexer->tokens = calloc(TOKENS_MAX, sizeof(Token*));
|
return argarr;
|
||||||
lexer->ntokens = 0;
|
|
||||||
lexer->state = LEXER_STATE_CONFUSED;
|
|
||||||
|
|
||||||
log_dbgf("created new lexer @ %p", lexer);
|
|
||||||
|
|
||||||
return lexer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lexer_destroy(Lexer* lexer) {
|
void argarr_destroy(ArgArr* argarr) {
|
||||||
free(lexer->src);
|
free(argarr->buf);
|
||||||
|
free(argarr);
|
||||||
for (int i = 0; i < lexer->ntokens; i++) token_destroy(lexer->tokens[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lexer_lex(Lexer* lexer) {
|
void argarr_destroypsv(ArgArr* argarr) { free(argarr); }
|
||||||
while (*lexer->cchar) {
|
|
||||||
switch (lexer->state) {
|
void argarr_add(ArgArr* argarr, AST* arg) {
|
||||||
case LEXER_STATE_CONFUSED: lexer_do_confused(lexer); break;
|
if ((argarr->ln + 1) * argarr->sz > argarr->sz) {
|
||||||
case LEXER_STATE_NUM: lexer_do_number(lexer); break;
|
argarr->sz *= 2;
|
||||||
case LEXER_STATE_CALL: lexer_do_call(lexer); break;
|
argarr->buf = realloc(argarr->buf, argarr->sz);
|
||||||
default: break;
|
log_dbgf(
|
||||||
|
"ArgArr @ %p doubled from %ld to %ld", argarr, argarr->sz / 2,
|
||||||
|
argarr->sz
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
argarr->buf[argarr->ln++] = arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
int acc_int(int c) {
|
||||||
|
int value = c - '0';
|
||||||
|
while (isdigit(*inp)) {
|
||||||
|
value = value * 10 + (*inp - '0'); // Accumulate value.
|
||||||
|
inp++;
|
||||||
}
|
}
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lexer_do_confused(Lexer* lexer) {
|
double acc_float(int c) {
|
||||||
log_dbgf("lexer @ %p entered confused mode @ char '%c' (%d)", lexer, *lexer->cchar, (int)*lexer->cchar);
|
int dplaces = 0;
|
||||||
|
double value = (double)(c - '0');
|
||||||
|
|
||||||
if (isdigit(*lexer->cchar)) {
|
// Grab everything prior to '.'.
|
||||||
lexer->state = LEXER_STATE_NUM;
|
while (isdigit(*inp)) {
|
||||||
lexer_do_number(lexer);
|
value = value * 10 + (*inp - '0'); // Accumulate value.
|
||||||
} else {
|
inp++;
|
||||||
lexer->state = LEXER_STATE_CALL;
|
|
||||||
lexer_do_call(lexer);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void lexer_do_number(Lexer* lexer) {
|
if (*inp == '.') {
|
||||||
log_dbgf("lexer @ %p entered number mode @ char '%c' (%d)", lexer, *lexer->cchar, (int)*lexer->cchar);
|
inp++;
|
||||||
|
|
||||||
// Length of the number string.
|
while (isdigit(*inp)) {
|
||||||
size_t numln;
|
value = value * 10 + (*inp - '0'); // Accumulate value.
|
||||||
|
dplaces++;
|
||||||
// Where the number string starts.
|
inp++;
|
||||||
char* start = lexer->cchar;
|
|
||||||
|
|
||||||
for (numln = 0; *lexer->cchar && isdigit(*lexer->cchar); numln++)
|
|
||||||
lexer_inc(lexer);
|
|
||||||
|
|
||||||
char* num = malloc(numln + 1);
|
|
||||||
memcpy(num, start, numln);
|
|
||||||
num[numln] = '\0';
|
|
||||||
|
|
||||||
lexer_add_token(lexer, token_init(TOKEN_TYPE_NUMBER, num, numln));
|
|
||||||
lexer->state = LEXER_STATE_CONFUSED;
|
|
||||||
}
|
|
||||||
|
|
||||||
void lexer_do_call(Lexer* lexer) {
|
|
||||||
log_dbgf("lexer @ %p entered call mode @ char '%c' (%d)", lexer, *lexer->cchar, (int)*lexer->cchar);
|
|
||||||
|
|
||||||
// Size of the call string.
|
|
||||||
size_t callln;
|
|
||||||
|
|
||||||
// Where the call string starts.
|
|
||||||
char* start = lexer->cchar;
|
|
||||||
|
|
||||||
for (callln = 0; *lexer->cchar && (!isdigit(*lexer->cchar)); callln++)
|
|
||||||
lexer_inc(lexer);
|
|
||||||
|
|
||||||
char* call = malloc(callln + 1);
|
|
||||||
memcpy(call, start, callln);
|
|
||||||
call[callln] = '\0';
|
|
||||||
|
|
||||||
lexer_add_token(lexer, token_init(TOKEN_TYPE_CALL, call, callln));
|
|
||||||
|
|
||||||
lexer->state = LEXER_STATE_CONFUSED;
|
|
||||||
}
|
|
||||||
|
|
||||||
void lexer_inc(Lexer* lexer) {
|
|
||||||
lexer->cchar += sizeof(char);
|
|
||||||
}
|
|
||||||
|
|
||||||
void lexer_add_token(Lexer* lexer, Token* token) {
|
|
||||||
assert(lexer->ntokens < TOKENS_MAX);
|
|
||||||
|
|
||||||
if (lexer->ntokens < TOKENS_MAX - 1) {
|
|
||||||
lexer->tokens[lexer->ntokens] = token;
|
|
||||||
lexer->ntokens++;
|
|
||||||
|
|
||||||
log_dbgf("added token (total: %ld)", lexer->ntokens);
|
|
||||||
}
|
}
|
||||||
}
|
value = value / pow(10, dplaces);
|
||||||
|
|
||||||
void lexer_print(Lexer* lexer) { lexer_print_i(lexer, 0); }
|
|
||||||
|
|
||||||
void lexer_print_i(Lexer* lexer, int ilvl) {
|
|
||||||
INDENT_BEGIN(ilvl);
|
|
||||||
INDENT_TITLE("Lexer", lexer);
|
|
||||||
INDENT_FIELD_NONL("state");
|
|
||||||
lexerstate_print_raw(lexer->state); putchar('\n');
|
|
||||||
INDENT_FIELD("srcln", "%ld", lexer->srcln);
|
|
||||||
INDENT_FIELD_NL("src", "\"%s\"", lexer->src);
|
|
||||||
INDENT_FIELD("cchar", "'%c'", *lexer->cchar);
|
|
||||||
INDENT_FIELD("ntokens", "%ld", lexer->ntokens);
|
|
||||||
printf("%s tokens: [\n", INDENT_spacing->buf);
|
|
||||||
|
|
||||||
for (int i = 0; i < lexer->ntokens; i++) {
|
|
||||||
token_print_i(lexer->tokens[i], ilvl + 2);
|
|
||||||
printf(",\n\n");
|
|
||||||
}
|
}
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lexerstate_print_raw(LexerState s) {
|
char* acc_word(int c) {
|
||||||
if (s > LEXER_STATE_MAX)
|
Dstr* val = dstr_init();
|
||||||
printf("Unknown (%d)", s) && log_dbgf("%d is not a valid LexerState (max: %d)", s, TOKEN_TYPE_MAX)
|
do {
|
||||||
else printf("%s", lexerstate_names[s]);
|
dstr_appendch(val, *(inp - 1));
|
||||||
|
inp++;
|
||||||
|
} while (isalpha(*inp));
|
||||||
|
dstr_appendch(val, *(inp - 1));
|
||||||
|
|
||||||
|
char* ret = val->buf;
|
||||||
|
dstr_destroypsv(val);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int yylex() {
|
||||||
|
if (*inp == '\0') return YYEOF;
|
||||||
|
|
||||||
|
// Skip all whitespace.
|
||||||
|
while (*inp == ' ' || *inp == '\t') inp++;
|
||||||
|
|
||||||
|
// Assign & consume current character.
|
||||||
|
int c = *inp++;
|
||||||
|
|
||||||
|
// Check for NUM.
|
||||||
|
if (isdigit(c)) {
|
||||||
|
yylval.fval = acc_float(c); // Set the token value.
|
||||||
|
return NUM;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isalpha(c)) {
|
||||||
|
yylval.strval = acc_word(c);
|
||||||
|
return WORD;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (c) {
|
||||||
|
case '+': return PLUS;
|
||||||
|
case '\n': return NL;
|
||||||
|
case '-': return SUB;
|
||||||
|
case '*': return MULT;
|
||||||
|
case '/': return DIV;
|
||||||
|
case '(': return LGROUP;
|
||||||
|
case ')': return RGROUP;
|
||||||
|
case ',': return SEP;
|
||||||
|
default: fprintf(stderr, "Unexpected character: %c\n", c);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
void yyerror(char const* s) { fprintf(stderr, "Parse error: %s\n", s); }
|
||||||
|
70
src/main.c
70
src/main.c
@@ -1,26 +1,68 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "include/ast.h"
|
||||||
#include "include/dstr.h"
|
#include "include/dstr.h"
|
||||||
#include "include/token.h"
|
#include "include/exec.h"
|
||||||
#include "include/util.h"
|
|
||||||
#include "include/lexer.h"
|
#include "include/lexer.h"
|
||||||
|
#include "include/util.h"
|
||||||
|
|
||||||
|
#include "../build/grammars/grammar.tab.h"
|
||||||
|
|
||||||
|
// Global Abstract Syntax Tree.
|
||||||
|
extern AST* root;
|
||||||
|
|
||||||
|
// Global input text.
|
||||||
|
char* inp = NULL;
|
||||||
|
|
||||||
|
extern int yyparse();
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
while(1) {
|
|
||||||
Dstr* cline = dstr_init(); // The current line.
|
if (argc - 1 && strlen(argv[1]) > 0 && (inp = argv[1]) && !yyparse()) {
|
||||||
|
log_dbg("Parsed successfully!\n");
|
||||||
|
exec_print(exec_exp(root));
|
||||||
|
ast_destroy(root);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
Dstr* ln = dstr_init();
|
||||||
|
char c;
|
||||||
|
|
||||||
printf("> ");
|
printf("> ");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
for (char cch; (cch = getc(stdin)) != '\n';) {
|
|
||||||
log_dbgf("cchar: %c", cch);
|
// Accumulate line.
|
||||||
dstr_appendch(cline, cch);
|
do {
|
||||||
|
c = getc(stdin);
|
||||||
|
switch (c) {
|
||||||
|
case EOF: dstr_destroy(ln); goto lnskip;
|
||||||
|
case '\n': goto lnend;
|
||||||
|
default: dstr_appendch(ln, c); log_dbgf("cchar: %c", c);
|
||||||
|
}
|
||||||
|
} while (1);
|
||||||
|
|
||||||
|
lnend:
|
||||||
|
|
||||||
|
log_dbgf("cline: %s", ln->buf);
|
||||||
|
|
||||||
|
if (ln->ln > 0) {
|
||||||
|
inp = ln->buf;
|
||||||
|
if (yyparse() == 0) {
|
||||||
|
log_dbg("Parsed successfully!\n");
|
||||||
|
} else printf("Parse error.\n");
|
||||||
|
|
||||||
|
exec_print(exec_exp(root));
|
||||||
|
#ifdef DBG
|
||||||
|
ast_print(root);
|
||||||
|
#endif
|
||||||
|
ast_destroy(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
log_dbgf("cline: %s", cline->buf);
|
dstr_destroy(ln);
|
||||||
|
}
|
||||||
|
lnskip:;
|
||||||
|
|
||||||
if (cline->ln > 0) {
|
return 0;
|
||||||
Lexer* lexer = lexer_init(cline->buf);
|
|
||||||
lexer_lex(lexer);
|
|
||||||
lexer_print(lexer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
40
src/stack.c
Normal file
40
src/stack.c
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "include/stack.h"
|
||||||
|
#include "include/util.h"
|
||||||
|
|
||||||
|
Stack* stack_init() {
|
||||||
|
talloc(Stack, stack);
|
||||||
|
|
||||||
|
memset(stack->val, 0, sizeof(void*) * STACK_MAX);
|
||||||
|
stack->i = 0;
|
||||||
|
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
void stack_destroy(Stack* stack) {
|
||||||
|
// Can only free an empty stack.
|
||||||
|
assert(stack->i == 0);
|
||||||
|
free(stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
void stack_push(Stack* stack, void* val) {
|
||||||
|
if (stack->i >= STACK_MAX) {
|
||||||
|
log_dbgf("Ran out of stack (max: %d)", STACK_MAX);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
stack->val[stack->i] = val;
|
||||||
|
stack->i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* stack_pop(Stack* stack) {
|
||||||
|
if (stack->i <= 0) {
|
||||||
|
log_dbg("Can't pop empty stack.");
|
||||||
|
return (void*)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return stack->val[--stack->i];
|
||||||
|
}
|
62
src/token.c
62
src/token.c
@@ -1,62 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "include/token.h"
|
|
||||||
#include "include/dstr.h"
|
|
||||||
#include "include/util.h"
|
|
||||||
|
|
||||||
static char* tokentype_names[] = {
|
|
||||||
[TOKEN_TYPE_CALL] = "CALL",
|
|
||||||
[TOKEN_TYPE_NUMBER] = "NUMBER",
|
|
||||||
};
|
|
||||||
|
|
||||||
Token* token_init(TokenType type, char* val, size_t valn) {
|
|
||||||
Token* t = malloc(sizeof(Token));
|
|
||||||
|
|
||||||
t->type = type;
|
|
||||||
t->valn = valn;
|
|
||||||
t->val = val;
|
|
||||||
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
void token_destroy(Token* t) {
|
|
||||||
free(t->val);
|
|
||||||
free(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
void token_print(Token* token) { token_print_i(token, 0); }
|
|
||||||
|
|
||||||
void token_print_i(Token *token, int ilvl) {
|
|
||||||
INDENT_BEGIN(ilvl);
|
|
||||||
|
|
||||||
INDENT_TITLE("Token", token);
|
|
||||||
INDENT_FIELD_NONL("type");
|
|
||||||
tokentype_print_raw(token->type);
|
|
||||||
putchar('\n');
|
|
||||||
INDENT_FIELD("valn", "%ld", token->valn);
|
|
||||||
INDENT_FIELD_NL("val", "\"%s\"", token->val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tokentype_print_raw(TokenType t) {
|
|
||||||
if (t > TOKEN_TYPE_MAX) {
|
|
||||||
printf("Unknown (%d)", t);
|
|
||||||
log_dbgf("%d is not a valid TokenType (max: %d)", t, TOKEN_TYPE_MAX);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("%s", tokentype_names[t]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tokentype_print(TokenType t) { tokentype_print_i(t, 0); }
|
|
||||||
|
|
||||||
void tokentype_print_i(TokenType t, int i) {
|
|
||||||
INDENT_BEGIN(i);
|
|
||||||
|
|
||||||
if (t > TOKEN_TYPE_MAX) {
|
|
||||||
INDENT_FIELD("val", "Unknown (%d)", t);
|
|
||||||
log_dbgf("%d is not a valid TokenType (max: %d)", t, TOKEN_TYPE_MAX);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
INDENT_FIELD("val", "%s", tokentype_names[t]);
|
|
||||||
}
|
|
1
test/Unity
Submodule
1
test/Unity
Submodule
Submodule test/Unity added at 73237c5d22
39
test/dstr.c
39
test/dstr.c
@@ -1,39 +0,0 @@
|
|||||||
#include "../src/include/dstr.h"
|
|
||||||
#include "unity/unity.h"
|
|
||||||
#include "registry.h"
|
|
||||||
|
|
||||||
void test_dstr_init() {
|
|
||||||
Dstr* dstr = dstr_init();
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_INT(DSTR_INITSZ, dstr->bufsz);
|
|
||||||
TEST_ASSERT_EQUAL_STRING(malloc(DSTR_INITSZ), dstr->buf);
|
|
||||||
TEST_ASSERT_EQUAL_size_t(0, dstr->ln);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_dstr_append() {
|
|
||||||
char* str1 = malloc(2);
|
|
||||||
str1[0] = 'h';
|
|
||||||
str1[1] = '\0';
|
|
||||||
|
|
||||||
char* str2 = malloc(DSTR_INITSZ);
|
|
||||||
str2[0] = 'h';
|
|
||||||
str2[1] = '\0';
|
|
||||||
|
|
||||||
|
|
||||||
Dstr* dstr = dstr_init();
|
|
||||||
dstr_append(dstr, str1, 1);
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_STRING(str2, dstr->buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_dstr() {
|
|
||||||
UNITY_BEGIN();
|
|
||||||
RUN_TEST(test_dstr_init);
|
|
||||||
RUN_TEST(test_dstr_append);
|
|
||||||
UNITY_END();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((constructor)) void register_dstr() {
|
|
||||||
register_test(test_dstr);
|
|
||||||
}
|
|
52
test/lexer.c
52
test/lexer.c
@@ -1,52 +0,0 @@
|
|||||||
#include "../src/include/lexer.h"
|
|
||||||
#include "unity/unity.h"
|
|
||||||
#include "registry.h"
|
|
||||||
|
|
||||||
void test_lexer_init() {
|
|
||||||
char* src = malloc(sizeof("a1b2"));
|
|
||||||
src = "a1b2";
|
|
||||||
Lexer* lexer = lexer_init(src);
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_STRING(src, lexer->src);
|
|
||||||
TEST_ASSERT_EQUAL_INT(4, lexer->srcl);
|
|
||||||
TEST_ASSERT_EQUAL_CHAR(src[0], *lexer->cchar);
|
|
||||||
TEST_ASSERT_EQUAL_INT(LEXER_STATE_CONFUSED, lexer->state);
|
|
||||||
// Hope that token arr. is right size :).
|
|
||||||
TEST_ASSERT_EQUAL_INT(0, lexer->ntokens);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_lexer_lex_callnum() {
|
|
||||||
char* src = malloc(sizeof("a1b2"));
|
|
||||||
src = "a1b2";
|
|
||||||
Lexer* lexer = lexer_init(src);
|
|
||||||
|
|
||||||
Token* tokens[4] = {
|
|
||||||
token_init(TOKEN_TYPE_CALL, "a"),
|
|
||||||
token_init(TOKEN_TYPE_NUMBER, "1"),
|
|
||||||
token_init(TOKEN_TYPE_CALL, "b"),
|
|
||||||
token_init(TOKEN_TYPE_NUMBER, "2"),
|
|
||||||
};
|
|
||||||
|
|
||||||
lexer_lex(lexer);
|
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL_INT(4, lexer->ntokens);
|
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
printf("h");
|
|
||||||
fflush(stdout);
|
|
||||||
TEST_ASSERT_EQUAL_INT(tokens[i]->type, lexer->tokens[i]->type);
|
|
||||||
TEST_ASSERT_EQUAL_STRING(tokens[i]->val, lexer->tokens[i]->val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_lexer() {
|
|
||||||
UNITY_BEGIN();
|
|
||||||
RUN_TEST(test_lexer_init);
|
|
||||||
RUN_TEST(test_lexer_lex_callnum);
|
|
||||||
UNITY_END();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((constructor)) void register_lexer() {
|
|
||||||
register_test(test_lexer);
|
|
||||||
}
|
|
12
test/main.c
12
test/main.c
@@ -1,12 +0,0 @@
|
|||||||
#include "registry.h"
|
|
||||||
#include "unity/unity.h"
|
|
||||||
|
|
||||||
void (*tests[30])();
|
|
||||||
|
|
||||||
void setUp() {}
|
|
||||||
void tearDown() {}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
run_all_tests();
|
|
||||||
return 0;
|
|
||||||
}
|
|
@@ -1,20 +0,0 @@
|
|||||||
#include "registry.h"
|
|
||||||
#include "unity/unity_internals.h"
|
|
||||||
|
|
||||||
#define TESTS_MAX 128
|
|
||||||
|
|
||||||
static Test tests[TESTS_MAX];
|
|
||||||
static int test_count = 0;
|
|
||||||
|
|
||||||
void register_test(Test t) {
|
|
||||||
if (test_count < TESTS_MAX) {
|
|
||||||
tests[test_count] = t;
|
|
||||||
test_count++;
|
|
||||||
} else printf("Maximum number of tests (%d) exceeded.\n", TESTS_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
void run_all_tests() {
|
|
||||||
for (int i = 0; i < test_count; i++) {
|
|
||||||
int res = tests[i]();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,15 +0,0 @@
|
|||||||
#ifndef REGISTRY_H
|
|
||||||
#define REGISTRY_H
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "unity/unity.h"
|
|
||||||
|
|
||||||
typedef int (*Test)(void);
|
|
||||||
|
|
||||||
// Register a new test function.
|
|
||||||
void register_test(Test);
|
|
||||||
|
|
||||||
// Run all registered tests.
|
|
||||||
void run_all_tests();
|
|
||||||
|
|
||||||
#endif
|
|
79
test/test_dstr.c
Normal file
79
test/test_dstr.c
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
#include "../src/include/dstr.h"
|
||||||
|
#include "Unity/src/unity.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
void setUp() {};
|
||||||
|
void tearDown() {};
|
||||||
|
|
||||||
|
void test_dstr_init() {
|
||||||
|
Dstr* dstr = dstr_init();
|
||||||
|
TEST_ASSERT_EQUAL(0, strlen(dstr->buf));
|
||||||
|
TEST_ASSERT_EQUAL(0, dstr->ln);
|
||||||
|
TEST_ASSERT_EQUAL(DSTR_INITSZ, dstr->bufsz);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_dstr_append() {
|
||||||
|
Dstr* dstr;
|
||||||
|
|
||||||
|
// Test simple appending.
|
||||||
|
dstr = dstr_init();
|
||||||
|
char* hello_world = "Hello, world!";
|
||||||
|
dstr_append(dstr, hello_world, strlen(hello_world));
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_STRING(hello_world, dstr->buf);
|
||||||
|
TEST_ASSERT_EQUAL(strlen(hello_world), dstr->ln);
|
||||||
|
TEST_ASSERT_EQUAL(DSTR_INITSZ, dstr->bufsz);
|
||||||
|
|
||||||
|
dstr_destroy(dstr);
|
||||||
|
|
||||||
|
// Test buffer doubling.
|
||||||
|
dstr = dstr_init();
|
||||||
|
|
||||||
|
char h[DSTR_INITSZ + 20];
|
||||||
|
memset(h, 'h', DSTR_INITSZ + 19);
|
||||||
|
h[DSTR_INITSZ + 19] = '\0';
|
||||||
|
dstr_append(dstr, h, strlen(h));
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_STRING(h, dstr->buf);
|
||||||
|
TEST_ASSERT_EQUAL(strlen(h), dstr->ln);
|
||||||
|
TEST_ASSERT_EQUAL(DSTR_INITSZ * 2, dstr->bufsz);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_dstr_appendch() {
|
||||||
|
Dstr* dstr;
|
||||||
|
|
||||||
|
// Test simple character appending.
|
||||||
|
dstr = dstr_init();
|
||||||
|
char c = 'c';
|
||||||
|
char* c_str = "c";
|
||||||
|
dstr_appendch(dstr, c);
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_STRING(c_str, dstr->buf);
|
||||||
|
TEST_ASSERT_EQUAL(strlen(c_str), dstr->ln);
|
||||||
|
TEST_ASSERT_EQUAL(DSTR_INITSZ, dstr->bufsz);
|
||||||
|
|
||||||
|
dstr_destroy(dstr);
|
||||||
|
|
||||||
|
// Test buffer doubling.
|
||||||
|
dstr = dstr_init();
|
||||||
|
|
||||||
|
// Test against this string.
|
||||||
|
char h[DSTR_INITSZ + 20];
|
||||||
|
memset(h, 'h', DSTR_INITSZ + 19);
|
||||||
|
h[DSTR_INITSZ + 19] = '\0';
|
||||||
|
|
||||||
|
for (int i = 0; i < DSTR_INITSZ + 19; i++) dstr_appendch(dstr, 'h');
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_STRING(h, dstr->buf);
|
||||||
|
TEST_ASSERT_EQUAL(strlen(h), dstr->ln);
|
||||||
|
TEST_ASSERT_EQUAL(DSTR_INITSZ * 2, dstr->bufsz);
|
||||||
|
}
|
||||||
|
|
||||||
|
// not needed when using generate_test_runner.rb
|
||||||
|
int main(void) {
|
||||||
|
UNITY_BEGIN();
|
||||||
|
RUN_TEST(test_dstr_init);
|
||||||
|
RUN_TEST(test_dstr_append);
|
||||||
|
RUN_TEST(test_dstr_appendch);
|
||||||
|
return UNITY_END();
|
||||||
|
}
|
24
test/token.c
24
test/token.c
@@ -1,24 +0,0 @@
|
|||||||
#include "unity/unity.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "../src/include/token.h"
|
|
||||||
#include "registry.h"
|
|
||||||
#include "unity/unity_internals.h"
|
|
||||||
|
|
||||||
void test_token_init() {
|
|
||||||
char* s = malloc(sizeof("Hello, world!"));
|
|
||||||
s = "Hello, world!";
|
|
||||||
Token* t = token_init(TOKEN_TYPE_CALL, s);
|
|
||||||
TEST_ASSERT_EQUAL(TOKEN_TYPE_CALL, t->type);
|
|
||||||
TEST_ASSERT_EQUAL_STRING("Hello, world!", t->val);
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_token() {
|
|
||||||
UNITY_BEGIN();
|
|
||||||
RUN_TEST(test_token_init);
|
|
||||||
return UNITY_END();
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((constructor)) void register_token() {
|
|
||||||
register_test(test_token);
|
|
||||||
}
|
|
@@ -1,21 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, Greg Williams
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
2501
test/unity/unity.c
2501
test/unity/unity.c
File diff suppressed because it is too large
Load Diff
@@ -1,698 +0,0 @@
|
|||||||
/* =========================================================================
|
|
||||||
Unity - A Test Framework for C
|
|
||||||
ThrowTheSwitch.org
|
|
||||||
Copyright (c) 2007-24 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
||||||
SPDX-License-Identifier: MIT
|
|
||||||
========================================================================= */
|
|
||||||
|
|
||||||
#ifndef UNITY_FRAMEWORK_H
|
|
||||||
#define UNITY_FRAMEWORK_H
|
|
||||||
#define UNITY
|
|
||||||
|
|
||||||
#define UNITY_VERSION_MAJOR 2
|
|
||||||
#define UNITY_VERSION_MINOR 6
|
|
||||||
#define UNITY_VERSION_BUILD 0
|
|
||||||
#define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | (UNITY_VERSION_MINOR << 8) | UNITY_VERSION_BUILD)
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "unity_internals.h"
|
|
||||||
|
|
||||||
/*-------------------------------------------------------
|
|
||||||
* Test Setup / Teardown
|
|
||||||
*-------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* These functions are intended to be called before and after each test.
|
|
||||||
* If using unity directly, these will need to be provided for each test
|
|
||||||
* executable built. If you are using the test runner generator and/or
|
|
||||||
* Ceedling, these are optional. */
|
|
||||||
void setUp(void);
|
|
||||||
void tearDown(void);
|
|
||||||
|
|
||||||
/* These functions are intended to be called at the beginning and end of an
|
|
||||||
* entire test suite. suiteTearDown() is passed the number of tests that
|
|
||||||
* failed, and its return value becomes the exit code of main(). If using
|
|
||||||
* Unity directly, you're in charge of calling these if they are desired.
|
|
||||||
* If using Ceedling or the test runner generator, these will be called
|
|
||||||
* automatically if they exist. */
|
|
||||||
void suiteSetUp(void);
|
|
||||||
int suiteTearDown(int num_failures);
|
|
||||||
|
|
||||||
/*-------------------------------------------------------
|
|
||||||
* Test Reset and Verify
|
|
||||||
*-------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* These functions are intended to be called before during tests in order
|
|
||||||
* to support complex test loops, etc. Both are NOT built into Unity. Instead
|
|
||||||
* the test runner generator will create them. resetTest will run teardown and
|
|
||||||
* setup again, verifying any end-of-test needs between. verifyTest will only
|
|
||||||
* run the verification. */
|
|
||||||
void resetTest(void);
|
|
||||||
void verifyTest(void);
|
|
||||||
|
|
||||||
/*-------------------------------------------------------
|
|
||||||
* 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>
|
|
||||||
* - If you cannot use the automatic methods above, you can force Unity by using these options:
|
|
||||||
* - define UNITY_SUPPORT_64
|
|
||||||
* - set UNITY_INT_WIDTH
|
|
||||||
* - set UNITY_LONG_WIDTH
|
|
||||||
* - set 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_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_EXCLUDE_FLOAT_PRINT to trim binary size, won't print floating point values in errors
|
|
||||||
|
|
||||||
* Output
|
|
||||||
* - by default, Unity prints to standard out with putchar. define UNITY_OUTPUT_CHAR(a) with a different function if desired
|
|
||||||
* - define UNITY_DIFFERENTIATE_FINAL_FAIL to print FAILED (vs. FAIL) at test end summary - for automated search for failure
|
|
||||||
|
|
||||||
* 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(...), TEST_RANGE(...) and/or TEST_MATRIX(...) which basically evaluates to nothing
|
|
||||||
|
|
||||||
* Tests with Arguments
|
|
||||||
* - you'll want to define UNITY_USE_COMMAND_LINE_ARGS if you have the test runner passing arguments to Unity
|
|
||||||
|
|
||||||
*-------------------------------------------------------
|
|
||||||
* 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_MESSAGE(message) UnityMessage((message), __LINE__)
|
|
||||||
#define TEST_ONLY()
|
|
||||||
#ifdef UNITY_INCLUDE_PRINT_FORMATTED
|
|
||||||
#define TEST_PRINTF(message, ...) UnityPrintF(__LINE__, (message), ##__VA_ARGS__)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* It is not necessary for you to call PASS. A PASS condition is assumed if nothing fails.
|
|
||||||
* This method allows you to abort a test immediately with a PASS state, ignoring the remainder of the test. */
|
|
||||||
#define TEST_PASS() TEST_ABORT()
|
|
||||||
#define TEST_PASS_MESSAGE(message) do { UnityMessage((message), __LINE__); TEST_ABORT(); } while (0)
|
|
||||||
|
|
||||||
/*-------------------------------------------------------
|
|
||||||
* Build Directives
|
|
||||||
*-------------------------------------------------------
|
|
||||||
|
|
||||||
* These macros do nothing, but they are useful for additional build context.
|
|
||||||
* Tools (like Ceedling) can scan for these directives and make use of them for
|
|
||||||
* per-test-executable #include search paths and linking. */
|
|
||||||
|
|
||||||
/* Add source files to a test executable's compilation and linking. Ex: TEST_SOURCE_FILE("sandwiches.c") */
|
|
||||||
#define TEST_SOURCE_FILE(a)
|
|
||||||
|
|
||||||
/* Customize #include search paths for a test executable's compilation. Ex: TEST_INCLUDE_PATH("src/module_a/inc") */
|
|
||||||
#define TEST_INCLUDE_PATH(a)
|
|
||||||
|
|
||||||
/*-------------------------------------------------------
|
|
||||||
* 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")
|
|
||||||
#define TEST_ASSERT_EMPTY(pointer) UNITY_TEST_ASSERT_EMPTY( (pointer), __LINE__, " Expected Empty")
|
|
||||||
#define TEST_ASSERT_NOT_EMPTY(pointer) UNITY_TEST_ASSERT_NOT_EMPTY((pointer), __LINE__, " Expected Non-Empty")
|
|
||||||
|
|
||||||
/* 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_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_size_t(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT((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_EQUAL_CHAR(expected, actual) UNITY_TEST_ASSERT_EQUAL_CHAR((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), (UNITY_UINT)(-1), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_BITS_LOW(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT)(0), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_BIT_HIGH(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT)1 << (bit)), (UNITY_UINT)(-1), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_BIT_LOW(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT)1 << (bit)), (UNITY_UINT)(0), (actual), __LINE__, NULL)
|
|
||||||
|
|
||||||
/* Integer Not Equal To (of all sizes) */
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_size_t(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_CHAR(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_CHAR((threshold), (actual), __LINE__, NULL)
|
|
||||||
|
|
||||||
/* Integer Greater Than/ Less Than (of all sizes) */
|
|
||||||
#define TEST_ASSERT_GREATER_THAN(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_size_t(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_CHAR(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_CHAR((threshold), (actual), __LINE__, NULL)
|
|
||||||
|
|
||||||
#define TEST_ASSERT_LESS_THAN(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_size_t(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_HEX64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_CHAR(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_CHAR((threshold), (actual), __LINE__, NULL)
|
|
||||||
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_size_t(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_CHAR(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, NULL)
|
|
||||||
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_size_t(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_CHAR(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_CHAR((threshold), (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_size_t_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT_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)
|
|
||||||
#define TEST_ASSERT_CHAR_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_CHAR_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
|
||||||
|
|
||||||
/* Integer Array Ranges (of all sizes) */
|
|
||||||
#define TEST_ASSERT_INT_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_INT8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_INT16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_INT32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_INT64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_UINT64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_size_t_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_HEX_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_HEX16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_HEX32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_CHAR_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __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_size_t_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT_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)
|
|
||||||
#define TEST_ASSERT_EQUAL_CHAR_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_CHAR_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
|
|
||||||
/* Arrays Compared To Single Value */
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT8((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT16((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT32((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT64((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT8((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT16((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT32((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT64((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_size_t(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX8((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX16((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX64((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_PTR(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_PTR((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_STRING(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_STRING((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_MEMORY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY((expected), (actual), (len), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_CHAR(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_CHAR((expected), (actual), (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_FLOAT_NOT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_FLOAT_NOT_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_NOT_EQUAL_FLOAT(expected, actual) UNITY_TEST_ASSERT_NOT_EQUAL_FLOAT((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_FLOAT_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_FLOAT_ARRAY_WITHIN((delta), (expected), (actual), (num_elements), __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_EACH_EQUAL_FLOAT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_FLOAT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_FLOAT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_FLOAT(threshold, actual) UNITY_TEST_ASSERT_LESS_THAN_FLOAT((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_FLOAT(threshold, actual) UNITY_TEST_ASSERT_LESS_OR_EQUAL_FLOAT((threshold), (actual), __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_DOUBLE_NOT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_DOUBLE_NOT_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_NOT_EQUAL_DOUBLE(expected, actual) UNITY_TEST_ASSERT_NOT_EQUAL_DOUBLE((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_DOUBLE_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_DOUBLE_ARRAY_WITHIN((delta), (expected), (actual), (num_elements), __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_EACH_EQUAL_DOUBLE(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_THAN_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_LESS_THAN_DOUBLE((threshold), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_LESS_OR_EQUAL_DOUBLE((threshold), (actual), __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)
|
|
||||||
|
|
||||||
/* Shorthand */
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_OLD
|
|
||||||
#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")
|
|
||||||
#endif
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_INT
|
|
||||||
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
|
||||||
#endif
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_MEM
|
|
||||||
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_MEMORY((&expected), (&actual), sizeof(expected), __LINE__, NULL)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
|
||||||
#endif
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_RAW
|
|
||||||
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) == (actual)), __LINE__, " Expected Equal")
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal")
|
|
||||||
#endif
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_NONE
|
|
||||||
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*-------------------------------------------------------
|
|
||||||
* 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))
|
|
||||||
#define TEST_ASSERT_EMPTY_MESSAGE(pointer, message) UNITY_TEST_ASSERT_EMPTY( (pointer), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EMPTY_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NOT_EMPTY((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_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_size_t_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT( (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), (UNITY_UINT32)(-1), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_BITS_LOW_MESSAGE(mask, actual, message) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(0), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_BIT_HIGH_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(-1), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_BIT_LOW_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EQUAL_CHAR_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_CHAR((expected), (actual), __LINE__, (message))
|
|
||||||
|
|
||||||
/* Integer Not Equal To (of all sizes) */
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_CHAR((threshold), (actual), __LINE__, (message))
|
|
||||||
|
|
||||||
|
|
||||||
/* Integer Greater Than/ Less Than (of all sizes) */
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_CHAR((threshold), (actual), __LINE__, (message))
|
|
||||||
|
|
||||||
#define TEST_ASSERT_LESS_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_CHAR((threshold), (actual), __LINE__, (message))
|
|
||||||
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, (message))
|
|
||||||
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_CHAR((threshold), (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_size_t_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT_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))
|
|
||||||
#define TEST_ASSERT_CHAR_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_CHAR_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
|
||||||
|
|
||||||
/* Integer Array Ranges (of all sizes) */
|
|
||||||
#define TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_INT32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_UINT32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_size_t_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_HEX_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __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_size_t_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT_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))
|
|
||||||
#define TEST_ASSERT_EQUAL_CHAR_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_CHAR_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
|
|
||||||
/* Arrays Compared To Single Value*/
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT8((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT16((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT32((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_INT64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT64((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT8((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT16((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT32((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_UINT64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT64((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_size_t_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX8((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX16((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_HEX64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX64((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_PTR_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_PTR((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_STRING_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_STRING((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_MEMORY_MESSAGE(expected, actual, len, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY((expected), (actual), (len), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_EACH_EQUAL_CHAR_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_CHAR((expected), (actual), (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_NOT_EQUAL_FLOAT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_FLOAT((expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_FLOAT_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_FLOAT_ARRAY_WITHIN((delta), (expected), (actual), (num_elements), __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_EACH_EQUAL_FLOAT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_FLOAT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_FLOAT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_FLOAT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_FLOAT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_FLOAT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_LESS_THAN_FLOAT((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_FLOAT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_LESS_OR_EQUAL_FLOAT((threshold), (actual), __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_NOT_EQUAL_DOUBLE_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_DOUBLE((expected), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_DOUBLE_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_DOUBLE_ARRAY_WITHIN((delta), (expected), (actual), (num_elements), __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_EACH_EQUAL_DOUBLE_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_THAN_DOUBLE_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_THAN_DOUBLE_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_LESS_THAN_DOUBLE((threshold), (actual), __LINE__, (message))
|
|
||||||
#define TEST_ASSERT_LESS_OR_EQUAL_DOUBLE_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_LESS_OR_EQUAL_DOUBLE((threshold), (actual), __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))
|
|
||||||
|
|
||||||
/* Shorthand */
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_OLD
|
|
||||||
#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))
|
|
||||||
#endif
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_INT
|
|
||||||
#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_FAIL(__LINE__, UnityStrErrShorthand)
|
|
||||||
#endif
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_MEM
|
|
||||||
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_MEMORY((&expected), (&actual), sizeof(expected), __LINE__, message)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
|
||||||
#endif
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_RAW
|
|
||||||
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) == (actual)), __LINE__, message)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, message)
|
|
||||||
#endif
|
|
||||||
#ifdef UNITY_SHORTHAND_AS_NONE
|
|
||||||
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
|
||||||
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* end of UNITY_FRAMEWORK_H */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
File diff suppressed because it is too large
Load Diff
84
test/validation/test.bats
Normal file
84
test/validation/test.bats
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
bin() { ./scl.out $1 | tail -n1; }
|
||||||
|
|
||||||
|
@test "simple addition" {
|
||||||
|
run bin "1+1"
|
||||||
|
[ "$output" = "= 2.000000" ]
|
||||||
|
|
||||||
|
run bin "-1+1"
|
||||||
|
[ "$output" = "= 0.000000" ]
|
||||||
|
|
||||||
|
run bin "1+-1"
|
||||||
|
[ "$output" = "= 0.000000" ]
|
||||||
|
|
||||||
|
run bin "-1+-1"
|
||||||
|
[ "$output" = "= -2.000000" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "simple subtraction" {
|
||||||
|
run bin "1-1"
|
||||||
|
[ "$output" = "= 0.000000" ]
|
||||||
|
|
||||||
|
run bin "-1-1"
|
||||||
|
[ "$output" = "= -2.000000" ]
|
||||||
|
|
||||||
|
run bin "1--1"
|
||||||
|
[ "$output" = "= 2.000000" ]
|
||||||
|
|
||||||
|
run bin "-1--1"
|
||||||
|
[ "$output" = "= 0.000000" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "simple multiplication" {
|
||||||
|
run bin "1*2"
|
||||||
|
[ "$output" = "= 2.000000" ]
|
||||||
|
|
||||||
|
run bin "-1*2"
|
||||||
|
[ "$output" = "= -2.000000" ]
|
||||||
|
|
||||||
|
run bin "1*-1"
|
||||||
|
[ "$output" = "= -1.000000" ]
|
||||||
|
|
||||||
|
run bin "-1*-1"
|
||||||
|
[ "$output" = "= 1.000000" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "simple division" {
|
||||||
|
run bin "1/2"
|
||||||
|
[ "$output" = "= 0.500000" ]
|
||||||
|
|
||||||
|
run bin "-1/2"
|
||||||
|
[ "$output" = "= -0.500000" ]
|
||||||
|
|
||||||
|
run bin "1/-1"
|
||||||
|
[ "$output" = "= -1.000000" ]
|
||||||
|
|
||||||
|
run bin "-1/-1"
|
||||||
|
[ "$output" = "= 1.000000" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "order of operations" {
|
||||||
|
run bin "1+2*3"
|
||||||
|
[ "$output" = "= 7.000000" ]
|
||||||
|
|
||||||
|
run bin "2*3+1"
|
||||||
|
[ "$output" = "= 7.000000" ]
|
||||||
|
|
||||||
|
run bin "6/2-1"
|
||||||
|
[ "$output" = "= 2.000000" ]
|
||||||
|
|
||||||
|
run bin "1-6/2"
|
||||||
|
[ "$output" = "= -2.000000" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "order of operations with parenthesis" {
|
||||||
|
run bin "(1+2)*3"
|
||||||
|
[ "$output" = "= 9.000000" ]
|
||||||
|
|
||||||
|
run bin "-(1+2*3)"
|
||||||
|
[ "$output" = "= -7.000000" ]
|
||||||
|
|
||||||
|
run bin "-(-(1+2)*3)"
|
||||||
|
[ "$output" = "= 9.000000" ]
|
||||||
|
}
|
Reference in New Issue
Block a user