Browse Source

Eingabe test ohne else, Emman Mensdorf

remotes/origin/Läufer-fertig,-Hendrik-Voß
Emman Mensdorf 11 months ago
parent
commit
2c23ecff9c
  1. 12
      build/test/cache/input.yml
  2. 94
      build/test/cache/test_schach.c
  3. 10
      build/test/dependencies/cmock.d
  4. 0
      build/test/dependencies/force_build
  5. 4
      build/test/dependencies/test_schach.d
  6. 4
      build/test/dependencies/test_schach_runner.d
  7. 6
      build/test/dependencies/unity.d
  8. BIN
      build/test/out/c/cmock.o
  9. BIN
      build/test/out/c/schach.o
  10. BIN
      build/test/out/c/test_schach.o
  11. BIN
      build/test/out/c/test_schach_runner.o
  12. BIN
      build/test/out/c/unity.o
  13. BIN
      build/test/out/test_schach.out
  14. 94
      build/test/preprocess/files/test_schach.c
  15. 2
      build/test/preprocess/includes/test_schach.c
  16. 12
      build/test/results/test_schach.pass
  17. 4
      build/test/runners/test_schach_runner.c
  18. 35
      src/schach.c
  19. 7
      src/schach.h
  20. 1
      temp_input.txt
  21. 31
      test/test_schach.c

12
build/test/cache/input.yml

@ -77,10 +77,10 @@
:testfail: ".fail"
:dependencies: ".d"
:unity:
:vendor_path: C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor
:vendor_path: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor
:defines: []
:cmock:
:vendor_path: C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor
:vendor_path: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor
:defines: []
:includes: []
:mock_prefix: mock_
@ -99,7 +99,7 @@
:verbosity: 3
:unity_helper: false
:cexception:
:vendor_path: C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor
:vendor_path: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor
:defines: []
:test_runner:
:includes: []
@ -223,13 +223,13 @@
:arguments: []
:plugins:
:load_paths:
- C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins
- C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins
:enabled:
- stdout_pretty_tests_report
- module_generator
:display_raw_test_results: false
:stdout_pretty_tests_report_path: C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/stdout_pretty_tests_report
:module_generator_path: C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/module_generator
:stdout_pretty_tests_report_path: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/stdout_pretty_tests_report
:module_generator_path: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/module_generator
:gcov:
:reports:
- HtmlDetailed

94
build/test/cache/test_schach.c

@ -1,5 +1,7 @@
#include "src/schach.h"
#include "C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h"
#include "C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h"
@ -48,12 +50,98 @@ void test_print_Schachfeld(void){
((void *)0)
), (UNITY_UINT)(25), UNITY_DISPLAY_STYLE_CHAR);
), (UNITY_UINT)(26), UNITY_DISPLAY_STYLE_CHAR);
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((expected)), (UNITY_INT)(UNITY_INT8 )((Spielfeld[1][0])), (
((void *)0)
), (UNITY_UINT)(26), UNITY_DISPLAY_STYLE_CHAR);
), (UNITY_UINT)(27), UNITY_DISPLAY_STYLE_CHAR);
}
void test_read_input(void) {
const char *input = "8\n";
int result = 0;
int expected = 7;
FILE *original_stdin = freopen(
((void *)0)
, "r",
(__acrt_iob_func(0))
);
FILE *tempInput = fopen("temp_input.txt", "w");
fputs(input, tempInput);
fclose(tempInput);
tempInput = freopen("temp_input.txt", "r",
(__acrt_iob_func(0))
);
result = read_input();
UnityAssertEqualNumber((UNITY_INT)((expected)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(49), UNITY_DISPLAY_STYLE_INT);
fclose(tempInput);
freopen("/dev/tty", "r",
(__acrt_iob_func(0))
);
freopen(
((void *)0)
, "r",
(__acrt_iob_func(0))
);
}

10
build/test/dependencies/cmock.d

@ -1,6 +1,6 @@
build/test/out/c/cmock.o: \
C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.c \
C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.h \
C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock_internals.h \
C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \
C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.c \
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.h \
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock_internals.h \
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h

0
build/test/dependencies/force_build

4
build/test/dependencies/test_schach.d

@ -1,4 +1,4 @@
build/test/out/c/test_schach.o: test/test_schach.c \
C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \
C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \
src/schach.h

4
build/test/dependencies/test_schach_runner.d

@ -1,4 +1,4 @@
build/test/out/c/test_schach_runner.o: \
build/test/runners/test_schach_runner.c \
C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \
C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h

6
build/test/dependencies/unity.d

@ -1,4 +1,4 @@
build/test/out/c/unity.o: \
C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.c \
C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \
C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.c \
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h

BIN
build/test/out/c/cmock.o

BIN
build/test/out/c/schach.o

BIN
build/test/out/c/test_schach.o

BIN
build/test/out/c/test_schach_runner.o

BIN
build/test/out/c/unity.o

BIN
build/test/out/test_schach.out

94
build/test/preprocess/files/test_schach.c

@ -1,5 +1,7 @@
#include "src/schach.h"
#include "C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h"
#include "C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h"
@ -48,12 +50,98 @@ void test_print_Schachfeld(void){
((void *)0)
), (UNITY_UINT)(25), UNITY_DISPLAY_STYLE_CHAR);
), (UNITY_UINT)(26), UNITY_DISPLAY_STYLE_CHAR);
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((expected)), (UNITY_INT)(UNITY_INT8 )((Spielfeld[1][0])), (
((void *)0)
), (UNITY_UINT)(26), UNITY_DISPLAY_STYLE_CHAR);
), (UNITY_UINT)(27), UNITY_DISPLAY_STYLE_CHAR);
}
void test_read_input(void) {
const char *input = "8\n";
int result = 0;
int expected = 7;
FILE *original_stdin = freopen(
((void *)0)
, "r",
(__acrt_iob_func(0))
);
FILE *tempInput = fopen("temp_input.txt", "w");
fputs(input, tempInput);
fclose(tempInput);
tempInput = freopen("temp_input.txt", "r",
(__acrt_iob_func(0))
);
result = read_input();
UnityAssertEqualNumber((UNITY_INT)((expected)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(49), UNITY_DISPLAY_STYLE_INT);
fclose(tempInput);
freopen("/dev/tty", "r",
(__acrt_iob_func(0))
);
freopen(
((void *)0)
, "r",
(__acrt_iob_func(0))
);
}

2
build/test/preprocess/includes/test_schach.c

@ -1,3 +1,3 @@
---
- C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h
- C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h
- src/schach.h

12
build/test/results/test_schach.pass

@ -4,15 +4,19 @@
:file: test_schach.c
:successes:
- :test: test_print_Schachfeld
:line: 15
:line: 16
:message: ''
:unity_test_time: 0
- :test: test_read_input
:line: 30
:message: ''
:unity_test_time: 0
:failures: []
:ignores: []
:counts:
:total: 1
:passed: 1
:total: 2
:passed: 2
:failed: 0
:ignored: 0
:stdout: []
:time: 0.13277340000058757
:time: 0.06211079999047797

4
build/test/runners/test_schach_runner.c

@ -11,6 +11,7 @@ char* GlobalOrderError;
extern void setUp(void);
extern void tearDown(void);
extern void test_print_Schachfeld(void);
extern void test_read_input(void);
/*=======Mock Management=====*/
@ -75,7 +76,8 @@ static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE l
int main(void)
{
UnityBegin("test_schach.c");
run_test(test_print_Schachfeld, "test_print_Schachfeld", 15);
run_test(test_print_Schachfeld, "test_print_Schachfeld", 16);
run_test(test_read_input, "test_read_input", 30);
return UnityEnd();
}

35
src/schach.c

@ -36,6 +36,37 @@
8.Schritt 2-8 wird Wiederholt
*/
int read_input(){
int koordinate = 0;
scanf("%d", &koordinate);
if(koordinate < 9){
return koordinate - 1;
}
else{
}
}
void choose_Figur(){
int x,y;
printf("X-Koordinaten der Figur der bewegt werden soll eingeben:\n");
x = read_input();
printf("X-Koordinaten der Figur der bewegt werden soll eingeben:\n");
y = read_input();
}
void print_Schachfeld(char** Spielfeld, int x, int y) {
for (int i = 0; i < x; i++) {
@ -70,7 +101,6 @@ void free_Schachfeld(char** Spielfeld, int x) {
free(Spielfeld);
}
/*
int main() {
int x = 8;
@ -83,5 +113,4 @@ int main() {
return 0;
}
*/
*/

7
src/schach.h

@ -5,4 +5,9 @@ void print_Schachfeld(char** , int , int );
char** create_Schachfeld(int , int );
void free_Schachfeld(char** , int );
#endif
int read_input();
void choose_Figur();
#endif

1
temp_input.txt

@ -0,0 +1 @@
8

31
test/test_schach.c

@ -4,6 +4,7 @@
#include "schach.h"
#include "string.h"
void setUp(void)
{
}
@ -26,4 +27,34 @@ void test_print_Schachfeld(void){
TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[1][0]);
}
void test_read_input(void) {
/* arrange */
const char *input = "8\n";
int result = 0;
int expected = 7;
FILE *original_stdin = freopen(NULL, "r", stdin);
FILE *tempInput = fopen("temp_input.txt", "w");
fputs(input, tempInput);
fclose(tempInput);
tempInput = freopen("temp_input.txt", "r", stdin);
/* act */
result = read_input();
/* assert */
TEST_ASSERT_EQUAL_INT(expected, result);
/* Clean up */
fclose(tempInput);
freopen("/dev/tty", "r", stdin);
freopen(NULL, "r", stdin);
}
#endif // TEST
Loading…
Cancel
Save