-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from knixeur/reactivate_tests
Reactivate tests
- Loading branch information
Showing
11 changed files
with
268 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# System-specific configuration is in system.mk | ||
TOPDIR=../.. | ||
include $(TOPDIR)/build/system-inc.mk | ||
|
||
###################################### | ||
|
||
# SOURCES=../readconfig.c ../misc.c | ||
|
||
#LIBS += $(LUA_LIBS) $(DL_LIBS) -lm | ||
INCLUDES += -I.. $(LIBTU_INCLUDES) $(LUA_INCLUDES) | ||
CFLAGS += $(XOPEN_SOURCE) $(C99_SOURCE) | ||
|
||
SOURCES=../readconfig.c ../misc.c | ||
|
||
LIBS += $(LIBTU_LIBS) $(LUA_LIBS) $(DL_LIBS) -lm | ||
|
||
HEADERS=readconfig.h extl.h luaextl.h private.h types.h | ||
|
||
|
||
###################################### | ||
|
||
include $(TOPDIR)/build/rules.mk | ||
|
||
###################################### | ||
|
||
test: $(SOURCES) | ||
$(CC) $(CFLAGS) -o extltest $(SOURCES) extltest.c $(INCLUDES) $(LIBS) | ||
./extltest | ||
# $(RM) extltest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# System-specific configuration is in system.mk | ||
TOPDIR=../.. | ||
include $(TOPDIR)/build/system-inc.mk | ||
|
||
###################################### | ||
|
||
SOURCES=../misc.c ../tokenizer.c ../util.c ../output.c | ||
|
||
LIBS += $(LUA_LIBS) $(DL_LIBS) -lm | ||
INCLUDES += $(LIBTU_INCLUDES) | ||
CFLAGS += $(XOPEN_SOURCE) $(C99_SOURCE) | ||
|
||
###################################### | ||
|
||
include $(TOPDIR)/build/rules.mk | ||
|
||
###################################### | ||
|
||
test: $(SOURCES) | ||
$(CC) $(CFLAGS) -o tutest $(SOURCES) tutest.c $(LIBS) | ||
./tutest | ||
$(RM) ./tutest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
1 | ||
2.3 # comment ignored | ||
# realcomment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* libtu/tester.c | ||
* | ||
* Copyright (c) Tuomo Valkonen 1999-2002. | ||
* | ||
* You may distribute and modify this library under the terms of either | ||
* the Clarified Artistic License or the GNU LGPL, version 2.1 or later. | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
#include "../misc.h" | ||
#include "../tokenizer.h" | ||
#include "../util.h" | ||
|
||
int test_get_token() { | ||
Tokenizer*tokz; | ||
Token tok=TOK_INIT; | ||
|
||
if(!(tokz=tokz_open("data_gettoken"))) | ||
return 1; | ||
|
||
// 1 | ||
if(tokz_get_token(tokz, &tok) == FALSE) | ||
return 11; | ||
if (tok.type != TOK_LONG) | ||
return 12; | ||
if (TOK_LONG_VAL(&tok) != 1) | ||
return 13; | ||
|
||
// \n | ||
if(tokz_get_token(tokz, &tok) == FALSE) | ||
return 21; | ||
if (tok.type != TOK_OP) | ||
return 22; | ||
|
||
// 2.3 | ||
if(tokz_get_token(tokz, &tok) == FALSE) | ||
return 31; | ||
if (tok.type != TOK_DOUBLE) | ||
return 32; | ||
if (TOK_DOUBLE_VAL(&tok) != 2.3) | ||
return 33; | ||
|
||
// ignore comment and go to next line | ||
if(tokz_get_token(tokz, &tok) == FALSE) | ||
return 41; | ||
if (tok.type != TOK_OP) | ||
return 42; | ||
if (TOK_OP_VAL(&tok) != OP_NEXTLINE) | ||
return 43; | ||
|
||
// ignore line | ||
if(tokz_get_token(tokz, &tok) == FALSE) | ||
return 51; | ||
if (tok.type != TOK_OP) | ||
return 52; | ||
if (TOK_OP_VAL(&tok) != OP_EOF) | ||
return 53; | ||
|
||
tokz_close(tokz); | ||
/* | ||
while(tokz_get_token(tokz, &tok)){ | ||
switch(tok.type){ | ||
case TOK_LONG: | ||
printf("long - %ld\n", TOK_LONG_VAL(&tok)); | ||
break; | ||
case TOK_DOUBLE: | ||
printf("double - %g\n", TOK_DOUBLE_VAL(&tok)); | ||
break; | ||
case TOK_CHAR: | ||
printf("char - '%c'\n", TOK_CHAR_VAL(&tok)); | ||
break; | ||
case TOK_STRING: | ||
printf("string - \"%s\"\n", TOK_STRING_VAL(&tok)); | ||
break; | ||
case TOK_IDENT: | ||
printf("ident - %s\n", TOK_IDENT_VAL(&tok)); | ||
break; | ||
case TOK_COMMENT: | ||
printf("comment - %s\n", TOK_COMMENT_VAL(&tok)); | ||
break; | ||
case TOK_OP: | ||
printf("operator - %03x\n", TOK_OP_VAL(&tok)); | ||
break; | ||
} | ||
} | ||
*/ | ||
return 0; | ||
} | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
fprintf(stdout, "[TESTING] libtu ====\n"); | ||
libtu_init(argv[0]); | ||
|
||
int result = 0; | ||
int err = 0; | ||
|
||
fprintf(stdout, "[TEST] test_get_token: "); | ||
result = test_get_token(); | ||
if (result != 0) { | ||
fprintf(stdout, "[ERROR]: %d\n", result); | ||
err += 1; | ||
} else { | ||
fprintf(stdout, "[OK]\n"); | ||
} | ||
|
||
return err; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters